class Jeny::Command::Generate

Attributes

config[R]
data[R]
from[R]
to[R]

Public Class Methods

new(config, data, from, to) click to toggle source
# File lib/jeny/command/generate.rb, line 6
def initialize(config, data, from, to)
  @config = config
  @data = Caser.for_hash(data)
  @from = from
  @to = to
end

Public Instance Methods

call() click to toggle source
# 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