GithubHelp home page GithubHelp logo

rush's Introduction

rush – manage your unix systems with pure Ruby

rush is a unix integration library and an interactive shell which uses pure Ruby syntax. Walk directory trees; create, copy, search, and destroy files; find and kill processes - everything you’d normally do with shell commands, now in the strict and elegant world of Ruby.

Usage

Count the number of classes in your project using bash:

find myproj -name \*.rb | xargs grep '^\s*class' | wc -l

In rush, this is:

myproj['**/*.rb'].search(/^\s*class/).lines.size

Pesky stray mongrels? In bash:

kill `ps aux | grep mongrel_rails | grep -v grep | cut -c 10-20`

In rush:

processes.filter(:cmdline => /mongrel_rails/).kill

As a library

require 'rubygems'
require 'rush'

file = Rush['/tmp/myfile']
file.write "hello"
puts file.contents
file.destroy

puts Rush.my_process.pid
puts Rush.processes.size
puts Rush.bash("echo SHELL COMMAND | tr A-Z a-z")
puts Rush.launch_dir['*.rb'].search(/Rush/).entries.inspect

Invoking the shell

Run the “rush” binary to enter the interactive shell.

Remote access and clustering

rush can control any number of remote machines from a single location. Copy files or directories between servers as seamlessly as if it was all local.

Example of remote access:

local = Rush::Box.new('localhost')
remote = Rush::Box.new('my.remote.server.com')
local_dir = local['/Users/adam/myproj/']
remote_dir = remote['/home/myproj/app/']

local_dir.copy_to remote_dir
remote_dir['**/.svn/'].each { |d| d.destroy }

Clustering:

local_dir = Rush::Box.new('localhost')['/Users/adam/server_logs/'].create
servers = %w(www1 www2 www3).map { |n| Rush::Box.new(n) }
servers.each { |s| s['/var/log/nginx/access.log'].copy_to local_dir["#{s.host}_access.log"] }

Reference

For more details on syntax and commands, see:

  • Rush

  • Rush::Entry

  • Rush::File

  • Rush::Dir

  • Rush::Commands

  • Rush::Box

  • Rush::Process

Meta

Created by Adam Wiggins

Patches contributed by Chihiro Ito, Gabriel Ware, Michael Schutte, Ricardo Chimal Jr., and Nicholas Schlueter, Pedro Belo, and Martin Kuehl

Logo by James Lindenbaum

Released under the MIT License: www.opensource.org/licenses/mit-license.php

rush.heroku.com

groups.google.com/group/ruby-shell

rush's People

Contributors

mkhl avatar fabiokung avatar ricardochimal avatar schlu avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.