class Jeweler::Generator::Options

Attributes

opts[R]
orig_args[R]

Public Class Methods

new(args) click to toggle source
Calls superclass method
    # File lib/bio-gem/mod/jeweler/options.rb
  6 def initialize(args)
  7   super()
  8 
  9   @orig_args = args.clone
 10   self[:testing_framework]       = :shoulda
 11   self[:documentation_framework] = :rdoc
 12   self[:use_bundler]             = true
 13   self[:create_repo]             = self[:create_repo] || true
 14 
 15   git_config =  if Pathname.new("~/.gitconfig").expand_path.exist?
 16     Git.global_config
 17   else
 18     {}
 19   end
 20   self[:user_name]       = ENV['GIT_AUTHOR_NAME']  || ENV['GIT_COMMITTER_NAME']  || git_config['user.name']
 21   self[:user_email]      = ENV['GIT_AUTHOR_EMAIL'] || ENV['GIT_COMMITTER_EMAIL'] || git_config['user.email']
 22   self[:github_username] = git_config['github.user']
 23   self[:github_token]    = git_config['github.token']
 24 
 25   require 'optparse'
 26   @opts = OptionParser.new do |o|
 27     self[:directory]='.'
 28     o.banner = "Usage: #{File.basename($0)} [options] reponame\ne.g. #{File.basename($0)} the-perfect-gem"
 29 
 30     o.on('--directory [DIRECTORY]', 'specify the directory to generate into') do |directory|
 31       self[:directory] = directory
 32     end
 33     
 34     o.separator ""
 35     
 36     o.separator "These options are for BioGem"
 37     
 38     #TODO: Scrivere le altre opzioni
 39     
 40     #Note this option has the priority over all the other options.
 41     o.on("--meta", 'create a meta package, just the Rakefile, Gemfile, Licence, Readme. This options takes the precedence over every other option.') do
 42       self[:biogem_meta] = true
 43     end
 44     
 45     o.on("--with-bin", 'create the bin directory and an executable template script called bioreponame') do
 46       self[:biogem_bin] = true
 47     end
 48 
 49     o.on('--with-ffi', 'generate a C extension with foreign function interface (FFI)') do
 50       self[:biogem_ffi] = true
 51     end
 52 
 53     o.on('--with-db', 'create the database directory for a db application-library.') do
 54       self[:biogem_db] = true
 55     end
 56 
 57     o.on('--with-test-data','create the data directory inside the test directory if the user need to set up a test with its own dataset') do
 58       self[:biogem_test_data] = true
 59     end
 60     
 61     o.on('--with-engine [NAMESPACE]', 'create a Rails engine with the namespace given in input. Set default database creation') do |namespace|
 62       self[:biogem_engine] = namespace
 63       self[:biogem_db] = true
 64     end
 65     
 66     o.on('--with-wrapper', 'setup the biogem to be a wrapper around a command line application') do
 67       self[:wrapper] = true
 68     end
 69     
 70     o.separator ""
 71     
 72     o.separator "These options are for Jeweler"
 73 
 74     o.on('--rspec', 'generate rspec code examples') do
 75       self[:testing_framework] = :rspec
 76     end
 77 
 78     o.on('--shoulda', 'generate shoulda tests') do
 79       self[:testing_framework] = :shoulda
 80     end
 81 
 82     o.on('--testunit', 'generate test/unit tests') do
 83       self[:testing_framework] = :testunit
 84     end
 85 
 86     o.on('--bacon', 'generate bacon specifications') do
 87       self[:testing_framework] = :bacon
 88     end
 89 
 90     o.on('--testspec', 'generate test/spec tests') do
 91       self[:testing_framework] = :testspec
 92     end
 93 
 94     o.on('--minitest', 'generate minitest tests') do
 95       self[:testing_framework] = :minitest
 96     end
 97 
 98     o.on('--micronaut', 'generate micronaut examples') do
 99       self[:testing_framework] = :micronaut
100     end
101 
102     o.on('--riot', 'generate riot tests') do
103       self[:testing_framework] = :riot
104     end
105 
106     o.on('--shindo', 'generate shindo tests') do
107       self[:testing_framework] = :shindo
108     end
109 
110     o.separator ""
111 
112     o.on('--[no-]bundler', 'use bundler for managing dependencies') do |v|
113       self[:use_bundler] = v
114     end
115 
116     o.on('--cucumber', 'generate cucumber stories in addition to the other tests') do
117       self[:use_cucumber] = true
118     end
119 
120     o.separator ""
121 
122     o.on('--reek', 'generate rake task for reek') do
123       self[:use_reek] = true
124     end
125 
126     o.on('--roodi', 'generate rake task for roodi') do
127       self[:use_roodi] = true
128     end
129 
130     o.separator ""
131 
132     o.on('--summary [SUMMARY]', 'specify the summary of the project') do |summary|
133       self[:summary] = summary
134     end
135 
136     o.on('--description [DESCRIPTION]', 'specify a description of the project') do |description|
137       self[:description] = description
138     end
139 
140     o.separator ""
141 
142     o.on('--user-name [USER_NAME]', "the user's name, ie that is credited in the LICENSE") do |user_name|
143       self[:user_name] = user_name
144     end
145 
146     o.on('--user-email [USER_EMAIL]', "the user's email, ie that is credited in the Gem specification") do |user_email|
147       self[:user_email] = user_email
148     end
149 
150     o.separator ""
151 
152     o.on('--github-username [GITHUB_USERNAME]', "name of the user on GitHub to set the project up under") do |github_username|
153       self[:github_username] = github_username
154     end
155 
156     o.on('--github-token [GITHUB_TOKEN]', "GitHub token to use for interacting with the GitHub API") do |github_token|
157       self[:github_token] = github_token
158     end
159 
160     o.on('--git-remote [GIT_REMOTE]', 'URI to set the git origin remote to') do |git_remote|
161       self[:git_remote] = git_remote
162     end
163 
164     o.on('--homepage [HOMEPAGE]', "the homepage for your project (defaults to the GitHub repo)") do |homepage|
165       self[:homepage] = homepage
166     end
167 
168     o.on('--no-create-repo', 'don\'t create the repository on GitHub') do
169       self[:create_repo] = false
170     end
171 
172 
173     o.separator ""
174 
175     o.on('--yard', 'use yard for documentation') do
176       self[:documentation_framework] = :yard
177     end
178 
179     o.on('--rdoc', 'use rdoc for documentation') do
180       self[:documentation_framework] = :rdoc
181     end
182 
183     o.on_tail('-h', '--help', 'display this help and exit') do
184       self[:show_help] = true
185     end
186   end
187 
188   begin
189     @opts.parse!(args)
190     self[:project_name] = args.shift
191   rescue OptionParser::InvalidOption => e
192     self[:invalid_argument] = e.message
193   end
194 end

Public Instance Methods

merge(other) click to toggle source
    # File lib/bio-gem/mod/jeweler/options.rb
196 def merge(other)
197   self.class.new(@orig_args + other.orig_args)
198 end