Class: Snip::Command::Run
- Inherits:
-
Object
- Object
- Snip::Command::Run
- Defined in:
- lib/snip/command/run.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(args, options = {}) ⇒ Run
constructor
A new instance of Run.
Constructor Details
#initialize(args, options = {}) ⇒ Run
Returns a new instance of Run.
6 7 8 9 |
# File 'lib/snip/command/run.rb', line 6 def initialize(args, ={}) @args = Array(args) @options = end |
Instance Method Details
#execute ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/snip/command/run.rb', line 11 def execute name = @args raise NotInitializedError unless Snip::initialized? raise SnippetNotFoundError unless Snip::snippet_exists?(name) snippet = File.read(File.join(Snip::INSTALL_DIR, name)) begin puts snippet.color(:magenta) puts `#{snippet}` rescue raise ExecuteSnippetError end end |