Class: Silmarails::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/silmarails/install/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



6
7
8
# File 'lib/generators/silmarails/install/install_generator.rb', line 6

def self.source_root
  @source_root ||= Silmarails::Engine.root.join "lib/generators/silmarails/install/files"
end

Instance Method Details

#install_filesObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/generators/silmarails/install/install_generator.rb', line 10

def install_files
  templates = self.class.source_root.join "templates"
  Dir[templates.join "**/*.*"].each do |file|
    copy_file file, "lib/templates/#{file.gsub(templates.to_s, "")}"
  end

  framework = options[:framework] || "bootstrap"
  framework_templates = self.class.source_root.join "#{framework}/templates"
  Dir[framework_templates.join "**/*.*"].each do |file|
    copy_file file, "lib/templates/#{file.gsub(framework_templates.to_s, "")}"
  end

  spec_support = self.class.source_root.join "spec/support"
  Dir[spec_support.join "**/*.*"].each do |file|
    copy_file file, "spec/support/#{file.gsub(spec_support.to_s, "")}"
  end
end