Class: UtilityColors::Generators::GenerateGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/utility_colors/generate_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.config_format_warnObject

TODO: add links to README for migration



28
29
30
# File 'lib/generators/utility_colors/generate_generator.rb', line 28

def self.config_format_warn
  warn 'WARNING: Utility Colors now uses an initializer to set config. You need to migrate and remove your YML/JSON file.'
end

.disabled_warnObject

TODO: add links to README for environment setting



33
34
35
# File 'lib/generators/utility_colors/generate_generator.rb', line 33

def self.disabled_warn
  warn 'ERROR: Utility Colors is disabled for this environment. Color classes will not be generated.'
end

Instance Method Details

#generate_utility_colorsObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/generators/utility_colors/generate_generator.rb', line 13

def generate_utility_colors
  # TODO: check if the v0.1.8 scss files exists
  # "app/app/assets/stylesheets/utility_colors_files" directory
  self.class.config_format_warn if File.exist?('config/utility_colors.yml') || File.exist?('config/utility_colors.json')

  if UtilityColors.configuration.enable_environments.include?(Rails.env.to_sym)
    UtilityColors::Colors.generate
  else
    self.class.disabled_warn
  end
end