Sha256: 195775a50ba0dae9644a7ce3c8cc090167882f2bf92ee8335cf1b6aab1680ca0

Contents?: true

Size: 1.63 KB

Versions: 24

Compression:

Stored size: 1.63 KB

Contents

class PlainThemeGenerator < RubiGen::Base
  
  default_options :author  => "TODO",
                  :email   => "todo@todo.com"
  
  attr_reader :author, :email
  
  def initialize(runtime_args, runtime_options = {})
    super
    extract_options
  end

  def manifest
    record do |m|
      # Ensure appropriate folder(s) exists
      m.directory 'website/javascripts'
      m.directory 'website/stylesheets'

      # Website
      m.template "website/template.html.erb", "website/template.html.erb"
      m.file_copy_each     %w( stylesheets/screen.css javascripts/rounded_corners_lite.inc.js ), "website"
    end
  end

  protected
    def banner
      <<-EOS
Installs the plain blue-ish website theme for newgem's website framework.

USAGE: #{$0} #{spec.name}"
EOS
    end

    def add_options!(opts)
      opts.separator ''
      opts.separator 'Options:'
      # For each option below, place the default
      # at the top of the file next to "default_options"
      opts.on("-a", "--author=\"Your Name\"", String,
              "You. The author of this RubyGem. You name goes in in the website.",
              "Default: 'TODO'") { |options[:author]| }
      opts.on("-e", "--email=your@email.com", String,
              "Your email for people to contact you.",
              "Default: nil") { |options[:author]| }
    end
    
    def extract_options
      # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
      # Templates can access these value via the attr_reader-generated methods, but not the
      # raw instance variable value.
      @author = options[:author]
      @email  = options[:email]
    end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
newjs-1.7.4 newjs_theme_generators/plain_theme/plain_theme_generator.rb
newjs-1.0.1 newjs_theme_generators/plain_theme/plain_theme_generator.rb
newjs-1.0.2 newjs_theme_generators/plain_theme/plain_theme_generator.rb
newjs-1.0.3 newjs_theme_generators/plain_theme/plain_theme_generator.rb
newjs-1.0.0 newjs_theme_generators/plain_theme/plain_theme_generator.rb
newjs-1.1.0 newjs_theme_generators/plain_theme/plain_theme_generator.rb
newjs-1.2.0 newjs_theme_generators/plain_theme/plain_theme_generator.rb
newjs-1.2.1 newjs_theme_generators/plain_theme/plain_theme_generator.rb
newjs-1.3.0 newjs_theme_generators/plain_theme/plain_theme_generator.rb
newjs-1.0.4 newjs_theme_generators/plain_theme/plain_theme_generator.rb
newjs-1.3.2 newjs_theme_generators/plain_theme/plain_theme_generator.rb
newjs-1.3.3 newjs_theme_generators/plain_theme/plain_theme_generator.rb
newjs-1.3.4 newjs_theme_generators/plain_theme/plain_theme_generator.rb
newjs-1.3.5 newjs_theme_generators/plain_theme/plain_theme_generator.rb
newjs-1.3.6 newjs_theme_generators/plain_theme/plain_theme_generator.rb
newjs-1.3.1 newjs_theme_generators/plain_theme/plain_theme_generator.rb
newjs-1.3.7 newjs_theme_generators/plain_theme/plain_theme_generator.rb
newjs-1.4.1 newjs_theme_generators/plain_theme/plain_theme_generator.rb
newjs-1.5.0 newjs_theme_generators/plain_theme/plain_theme_generator.rb
newjs-1.5.1 newjs_theme_generators/plain_theme/plain_theme_generator.rb