Browse files

Brought over the last options from Jeweler::Generator::Options.

  • Loading branch information...
1 parent dfcd7b6 commit 8584c5ee66d1bd663682cef4439ebb97103e540f @technicalpickles committed Mar 21, 2010
Showing with 6 additions and 150 deletions.
  1. +6 −1 lib/jeweler/generator.rb
  2. +0 −149 lib/jeweler/generator/options.rb
View
7 lib/jeweler/generator.rb
@@ -70,13 +70,18 @@ class Generator < Thor::Group
class_option :user_email, :type => :string,
:desc => "the user's email, ie that is credited in the Gem specification"
+ class_option :github_username, :type => :string,
+ :desc => "name of the user on GitHub to set the project up under"
+ class_option :github_token, :type => :string,
+ :desc => "GitHub token to use for interacting with the GitHub API"
class_option :git_remote, :type => :string,
:desc => 'URI to use for git origin remote'
class_option :create_repo, :type => :boolean, :default => false,
:desc => 'create a repository on GitHub'
def initialize(args = [], opts = {}, config = {})
# next section yanked from Thor::Base, because apparently Thor::Group will pass in opts as an array
+ # This is mostly a workaround so we can use `git config` as a default for some values
parse_options = self.class.class_options
array_options = hash_opts = nil
if opts.is_a?(Array)
@@ -97,8 +102,8 @@ def initialize(args = [], opts = {}, config = {})
super
self.destination_root = Pathname.new(directory).expand_path
-
self.project_name = Pathname.new(self.destination_root).basename.to_s
+
self.summary = options[:summary]
self.description = options[:description]
self.user_name = options[:user_name]
View
149 lib/jeweler/generator/options.rb
@@ -1,149 +0,0 @@
-
-class Jeweler
- class Generator
- class Options < Hash
- attr_reader :opts, :orig_args
-
- def initialize(args)
- super()
-
- @orig_args = args.clone
- self[:testing_framework] = :shoulda
- self[:documentation_framework] = :rdoc
-
- git_config = Git.global_config
- self[:user_name] = git_config['user.name']
- self[:user_email] = git_config['user.email']
- self[:github_username] = git_config['github.user']
- self[:github_token] = git_config['github.token']
-
- require 'optparse'
- @opts = OptionParser.new do |o|
- o.banner = "Usage: #{File.basename($0)} [options] reponame\ne.g. #{File.basename($0)} the-perfect-gem"
-
- o.on('--directory [DIRECTORY]', 'specify the directory to generate into') do |directory|
- self[:directory] = directory
- end
-
- o.separator ""
-
- o.on('--testing-framework [FRAMEWORK]', 'specify the testing framework to generate') do |framework|
- self[:testing_framework] = framework.to_sym
- end
-
- o.on('--rspec', 'generate rspec code examples') do
- self[:testing_framework] = :rspec
- end
-
- o.on('--shoulda', 'generate shoulda tests') do
- self[:testing_framework] = :shoulda
- end
-
- o.on('--testunit', 'generate test/unit tests') do
- self[:testing_framework] = :testunit
- end
-
- o.on('--bacon', 'generate bacon specifications') do
- self[:testing_framework] = :bacon
- end
-
- o.on('--testspec', 'generate test/spec tests') do
- self[:testing_framework] = :testspec
- end
-
- o.on('--minitest', 'generate minitest tests') do
- self[:testing_framework] = :minitest
- end
-
- o.on('--micronaut', 'generate micronaut examples') do
- self[:testing_framework] = :micronaut
- end
-
- o.on('--riot', 'generate riot tests') do
- self[:testing_framework] = :riot
- end
-
- o.on('--shindo', 'generate shindo tests') do
- self[:testing_framework] = :shindo
- end
-
- o.separator ""
-
- o.on('--cucumber', 'generate cucumber stories in addition to the other tests') do
- self[:cucumber] = true
- end
-
- o.separator ""
-
- o.on('--reek', 'generate rake task for reek') do
- self[:use_reek] = true
- end
-
- o.on('--roodi', 'generate rake task for roodi') do
- self[:use_roodi] = true
- end
-
- o.separator ""
-
- o.on('--summary [SUMMARY]', 'specify the summary of the project') do |summary|
- self[:summary] = summary
- end
-
- o.on('--description [DESCRIPTION]', 'specify a description of the project') do |description|
- self[:description] = description
- end
-
- o.on('--github-username [GITHUB_USERNAME]', "name of the user on GitHub to set the project up under") do |github_username|
- self[:github_username] = github_username
- end
-
- o.on('--github-token [GITHUB_TOKEN]', "GitHub token to use for interacting with the GitHub API") do |github_token|
- self[:github_token] = github_token
- end
-
- o.on('--git-remote [GIT_REMOTE]', 'URI to set the git origin remote to') do |git_remote|
- self[:git_remote] = git_remote
- end
-
- o.on('--homepage [HOMEPAGE]', "the homepage for your project (defaults to the GitHub repo)") do |homepage|
- self[:homepage] = homepage
- end
-
- o.on('--create-repo', 'create the repository on GitHub') do
- self[:create_repo] = true
- end
-
-
- o.separator ""
-
- o.on('--yard', 'use yard for documentation') do
- self[:documentation_framework] = :yard
- end
-
- o.on('--rdoc', 'use rdoc for documentation') do
- self[:documentation_framework] = :rdoc
- end
-
- o.on_tail('-h', '--help', 'display this help and exit') do
- self[:show_help] = true
- end
- end
-
- begin
- @opts.parse!(args)
- rescue OptionParser::InvalidOption => e
- self[:invalid_argument] = e.message
- end
- end
-
- def merge(other)
- if other.respond_to?(:orig_args)
- self.class.new(@orig_args + other.orig_args)
- else
- super
- end
- end
-
- end
- end
-end

0 comments on commit 8584c5e

Please sign in to comment.