https://github.com/hoshinotsuyoshi/acts_as_shellscript_executable
https://github.com/hoshinotsuyoshi/acts_as_shellscript_executable
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/hoshinotsuyoshi/acts_as_shellscript_executable
- Owner: hoshinotsuyoshi
- License: mit
- Created: 2014-09-20T07:22:11.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-09-30T00:09:23.000Z (over 10 years ago)
- Last Synced: 2025-03-25T04:13:26.489Z (2 months ago)
- Language: Ruby
- Size: 1.05 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ActsAsShellscriptExecutable
[](https://travis-ci.org/hoshinotsuyoshi/acts_as_shellscript_executable)
[](https://coveralls.io/r/hoshinotsuyoshi/acts_as_shellscript_executable)
[](https://codeclimate.com/github/hoshinotsuyoshi/acts_as_shellscript_executable)### before:
| id | name | script | result |
| :---|:----- |:--------------|:-------|
| 1 | foo | echo 'lalala' | |### execute:
```ruby
class Script < ActiveRecord::Base
acts_as_shellscript_executable script: :script
end
``````ruby
script = Script.find(1)
script.result = script.execute!
script.save!
```### after:
| id | name | script | result |
| :---|:----- |:--------------|:---------|
| 1 | foo | echo 'lalala' | lalala\n |## #execute!
* `#execute!(no args)`
* returns the shellscript's 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* `method:` (default: `execute!`)
* the execute method's name* `command:` (default: `'/bin/sh'`)
## Options of `.acts_as_rubyscript_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* `method:` (default: `ruby_execute!`)
* the execute method's name* `command:` (default: `'ruby'`)
* Set path like `'/usr/bin/ruby'`, or array to set option like `['ruby', '-c']`, `['bundle exec rails', 'r']`## 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