module Specs
Constants
- BUILTINS
- RECIPE_DIR
…/specs/aspects
- SEP
- SPECS_DIR
- VERSION
Public Class Methods
check_ruby_version()
click to toggle source
# File lib/specs.rb, line 251 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)
click to toggle source
# File lib/specs.rb, line 203 def self.command(aspect) # Ruby methods can't use hyphens (-), # So translate to underscores (_) # When looking up known aspects. method = aspect.gsub('-', '_').to_sym # Package? 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 # Known aspect? elsif Recipe.methods.include?(method) Recipe.send(method) # Unknown aspect. # Default to --version flag. else "#{aspect} --version" end end
main()
click to toggle source
# File lib/cli.rb, line 18 def self.main check_ruby_version begin options = Docopt::docopt(USAGE, version: Specs::VERSION) aspects = options['<aspect>'] # Work around https://github.com/docopt/docopt/issues/274 if aspects == [] aspects = ['os', 'hardware'] end # Print specs' own version, and filter out redundant requests aspects = ['specs'] + (aspects - ['specs']) aspects.each do |aspect| # What does the aspect module say to run # in order to retrieve the aspect information? cmds = command(aspect) if !cmds || cmds.instance_of?(String) run(cmds, aspect) # Module returns an array of command strings. elsif cmds.instance_of?(Array) cmds.each { |cmd| run(cmd, aspect) } end end rescue Docopt::Exit => e puts e.message end rescue Interrupt nil end
run(cmd, aspect)
click to toggle source
Print a command line instruction and its output, Emulating a user manually entering the instruction.
# File lib/specs.rb, line 229 def self.run(cmd, aspect) if !cmd puts "#{aspect} aspect not implemented for this system" elsif cmd == 'specs' puts 'specs --version' puts Specs::Version else puts cmd output = SystemWithAliases::execute(cmd) if output.include?(Recipe.command_not_found) puts "#{cmd.split.first} not found" else puts output end # Vertically separate multiple aspects puts '' end end