Sha256: 07a9cb1a69fec867b0f7cd0d9a1ed182c8ecf4e8152e57c98823e35b7e2bdec2

Contents?: true

Size: 1.76 KB

Versions: 7

Compression:

Stored size: 1.76 KB

Contents

require 'rubygems'
require 'rubigen'
require 'activesupport'

class PageGenerator < RubiGen::Base
  default_options :author => nil
  attr_reader :site_name,:name

  def initialize(runtime_args, runtime_options = {})
    super
    usage if args.size != 2
    @name = args.shift
    @site_name=args.shift
    check_if_site_exists
    extract_options
  end

  def check_if_site_exists
    unless File.directory?(File.join(destination_root,'lib','sites',site_name.underscore))
      $stderr.puts "******No such site #{site_name} exists.******"
      usage
    end
  end

  def manifest
    record do |m|
      m.template "page.rb.erb", File.join('lib','sites', site_name.underscore, "pages",  "#{name.underscore}_page.rb")
      m.template "functional_page_spec.rb.erb", File.join('spec','functional',site_name.underscore,"#{name.underscore}_page_spec.rb")
    end
  end

  protected
  def banner
    <<-EOS
    Creates a taza page for a given taza site, site you are making a page for must exist first.

    USAGE: #{$0} #{spec.name} page_name site_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,
    #         "Some comment about this option",
    #         "Default: none") { |options[:author]| }
    # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
  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]
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
scudco-taza-0.8.1 generators/page/page_generator.rb
scudco-taza-0.8.3 generators/page/page_generator.rb
scudco-taza-0.8.4 generators/page/page_generator.rb
taza-0.8.4 generators/page/page_generator.rb
taza-0.8.0 generators/page/page_generator.rb
taza-0.8.3 generators/page/page_generator.rb
taza-0.8.2 generators/page/page_generator.rb