Class: ClientSideValidations::Generators::CopyAssetsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ClientSideValidations::Generators::CopyAssetsGenerator
- Defined in:
- lib/generators/client_side_validations/copy_assets_generator.rb
Direct Known Subclasses
Class Method Summary collapse
- .asset_directory ⇒ Object
- .asset_file_names ⇒ Object
- .asset_pipeline_enabled? ⇒ Boolean
- .assets ⇒ Object
- .installation_message ⇒ Object
Instance Method Summary collapse
Class Method Details
.asset_directory ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/generators/client_side_validations/copy_assets_generator.rb', line 12 def self.asset_directory if asset_pipeline_enabled? "app#{Rails.configuration.assets.prefix}/javascripts" else 'public/javascripts' end end |
.asset_file_names ⇒ Object
24 25 26 |
# File 'lib/generators/client_side_validations/copy_assets_generator.rb', line 24 def self.asset_file_names assets.map { |asset| asset[:file] }.join(', ') end |
.asset_pipeline_enabled? ⇒ Boolean
28 29 30 31 |
# File 'lib/generators/client_side_validations/copy_assets_generator.rb', line 28 def self.asset_pipeline_enabled? # Rails 4.1 doesn't provide :enabled in asset configuration, so we look for Sprockets defined?(Sprockets).present? end |
.assets ⇒ Object
20 21 22 |
# File 'lib/generators/client_side_validations/copy_assets_generator.rb', line 20 def self.assets ClientSideValidations::Generators.assets end |
.installation_message ⇒ Object
33 34 35 |
# File 'lib/generators/client_side_validations/copy_assets_generator.rb', line 33 def self. "Copies #{asset_file_names} to #{asset_directory}" end |
Instance Method Details
#copy_javascript_asset ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/generators/client_side_validations/copy_assets_generator.rb', line 4 def copy_javascript_asset return unless self.class == CopyAssetsGenerator || !asset_pipeline_enabled? assets.each do |asset| source_paths << asset[:path] copy_file asset[:file], "#{asset_directory}/#{asset[:file]}" end end |