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
- .assets ⇒ Object
- .copy_assets? ⇒ Boolean
- .installation_message ⇒ Object
- .sprockets? ⇒ Boolean
- .webpacker? ⇒ Boolean
Instance Method Summary collapse
Class Method Details
.asset_directory ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/generators/client_side_validations/copy_assets_generator.rb', line 15 def self.asset_directory if sprockets? "app#{Rails.configuration.assets.prefix}/javascripts" else 'public/javascripts' end end |
.asset_file_names ⇒ Object
27 28 29 |
# File 'lib/generators/client_side_validations/copy_assets_generator.rb', line 27 def self.asset_file_names assets.map { |asset| asset[:file] }.join(', ') end |
.assets ⇒ Object
23 24 25 |
# File 'lib/generators/client_side_validations/copy_assets_generator.rb', line 23 def self.assets ClientSideValidations::Generators.assets end |
.copy_assets? ⇒ Boolean
31 32 33 |
# File 'lib/generators/client_side_validations/copy_assets_generator.rb', line 31 def self.copy_assets? !sprockets? && !webpacker? end |
.installation_message ⇒ Object
43 44 45 |
# File 'lib/generators/client_side_validations/copy_assets_generator.rb', line 43 def self. "Copies #{asset_file_names} to #{asset_directory}" end |
.sprockets? ⇒ Boolean
35 36 37 |
# File 'lib/generators/client_side_validations/copy_assets_generator.rb', line 35 def self.sprockets? defined?(Sprockets) end |
.webpacker? ⇒ Boolean
39 40 41 |
# File 'lib/generators/client_side_validations/copy_assets_generator.rb', line 39 def self.webpacker? defined?(Webpacker) end |
Instance Method Details
#copy_javascript_asset ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/generators/client_side_validations/copy_assets_generator.rb', line 6 def copy_javascript_asset return unless instance_of?(CopyAssetsGenerator) || copy_assets? assets.each do |asset| source_paths << asset[:path] copy_file asset[:file], "#{asset_directory}/#{asset[:file]}" end end |