class Themeable::Command

Public Instance Methods

app_name() click to toggle source
# File lib/themeable/command.rb, line 75
def app_name
  @app_name
end
help(*args) click to toggle source
Calls superclass method
# File lib/themeable/command.rb, line 10
def help(*args)
  super(*args)
end
new(name) click to toggle source
# File lib/themeable/command.rb, line 15
    def new(name)
      @theme_name = name
      @app_name = "theme_#{name}"
      say('Initializing theme project...', :green)
      # say("\"rails plugin new #{app_name} -T\"")
      system "rails plugin new #{app_name} -T -B"

      @destination_stack ||= []
      @destination_stack[0] = File.expand_path(app_name)

      gsub_file "#{app_name}.gemspec", /TODO[: ]*/, ''
      gsub_file "#{app_name}.gemspec", %r{^ *s\.files *=.*} do
        '  s.files = Dir["{lib,theme}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]'
      end

      insert_into_file "#{app_name}.gemspec", after: %r{^ *s\.add_dependency .*} do
        "\n  s.add_dependency 'themeable'"
      end

      # generators
      template 'generators/copy_views_generator.rb', "lib/generators/theme_#{theme_name}/copy_views_generator.rb"
      template 'generators/copy_assets_generator.rb', "lib/generators/theme_#{theme_name}/copy_assets_generator.rb"

      # rakes
      template 'resolve_css_path.rake', "lib/tasks/resolve_css_path.rake"
      append_to_file 'Rakefile' do
        <<-CODE
require '#{app_name}'
Dir.glob('lib/tasks/*.rake').each { |r| load r}
        CODE
      end
    
      # assets and views
      create_file "theme/assets/#{theme_name}/application.css"
      create_file "theme/assets/#{theme_name}/application.js"
      create_file "theme/views/layouts/.gitkeep"
      template "view_application.html.erb", "theme/views/layouts/application.html.erb"

      # scaffold templates
      %w(default admin).each do |name|
        create_file "theme/scaffold_templates/#{theme_name}/#{name}/index.html.erb"
        create_file "theme/scaffold_templates/#{theme_name}/#{name}/edit.html.erb"
        create_file "theme/scaffold_templates/#{theme_name}/#{name}/show.html.erb"
        create_file "theme/scaffold_templates/#{theme_name}/#{name}/new.html.erb"
        create_file "theme/scaffold_templates/#{theme_name}/#{name}/_form.html.erb"
      end

      # vender files
      create_file "vendor/#{theme_name}/.gitkeep"

      # libs
      remove_file "lib/#{app_name}.rb"
      template 'theme_main.rb', "lib/#{app_name}.rb"

      puts
      say("Done. Please check your new theme project in directory #{app_name}", :green)
      puts
    end
set_destination_root(name) click to toggle source
# File lib/themeable/command.rb, line 81
def set_destination_root(name)
  destination_root = name
end
theme_name() click to toggle source
# File lib/themeable/command.rb, line 78
def theme_name
  @theme_name
end