Sha256: 0cc48630f4115aee2fb2afa8ec5f536b9f0526511df7da24a9c5496755cb28e1
Contents?: true
Size: 1.76 KB
Versions: 4
Compression:
Stored size: 1.76 KB
Contents
require 'rubygems' require 'rubigen' require 'active_support' 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','isolation',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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
taza-0.9.1.2 | generators/page/page_generator.rb |
taza-0.9.1.1 | generators/page/page_generator.rb |
taza-0.9.1 | generators/page/page_generator.rb |
taza-0.9.0 | generators/page/page_generator.rb |