Class: Jeweler::Generator::Options

Inherits:
Hash
  • Object
show all
Defined in:
lib/bio-gem/mod/jeweler/options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Options

Returns a new instance of Options.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/bio-gem/mod/jeweler/options.rb', line 6

def initialize(args)
  super()

  @orig_args = args.clone
  self[:testing_framework]       = :shoulda
  self[:documentation_framework] = :rdoc
  self[:use_bundler]             = true
  self[:create_repo]             = self[:create_repo] || true

  git_config =  if Pathname.new("~/.gitconfig").expand_path.exist?
    Git.global_config
  else
    {}
  end
  self[:user_name]       = ENV['GIT_AUTHOR_NAME']  || ENV['GIT_COMMITTER_NAME']  || git_config['user.name']
  self[:user_email]      = ENV['GIT_AUTHOR_EMAIL'] || ENV['GIT_COMMITTER_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|
    self[:directory]='.'
    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.separator "These options are for BioGem"
    
    #TODO: Scrivere le altre opzioni
    
    #Note this option has the priority over all the other options.
    o.on("--meta", 'create a meta package, just the Rakefile, Gemfile, Licence, Readme. This options takes the precedence over every other option.') do
      self[:biogem_meta] = true
    end
    
    o.on("--with-bin", 'create the bin directory and an executable template script called bioreponame') do
      self[:biogem_bin] = true
    end

    o.on('--with-ffi', 'generate a C extension with foreign function interface (FFI)') do
      self[:biogem_ffi] = true
    end

    o.on('--with-db', 'create the database directory for a db application-library.') do
      self[:biogem_db] = true
    end

    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
      self[:biogem_test_data] = true
    end
    
    o.on('--with-engine [NAMESPACE]', 'create a Rails engine with the namespace given in input. Set default database creation') do |namespace|
      self[:biogem_engine] = namespace
      self[:biogem_db] = true
    end
    
    o.on('--with-wrapper', 'setup the biogem to be a wrapper around a command line application') do
      self[:wrapper] = true
    end
    
    o.separator ""
    
    o.separator "These options are for Jeweler"

    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('--[no-]bundler', 'use bundler for managing dependencies') do |v|
      self[:use_bundler] = v
    end

    o.on('--cucumber', 'generate cucumber stories in addition to the other tests') do
      self[:use_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.separator ""

    o.on('--user-name [USER_NAME]', "the user's name, ie that is credited in the LICENSE") do |user_name|
      self[:user_name] = user_name
    end

    o.on('--user-email [USER_EMAIL]', "the user's email, ie that is credited in the Gem specification") do |user_email|
      self[:user_email] = user_email
    end

    o.separator ""

    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('--no-create-repo', 'don\'t create the repository on GitHub') do
      self[:create_repo] = false
    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)
    self[:project_name] = args.shift
  rescue OptionParser::InvalidOption => e
    self[:invalid_argument] = e.message
  end
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



4
5
6
# File 'lib/bio-gem/mod/jeweler/options.rb', line 4

def opts
  @opts
end

#orig_argsObject (readonly)

Returns the value of attribute orig_args.



4
5
6
# File 'lib/bio-gem/mod/jeweler/options.rb', line 4

def orig_args
  @orig_args
end

Instance Method Details

#merge(other) ⇒ Object



196
197
198
# File 'lib/bio-gem/mod/jeweler/options.rb', line 196

def merge(other)
  self.class.new(@orig_args + other.orig_args)
end