Class: Appraisal::CLI
- Inherits:
-
Thor
- Object
- Thor
- Appraisal::CLI
show all
- Defined in:
- lib/appraisal/cli.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
# File 'lib/appraisal/cli.rb', line 155
def method_missing(name, *args)
matching_appraisal = AppraisalFile.new.appraisals.detect do |appraisal|
appraisal.name == name.to_s
end
if matching_appraisal
actual_args = (args.empty? && ARGV.any?) ? ARGV.dup : args
if actual_args.first == "generate"
matching_appraisal.write_gemfile
elsif actual_args.first == "install"
filtered_args = actual_args[1..-1] || []
parsed_options = parse_external_options(filtered_args)
gem_manager = options["gem-manager"] || options[:gem_manager]
parsed_options[:gem_manager] = gem_manager if gem_manager && !parsed_options.key?(:gem_manager)
matching_appraisal.install(parsed_options)
matching_appraisal.relativize
elsif actual_args.first == "generate-install"
filtered_args = actual_args[1..-1] || []
parsed_options = parse_external_options(filtered_args)
gem_manager = options["gem-manager"] || options[:gem_manager]
parsed_options[:gem_manager] = gem_manager if gem_manager && !parsed_options.key?(:gem_manager)
matching_appraisal.write_gemfile
matching_appraisal.install(parsed_options)
matching_appraisal.relativize
elsif actual_args.first == "update"
filtered_args = actual_args[1..-1] || []
gems, parsed_options = extract_gems_and_options(filtered_args)
gem_manager = options["gem-manager"] || options[:gem_manager]
parsed_options[:gem_manager] = gem_manager if gem_manager && !parsed_options.key?(:gem_manager)
matching_appraisal.update(gems, parsed_options)
elsif actual_args.first == "generate-update"
filtered_args = actual_args[1..-1] || []
gems, parsed_options = extract_gems_and_options(filtered_args)
gem_manager = options["gem-manager"] || options[:gem_manager]
parsed_options[:gem_manager] = gem_manager if gem_manager && !parsed_options.key?(:gem_manager)
matching_appraisal.write_gemfile
matching_appraisal.update(gems, parsed_options)
else
Command.new(actual_args, :gemfile => matching_appraisal.gemfile_path).run
end
else
AppraisalFile.each do |appraisal|
Command.new(ARGV, :gemfile => appraisal.gemfile_path).run
end
end
end
|
Class Method Details
.exit_on_failure? ⇒ Boolean
44
45
46
|
# File 'lib/appraisal/cli.rb', line 44
def exit_on_failure?
true
end
|
.help(shell, subcommand = false) ⇒ Object
Override help command to print out usage
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/appraisal/cli.rb', line 19
def help(shell, subcommand = false)
shell.say(strip_heredoc(<<-HELP))
Appraisal: Find out what your Ruby gems are worth.
Usage:
appraisal [APPRAISAL_NAME] EXTERNAL_COMMAND
If APPRAISAL_NAME is given, only run that EXTERNAL_COMMAND against the given
appraisal, otherwise it runs the EXTERNAL_COMMAND against all appraisals.
HELP
if File.exist?("Appraisals")
shell.say
shell.say("Available Appraisal(s):")
AppraisalFile.each do |appraisal|
shell.say(" - #{appraisal.name}")
end
end
shell.say
super
end
|
Instance Method Details
#clean ⇒ Object
124
125
126
|
# File 'lib/appraisal/cli.rb', line 124
def clean
FileUtils.rm_f(Dir["gemfiles/*.{gemfile,gemfile.lock}"])
end
|
#generate ⇒ Object
117
118
119
120
121
|
# File 'lib/appraisal/cli.rb', line 117
def generate
AppraisalFile.each do |appraisal|
appraisal.write_gemfile
end
end
|
#generate_install ⇒ Object
111
112
113
114
|
# File 'lib/appraisal/cli.rb', line 111
def generate_install
invoke(:generate, [], {})
invoke(:install, [], options.to_h)
end
|
#generate_update(*gems) ⇒ Object
138
139
140
141
|
# File 'lib/appraisal/cli.rb', line 138
def generate_update(*gems)
invoke(:generate, [], {})
update(*gems)
end
|
#install ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/appraisal/cli.rb', line 80
def install
install_options = options.to_h
AppraisalFile.each do |appraisal|
appraisal.install(install_options)
appraisal.relativize
end
end
|
#list ⇒ Object
144
145
146
|
# File 'lib/appraisal/cli.rb', line 144
def list
AppraisalFile.new.appraisals.each { |appraisal| puts appraisal.name }
end
|
#update(*gems) ⇒ Object
129
130
131
132
133
134
135
|
# File 'lib/appraisal/cli.rb', line 129
def update(*gems)
gem_manager = options["gem-manager"] || options[:gem_manager]
update_options = gem_manager ? {:gem_manager => gem_manager} : {}
AppraisalFile.each do |appraisal|
appraisal.update(gems, update_options)
end
end
|
#version ⇒ Object
149
150
151
|
# File 'lib/appraisal/cli.rb', line 149
def version
puts "Appraisal2 #{VERSION}"
end
|