Sha256: 73eb96b79eb58ea2d0f457319e5e4a419cb2de86db5f393f1fe19048e59a3a14

Contents?: true

Size: 1.87 KB

Versions: 23

Compression:

Stored size: 1.87 KB

Contents

class LongBoxThemeGenerator < RubiGen::Base
  
  default_options :author  => "TODO",
                  :email   => "todo@todo.com"
  
  attr_reader :author, :email
  attr_reader :gem_name, :module_name
  
  def initialize(runtime_args, runtime_options = {})
    super
    @destination_root = File.expand_path(destination_root)
    @gem_name = base_name
    
    @module_name  = @gem_name.camelcase

    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.template_copy_each %w( index.txt ), "website"
      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'") { |x| options[:author] = x }
      opts.on("-e", "--email=your@email.com", String,
              "Your email for people to contact you.",
              "Default: nil") { |x| options[:author] = x }
    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

23 entries across 23 versions & 1 rubygems

Version Path
newgem-0.25.0 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb
newgem-0.23.0 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb
newgem-0.22.2 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb
newgem-0.22.1 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb
newgem-0.23.1 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb
newgem-0.24.0 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb
newgem-0.29.0 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb
newgem-0.27.0 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb
newgem-0.28.0 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb
newgem-1.0.0 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb
newgem-1.0.2 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb
newgem-1.0.1 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb
newgem-1.0.3 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb
newgem-1.0.4 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb
newgem-1.0.5 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb
newgem-1.0.6 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb
newgem-1.0.7 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb
newgem-1.1.0 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb
newgem-1.2.0 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb
newgem-1.2.1 newgem_theme_generators/long_box_theme/long_box_theme_generator.rb