lib/repertoire/compat.rb in repertoire-0.2.2 vs lib/repertoire/compat.rb in repertoire-0.2.3

- old
+ new

@@ -2,23 +2,25 @@ require 'repertoire/exceptions/command_failed' module Repertoire module Compat # - # Returns the native _platform_. + # @return [String] + # The native platform. # + # @example # Compat.arch #=> "linux" # def self.platform RUBY_PLATFORM.split('-').last end # - # Returns an array representing the +PATH+ environment variable. - # If the +PATH+ environment variable is not setup, an empty array will - # be returned. + # @return [Array] + # +PATH+ environment variable. # + # @example # Compat.paths # #=> ["/bin", "/usr/bin"] # def self.paths # return an empty array in case @@ -31,15 +33,20 @@ return ENV['PATH'].split(':') end end # - # Finds the program matching _name_ and returns it's full path. - # If the program was not found, +nil+ will be returned. + # Finds the program matching name. # - # Compat.find_program('as') #=> "/usr/bin/as" + # @return [String, nil] + # The full path of the program, or +nil+ if the program could not be + # found. # + # @example + # Compat.find_program('as') + # #=> "/usr/bin/as" + # def self.find_program(name) self.paths.each do |dir| full_path = File.expand_path(File.join(dir,name)) return full_path if File.file?(full_path) @@ -47,13 +54,24 @@ return nil end # - # Runs the command specified by _program_ and the given _args_. - # If _program_ cannot be found on the system, a ProgramNotFound - # exception will be raised. + # Runs the command. # + # @param [String] program + # The name of the program to run. + # + # @param [Array] args + # Optional arguments to run the program with. + # + # @raise [ProgramNotFound] + # The specified _program_ could not be found. + # + # @raise [CommandFailed] + # The command failed to run. + # + # @example # Compat.sh('ls','-la','/') # def Compat.sh(program,*args) program = program.to_s