Class: Scaffolder::Tool
- Inherits:
-
Object
- Object
- Scaffolder::Tool
- Defined in:
- lib/scaffolder/tool.rb
Instance Attribute Summary collapse
-
#scaffold_file ⇒ Object
readonly
Returns the value of attribute scaffold_file.
-
#sequence_file ⇒ Object
readonly
Returns the value of attribute sequence_file.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Instance Method Summary collapse
-
#initialize(settings) ⇒ Tool
constructor
A new instance of Tool.
- #run(out = STDOUT, err = STDERR) ⇒ Object
- #scaffold ⇒ Object
Constructor Details
#initialize(settings) ⇒ Tool
Returns a new instance of Tool.
10 11 12 13 14 |
# File 'lib/scaffolder/tool.rb', line 10 def initialize(settings) @scaffold_file = settings.rest.first @sequence_file = settings.rest.last @settings = settings end |
Instance Attribute Details
#scaffold_file ⇒ Object (readonly)
Returns the value of attribute scaffold_file.
6 7 8 |
# File 'lib/scaffolder/tool.rb', line 6 def scaffold_file @scaffold_file end |
#sequence_file ⇒ Object (readonly)
Returns the value of attribute sequence_file.
7 8 9 |
# File 'lib/scaffolder/tool.rb', line 7 def sequence_file @sequence_file end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
8 9 10 |
# File 'lib/scaffolder/tool.rb', line 8 def settings @settings end |
Instance Method Details
#run(out = STDOUT, err = STDERR) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/scaffolder/tool.rb', line 16 def run(out=STDOUT,err=STDERR) begin = execute rescue Exception => e err.puts("Error. #{e.}") exit(1) else out.puts() if exit(0) end end |
#scaffold ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/scaffolder/tool.rb', line 28 def scaffold {:Scaffold => @scaffold_file, :Sequence => @sequence_file}.each do |name,file| unless File.exists?(file) raise ArgumentError.new("#{name} file not found: #{file}") end if File.size(file) == 0 raise ArgumentError.new("#{name} file is empty: #{file}") end end Scaffolder.new(YAML.load(File.read(@scaffold_file)),@sequence_file) end |