Top Level Namespace
Defined Under Namespace
Modules: Os, Recipe, Specs
Constant Summary
collapse
- SPECS_VERSION_STRING =
"specs #{Specs::VERSION}"
- SPECS_HOME_PAGE =
'https://github.com/mcandre/specs#readme'
- SPECS_DIR =
Pathname.new(File.dirname(__FILE__))
- BUILTINS =
%w(specs os arch ruby)
- SEP =
File::SEPARATOR
- RECIPE_DIR =
[SPECS_DIR, 'aspects'].join(SEP)
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.check_ruby_version ⇒ Object
260
261
262
263
264
265
266
|
# File 'lib/specs.rb', line 260
def self.check_ruby_version
if Recipe.ruby1_8?
puts 'Requires Ruby 1.9 or higher.'
puts 'http://www.ruby-lang.org/'
exit
end
end
|
.command(aspect) ⇒ Object
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
# File 'lib/specs.rb', line 212
def self.command(aspect)
method = aspect.gsub('-', '_').to_sym
if aspect.include?(':')
package_manager, package = aspect.split(':')
package_manager = package_manager.to_sym
if Recipe::Package.methods.include?(package_manager)
Recipe::Package.send(package_manager, package)
end
elsif Recipe.methods.include?(method)
Recipe.send(method)
else
"#{aspect} --version"
end
end
|
.run(cmd, aspect) ⇒ Object
Print a command line instruction and its output, Emulating a user manually entering the instruction.
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
# File 'lib/specs.rb', line 238
def self.run(cmd, aspect)
puts ''
if !cmd
puts "#{aspect} aspect not implemented for this system"
elsif cmd == SPECS_VERSION_STRING
puts 'specs --version'
puts SPECS_VERSION_STRING
else
puts cmd
output = `#{cmd} 2>&1`
if output.include?(Recipe.command_not_found)
puts "#{cmd.split.first} not found"
else
puts output
end
end
end
|
Instance Method Details
#main ⇒ Object
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
# File 'lib/specs.rb', line 274
def main
check_ruby_version
usage
aspects = %w(os)
aspects = ARGV unless ARGV.empty?
aspects -= ['specs', '-v', 'version', '-version', '--version']
aspects.each do |aspect|
cmds = command(aspect)
if !cmds || cmds.instance_of?(String)
run(cmds, aspect)
elsif cmds.instance_of?(Array)
cmds.each { |cmd| run(cmd, aspect) }
end
end
end
|