class Corundum::CLI::Skelfiles::Skelfile

Attributes

exclude[R]
message[R]
source[R]
target[R]

Public Class Methods

new(source, target, exclude) click to toggle source
# File lib/corundum/cli/skelfiles.rb, line 9
def initialize(source, target, exclude)
  @source, @target, @exclude = source, target, exclude
  @message = "No attempt to create yet"
end

Public Instance Methods

create!(scope) click to toggle source
# File lib/corundum/cli/skelfiles.rb, line 19
def create!(scope)
  unless (found = exclude.map{|pattern| Dir.glob(pattern)}.flatten).empty?
    @message = "Refusing to clobber existing '#{found.first}'"
  else
    File::open(target, "w") do |file|
      contents = templates.contents(source)
      case contents
      when Tilt::Template
        file.write(contents.render(scope, {}))
      else
        file.write(contents)
      end
    end
    @message = "Created #{target}"
  end
end
templates() click to toggle source
# File lib/corundum/cli/skelfiles.rb, line 15
def templates
  Corundum.configuration_store.valise.templates("skel-files")
end