Class: Huck::Generators::ExecGenerator
- Inherits:
-
Huck::Generator
- Object
- Huck::Generator
- Huck::Generators::ExecGenerator
- Defined in:
- lib/huck/generators/exec.rb
Overview
A generator to execute arbitrary scripts and use their output
Instance Attribute Summary
Attributes inherited from Huck::Generator
Instance Method Summary collapse
-
#generate ⇒ Object
Generate data by running a command and collecting output.
-
#initialize ⇒ ExecGenerator
constructor
Includes all required modules.
-
#verify_config ⇒ Object
Ensures that configuration is set properly before executing.
Methods inherited from Huck::Generator
Constructor Details
#initialize ⇒ ExecGenerator
Includes all required modules
9 10 11 |
# File 'lib/huck/generators/exec.rb', line 9 def initialize Huck::must_load 'open3' end |
Instance Method Details
#generate ⇒ Object
Generate data by running a command and collecting output
21 22 23 24 25 26 27 28 |
# File 'lib/huck/generators/exec.rb', line 21 def generate verify_config Open3.popen2e @config['command'] do |_, output, thread| thread.value # wait for process to complete return output.read end end |
#verify_config ⇒ Object
Ensures that configuration is set properly before executing
14 15 16 17 18 |
# File 'lib/huck/generators/exec.rb', line 14 def verify_config if !@config.has_key? 'command' raise Huck::Error, 'missing "exec" generator config: "command"' end end |