Sha256: ea0febf16d51ae630f8a9d38949ed37aa7bc5c5e821766ef8da3787214ab2892

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

class Rafters::ComponentGenerator < Rails::Generators::NamedBase
  source_root File.expand_path("../templates", __FILE__)

  def create_directories
    empty_directory "#{base_directory}"
    empty_directory "#{base_directory}/assets"
    empty_directory "#{base_directory}/assets/javascripts"
    empty_directory "#{base_directory}/assets/stylesheets"
    empty_directory "#{base_directory}/assets/images"
    empty_directory "#{base_directory}/sources"
    empty_directory "#{base_directory}/views"
  end

  def create_gitkeeps
    create_file "#{base_directory}/assets/images/.gitkeep"
  end

  def create_files
    template "component.rb.erb", "#{base_directory}/#{file_name}_component.rb"
    template "assets/javascripts/component.js.erb", "#{base_directory}/assets/javascripts/#{file_name}_component.js"
    template "assets/stylesheets/component.scss.erb", "#{base_directory}/assets/stylesheets/#{file_name}_component.scss"
    template "views/component.html.erb", "#{base_directory}/views/#{file_name}_component.html.erb"
  end

  private

  def base_directory
    "app/components/#{file_name}"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rafters-1.2.1 lib/generators/rafters/component/component_generator.rb
rafters-1.2.0 lib/generators/rafters/component/component_generator.rb