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
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
|
# File 'lib/appraisal/cli.rb', line 125
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 == "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)
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
98
99
100
|
# File 'lib/appraisal/cli.rb', line 98
def clean
FileUtils.rm_f(Dir["gemfiles/*.{gemfile,gemfile.lock}"])
end
|
#generate ⇒ Object
91
92
93
94
95
|
# File 'lib/appraisal/cli.rb', line 91
def generate
AppraisalFile.each do |appraisal|
appraisal.write_gemfile
end
end
|
#install ⇒ Object
80
81
82
83
84
85
86
87
88
|
# File 'lib/appraisal/cli.rb', line 80
def install
invoke(:generate, [], {})
install_options = options.to_h
AppraisalFile.each do |appraisal|
appraisal.install(install_options)
appraisal.relativize
end
end
|
#list ⇒ Object
114
115
116
|
# File 'lib/appraisal/cli.rb', line 114
def list
AppraisalFile.new.appraisals.each { |appraisal| puts appraisal.name }
end
|
#update(*gems) ⇒ Object
103
104
105
106
107
108
109
110
111
|
# File 'lib/appraisal/cli.rb', line 103
def update(*gems)
invoke(:generate, [], {})
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
119
120
121
|
# File 'lib/appraisal/cli.rb', line 119
def version
puts "Appraisal2 #{VERSION}"
end
|