Sha256: bf0bdcae6c9a345e3c8fa6f2fb642aaf1ebaadfad2804620e402af3e9a2a22b7

Contents?: true

Size: 1.01 KB

Versions: 7

Compression:

Stored size: 1.01 KB

Contents

require 'rails/generators'
module Silmarails
  class InstallGenerator < Rails::Generators::Base
    class_option :framework, desc: 'Frontend framework to use (bootstrap, foundation).'

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

    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
  end
end


Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
silmarails-0.3.4 lib/generators/silmarails/install/install_generator.rb
silmarails-0.3.2 lib/generators/silmarails/install/install_generator.rb
silmarails-0.3.1 lib/generators/silmarails/install/install_generator.rb
silmarails-0.3.0 lib/generators/silmarails/install/install_generator.rb
silmarails-0.2.2 lib/generators/silmarails/install/install_generator.rb
silmarails-0.2.1 lib/generators/silmarails/install/install_generator.rb
silmarails-0.2.0 lib/generators/silmarails/install/install_generator.rb