Class: Spree::Storefront::Generators::ThemeGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/spree/storefront/theme/theme_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_pathsObject



9
10
11
12
13
14
# File 'lib/generators/spree/storefront/theme/theme_generator.rb', line 9

def self.source_paths
  [
    File.expand_path('templates', __dir__),
    File.expand_path('../../../../../app/views', __dir__)
  ]
end

Instance Method Details

#copy_themeObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/generators/spree/storefront/theme/theme_generator.rb', line 16

def copy_theme
  empty_directory "app/models/spree/themes"
  template "model.rb.tt", "app/models/spree/themes/#{file_name}.rb"

  empty_directory "app/views/themes"

  directory "themes/default", "app/views/themes/#{file_name}"

  append_to_file "config/initializers/spree.rb", after: "Rails.application.config.after_initialize do\n" do
    "  Rails.application.config.spree.themes << Spree::Themes::#{class_name}\n"
  end
end