Class: Jeny::Command::Generate
- Inherits:
-
Object
- Object
- Jeny::Command::Generate
- Includes:
- Support
- Defined in:
- lib/jeny/command/generate.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(config, data, from, to) ⇒ Generate
constructor
A new instance of Generate.
Methods included from Support
#edit_changed_files, simplify_path
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
12 13 14 |
# File 'lib/jeny/command/generate.rb', line 12 def config @config end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
12 13 14 |
# File 'lib/jeny/command/generate.rb', line 12 def data @data end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
12 13 14 |
# File 'lib/jeny/command/generate.rb', line 12 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
12 13 14 |
# File 'lib/jeny/command/generate.rb', line 12 def to @to end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/jeny/command/generate.rb', line 14 def call puts changed = [] from.glob("**/*") do |source| target = target_for(source) puts "creating #{simplify_path(target)}" if source.directory? target.mkdir_p else target.parent.mkdir_p file = File::Full.new(source, config) target_content = file.instantiate(data) target.write(target_content) changed << [target, target_content] end end edit_changed_files(changed) end |