lib/generators/pig/pig_generator.rb in pig-0.0.4 vs lib/generators/pig/pig_generator.rb in pig-0.0.5
- old
+ new
@@ -1,13 +1,34 @@
require 'rails/generators'
class PigGenerator < Rails::Generators::Base
+ class_option :revision_path,
+ :banner => '/path_to_revisions',
+ :default => '/revision',
+ :desc => 'A root-relative path at which to display revision information.'
+
+ class_option :skip_routes,
+ :type => :boolean,
+ :default => false,
+ :desc => 'Do not generate routes.'
+
def install_pig
- route("match '/revision', :to => Pig.new")
+ if options[:skip_routes]
+ puts 'Nothing to do'
+ else
+ route("match '#{formatted_revision_path}', :to => Pig.new")
+ end
end
def self.source_root
File.join(File.dirname(__FILE__), 'templates')
+ end
+
+ protected
+
+ def formatted_revision_path
+ path = options[:revision_path]
+ path.starts_with?('/') ? path : '/#{path}'
end
end