Project

shr

0.0
No commit activity in last 3 years
No release in over 3 years
Make controlling subprocess easier in Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 0
 Project Readme

Shr

Description

Shr tries to make controlling subprocess easier in Ruby.

It can be writea shell command as like a Ruby's method and capture subprocess output.

This is a port of Python's sh.

Installation

gem install shr

Require when needed

require 'shr'

Usage

Create instance by Shr#shell

sh = Shr.shell

Run command and capture subprocess output.

puts sh.ls

Redirect [to|from] file

sh.ls > '/tmp/ls_result.txt'
puts sh.cat < '/tmp/ls_result.txt'

Pipes are represented by the chain method

# cat -n /tmp/ls_result.txt | sort -r
puts sh.cat(:n, '/tmp/ls_result.txt').sort(:r)

Bake and run new command

sh.bake(:catn,  :cat   [:n])
sh.bake(:sortr, :sort, [:r])
puts sh.catn('/tmp/ls_result.txt').sortr

License

Released under the MIT License. See the [LICENSE][license] file for further details. [license]: https://github.com/kukenko/shr/LICENSE.md