Sha256: d8c53378deccd48b8f936ab43fb1e2f22d28e4d4a6d40de133d8ee5fad7301a9
Contents?: true
Size: 1.68 KB
Versions: 3
Compression:
Stored size: 1.68 KB
Contents
require 'rails/generators' module Breezeblocks class ImportGenerator < Rails::Generators::Base desc 'Copy breezeblocks' source_root File.expand_path("../../../source", __FILE__) argument :snippet, type: :string, required: true class_option :coffee, type: :boolean, default: false def copy_html copy_file_if_exists( partial_name, File.join('app', 'views', 'breezeblocks', partial_name), ) end def copy_styles copy_file_if_exists( File.join('stylesheets', 'breezeblocks', stylesheet_name), File.join('app', 'assets', 'stylesheets', 'breezeblocks', stylesheet_name), ) end def copy_javascripts copy_file_if_exists( javascript_path, File.join('app', 'assets', 'javascripts', 'breezeblocks', javascript_name), ) end private def copy_file_if_exists(source, destination) if File.exists?(File.join(self.class.source_root, source)) copy_file source, destination end end def partial_name "_#{snippet.underscore}.html.haml" end def stylesheet_name "_#{snippet.dasherize}.sass" end def javascript_name "#{snippet.underscore}.#{javascript_extension}" end def javascript_extension if coffee? "coffee" else "js" end end def javascript_path if coffee? File.join( "javascripts", "breezeblocks", "coffeescript", javascript_name ) else File.join( "javascripts", "breezeblocks", javascript_name ) end end def coffee? options[:coffee] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
breezeblocks-0.0.4 | lib/breezeblocks/import_generator.rb |
breezeblocks-0.0.2 | lib/breezeblocks/import_generator.rb |
breezeblocks-0.0.1 | lib/breezeblocks/import_generator.rb |