lib/rprogram/program.rb in rprogram-0.1.8 vs lib/rprogram/program.rb in rprogram-0.2.0
- old
+ new
@@ -63,11 +63,11 @@
# @yieldparam [Program] prog
# The newly created program object.
#
# @return [Program, nil]
# Returns the newly created Program object. If the given path was
- # not a valid file, +nil+ will be returned.
+ # not a valid file, `nil` will be returned.
#
# @example
# Program.find_with_path('/bin/cd')
# # => Program
#
@@ -97,11 +97,11 @@
# @yieldparam [Program] prog
# The newly created program object.
#
# @return [Program, nil]
# Returns the newly created Program object. If none of the given
- # paths were valid files, +nil+ will be returned.
+ # paths were valid files, `nil` will be returned.
#
# @example
# Program.find_with_paths(['/bin/cd','/usr/bin/cd'])
# # => Program
#
@@ -114,11 +114,11 @@
return self.new(path,*arguments,&block) if File.file?(path)
end
end
#
- # Finds and creates the program using it's +program_names+.
+ # Finds and creates the program using it's `program_names`.
#
# @param [Array] arguments
# Additional arguments to initialize the program object with.
#
# @yield [prog]
@@ -130,11 +130,11 @@
#
# @return [Program]
# The newly created program object.
#
# @raise [ProgramNotFound]
- # Non of the +program_names+ represented valid programs on the system.
+ # Non of the `program_names` represented valid programs on the system.
#
# @example
# Program.find
# # => Program
#
@@ -142,11 +142,12 @@
# MyProgram.find('stuff','here') do |prog|
# # ...
# end
#
def self.find(*arguments,&block)
- path = Compat.find_program_by_names(*self.program_names)
+ path = self.path
+ path ||= Compat.find_program_by_names(*self.program_names)
unless path
names = self.program_names.map { |name| name.dump }.join(', ')
raise(ProgramNotFound,"programs #{names} were not found",caller)
@@ -184,10 +185,10 @@
#
# @return [Boolean]
# Specifies whether the program exited successfully.
#
# @raise [ProgramNotFound]
- # Indicates that the +sudo+ program could not be located.
+ # Indicates that the `sudo` program could not be located.
#
# @since 0.1.8
#
def sudo(*args)
Compat.sudo(@path,*args)