ActsAsShellscriptExecutable
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
)
- returns
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
- if
parallel:
(default:false
)- if true, the script will run in parallel by using
thread
- if true, the script will run in parallel by using
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
- Fork it ( http://github.com/hoshinotsuyoshi/acts_as_shellscript_executable/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request