Skip to content
Oeiuwq Faith Blog OpenSource Porfolio

haileys/rbs

ruby port of Python's pbs

haileys/rbs.json
{
"createdAt": "2012-09-04T05:54:41Z",
"defaultBranch": "master",
"description": "ruby port of Python's pbs",
"fullName": "haileys/rbs",
"homepage": null,
"language": "Ruby",
"name": "rbs",
"pushedAt": "2012-09-04T07:12:54Z",
"stargazersCount": 2,
"topics": [],
"updatedAt": "2015-03-12T15:46:23Z",
"url": "https://github.com/haileys/rbs"
}

rbs is a Ruby port of Python’s pbs.

It tries to make shelling out easier and nicer.

gem install rbs

Query the en0 network interface:

require "rbs"
puts rbs.ifconfig "en0"

Check gcc’s version:

require "rbs"
puts rbs.gcc(:version).lines.first

POST some JSON to an API:

require "rbs"
rbs.curl(:X, "POST", :"data-ascii", %{{"my":["example","json","document"]}})
  • rbs supports importing certain commands into the global namespace:

    require "rbs"
    rbs :echo
    echo "hello world"
  • rbs tries to be smart about programs that have dashes in their names:

    require "rbs"
    rbs.llvm_gcc # tries `llvm_gcc` first, and then tries `llvm-gcc`
  • For programs with really funky names, you can use the [] operator:

    require "rbs"
    rbs["ruby-1.9.3-p194", :version] # executes `ruby-1.9.3-p194 --version`
  • rbs supports scopes, so if you’d like to run a bunch of commands as root:

    require "rbs"
    rbs.sudo do
    puts rbs.whoami
    rbs.rm :r, :f, "/"
    end
  • You can also pass a Hash into an rbs command and it will be decomposed into arguments:

    require "rbs"
    rbs.configure prefix: "/usr/local", with_zlib_dir: "/path/to/zlib"
    # executes: `configure --prefix=/usr/local --with-zlib-dir=/path/to/zlib`