Class: KisoThemes::Generators::CustomizeGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_gemObject



34
35
36
# File 'lib/generators/kiso_themes/customize_generator.rb', line 34

def add_gem

end

#copy_stylesheetObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/generators/kiso_themes/customize_generator.rb', line 16

def copy_stylesheet
  unless File.directory?(File.expand_path("../../../../lib/generators/kiso_themes/templates/customizations/styles/#{options.theme_name}", __FILE__))
    raise Thor::Error, "You asked to customize theme '#{options.theme_name}', but it doesn't exist."
    return
  end

  unless File.exists?(File.expand_path("../../../../lib/generators/kiso_themes/templates/customizations/styles/#{options.theme_name}/#{options.style_name}.css.scss", __FILE__))
    raise Thor::Error, "You asked to customize theme #{options.theme_name}'s '#{options.style_name}.css.scss', but it doesn't exist."
    return
  end

  copy_file "lib/generators/kiso_themes/templates/customizations/styles/#{options.theme_name}/#{options.style_name}.css.scss", "app/assets/stylesheets/kiso_themes.css.scss"
  copy_file "lib/sass/kiso_themes/#{options.theme_name}/styles/_#{options.style_name}_variables.scss", "app/assets/stylesheets/_#{options.style_name}_variables.scss"
  copy_file "app/assets/javascripts/kiso_themes.js", "app/assets/javascripts/kiso_themes.js"

  PageRewriter.compile("app/assets/stylesheets/kiso_themes.css.scss", /kiso_themes\/#{options.theme_name}\/styles\//, '')
end

#run_bundleObject



38
39
40
41
42
# File 'lib/generators/kiso_themes/customize_generator.rb', line 38

def run_bundle
  command = "install"
  say_status :run, "bundle #{command}"
  print `"#{Gem.ruby}" "#{Gem.bin_path('bundler', 'bundle')}" #{command}`
end

#show_readmeObject



44
45
46
# File 'lib/generators/kiso_themes/customize_generator.rb', line 44

def show_readme
  readme "lib/generators/kiso_themes/templates/README_CUSTOMIZE" if behavior == :invoke
end