app_generators/newgem/newgem_generator.rb in newgem-0.29.0 vs app_generators/newgem/newgem_generator.rb in newgem-1.0.0

- old
+ new

@@ -29,11 +29,11 @@ def initialize(runtime_args, runtime_options = {}) super usage if args.empty? @destination_root = File.expand_path(args.shift) @gem_name = base_name - @module_name = gem_name.camelize + @module_name = gem_name.gsub('-','_').camelize @project_name = @gem_name extract_options end def manifest @@ -48,22 +48,14 @@ m.directory "lib/#{gem_name}" # Root m.template_copy_each %w( History.txt Rakefile README.rdoc PostInstall.txt ) - m.file_copy_each %w( setup.rb ) # Default module for app m.template "lib/module.rb", "lib/#{gem_name}.rb" - m.template "lib/version.rb", "lib/#{gem_name}/version.rb" - # Config - m.template_copy_each %w( hoe.rb requirements.rb ), "config" - - # Tasks - m.file_copy_each %w( deployment.rake environment.rake website.rake ), "tasks" - # Selecting a test framework case test_framework when "test_unit" m.dependency "install_test_unit", [gem_name], :destination => destination_root, :collision => :force when "rspec" @@ -72,18 +64,22 @@ # Website m.dependency "install_website", [gem_name], :author => author, :email => email, :destination => destination_root, :collision => :force unless disable_website - # JRuby - m.dependency "install_jruby", [gem_name], :destination => destination_root, :collision => :force if is_jruby + # JRuby + m.dependency "install_jruby", [gem_name], :destination => destination_root, :collision => :force if is_jruby # Executables for bin_name in bin_names_list m.dependency "executable", [bin_name], :destination => destination_root, :collision => :force end - + + for generator in @install_generators + m.dependency "install_#{generator}", [], :destination => destination_root, :collision => :force + end + m.dependency "install_rubigen_scripts", [destination_root, "rubygems", "newgem", "newgem_theme"], :shebang => options[:shebang], :collision => :force %w( console ).each do |file| m.template "script/#{file}.erb", "script/#{file}", script_options m.template "script/win_script.cmd", "script/#{file}.cmd", @@ -113,14 +109,19 @@ "Sets up executable scripts in the bin folder.", "Default: none") { |x| options[:bin_name] = x } opts.on("-e", "--email=PATH", String, "Your email to be inserted into generated files.", "Default: ~/.rubyforge/user-config.yml[email]") { |x| options[:email] = x } - # TODO --import_path - # opts.on("-i", "--import_path=PATH", String, - # "Path where your files could be copied from.", - # "Default: none") { |x| options[:import_path] = x } + opts.on("-i", "--install=generator", String, + "Installs a generator called install_<generator>.", + "For example, '-i cucumber' runs the install_cucumber generator.", + "Can be used multiple times for different generators.", + "Cannot be used for generators that require argumnts.", + "Default: none") do |generator| + options[:install] ||= [] + options[:install] << generator + end opts.on("-j", "--jruby", "Use if gem is for jruby.") { |x| options[:jruby] = x } opts.on("-a", "--author=PATH", String, "Your name to be inserted into generated files.", "Default: ~/.rubyforge/user-config.yml[user_name]") { |x| options[:author] = x } @@ -152,21 +153,20 @@ require 'newgem/rubyforge' rubyforge_config = Newgem::Rubyforge.new @author ||= rubyforge_config.full_name @email ||= rubyforge_config.email end - @bin_names_list = (options[:bin_name] || "").split(',') - @disable_website = options[:disable_website] - - @test_framework = options[:test_framework] || "test_unit" - @is_jruby = options[:jruby] - @project_name = options[:project] if options.include?(:project) + @bin_names_list = (options[:bin_name] || "").split(',') + @disable_website = options[:disable_website] + @test_framework = options[:test_framework] || "test_unit" + @is_jruby = options[:jruby] + @project_name = options[:project] if options.include?(:project) + @install_generators = options[:install] || [] end # Installation skeleton. Intermediate directories are automatically # created so don't sweat their absence here. BASEDIRS = %w( - config doc lib script tasks )