Sha256: fe1caa3b5dcc9de95fe60a73d29160abec096a17129491a7f2bf6d1563224e9e
Contents?: true
Size: 994 Bytes
Versions: 4
Compression:
Stored size: 994 Bytes
Contents
class WagonGenerator < Rails::Generators::NamedBase #:nodoc: attr_reader :wagon_name source_root File.expand_path('../templates', __FILE__) def initialize(*args) super @wagon_name = name assign_names!("#{application_name}_#{name}") end def copy_templates self.destination_root = "vendor/wagons/#{wagon_name}" # do this whole manual traversal to be able to replace every single file # individually in the application. all_templates.each do |file| if File.basename(file) == '.empty_directory' file = File.dirname(file) directory(file, File.join(destination_root, file)) else template(file, File.join(destination_root, file.sub(/\.tt$/, ''))) end end end private def all_templates source_paths.collect do |path| Dir[File.join(path, "**", "{*,.[a-z]*}")]. select {|f| File.file?(f) }. collect {|f| f.sub(path + File::SEPARATOR, '') } end.flatten.uniq.sort end end
Version data entries
4 entries across 4 versions & 1 rubygems