ActsAsShellscriptExecutable

travis-batch Coverage Status Code Climate

before:

id name script result
1 foo echo 'lalala'

execute:

class Script < ActiveRecord::Base
  acts_as_shellscript_executable script: :script
end
script = Script.find(1)
script.result = script.execute!
script.save!

after:

id name script result
1 foo echo 'lalala' lalala

#execute!

  • #execute!(nil)

    • returns scripts stdout of whole of the shellscript
  • #execute!(block)

    • returns nil, yields the shellscript's stdout st each line(splited by \n)

Options of .acts_as_shellscript_executable

  • script: (default: :script)

    • if Symbol, the same name column's value will be evaluated as shellscript
    • if String, the string will be evaluated as shellscript
  • parallel: (default: false)

    • if true, the script will run in parallel by using thread
  • method: (default: execute!)

    • the execute method's name

Installation

Add this line to your application's Gemfile:

gem 'acts_as_shellscript_executable'

And then execute:

$ bundle

Or install it yourself as:

$ gem install acts_as_shellscript_executable

Contributing

  1. Fork it ( http://github.com/hoshinotsuyoshi/acts_as_shellscript_executable/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request