lib/rprogram/program.rb in rprogram-0.1.5 vs lib/rprogram/program.rb in rprogram-0.1.6

- old
+ new

@@ -2,12 +2,10 @@ require 'rprogram/compat' require 'rprogram/task' require 'rprogram/nameable' require 'rprogram/exceptions/program_not_found' -require 'open3' - module RProgram class Program include Nameable @@ -37,60 +35,61 @@ block.call(self) if block end # # Creates a new program object with the specified _path_, if _path_ - # is a valid file. Any given _args_ or a given _block_ will be used + # is a valid file. Any given _arguments_ or a given _block_ will be used # in creating the new program. # # Program.find_with_path('/bin/cd') # => Program # # Program.find_with_path('/obviously/fake') # => nil # - def self.find_with_path(path,*args,&block) - return self.new(path,*args,&block) if File.file?(path) + def self.find_with_path(path,*arguments,&block) + return self.new(path,*arguments,&block) if File.file?(path) end # # Creates a new program object with the specified _paths_, - # if a path within _paths_ is a valid file. Any given _args_ or + # if a path within _paths_ is a valid file. Any given _arguments_ or # a given _block_ will be used in creating the new program. # # Program.find_with_paths(['/bin/cd','/usr/bin/cd']) # => Program # # Program.find_with_paths(['/obviously/fake','/bla']) # => nil # - def self.find_with_paths(paths,*args,&block) + def self.find_with_paths(paths,*arguments,&block) paths.each do |path| - return self.new(path,*args,&block) if File.file?(path) + return self.new(path,*arguments,&block) if File.file?(path) end end # # Finds and creates the program using it's +program_names+ and returns # a new Program object. If the program cannot be found by any of it's # +program_names+, a ProramNotFound exception will be raised. Any given - # _args_ or a given _block_ will be used in creating the new program. + # _arguments_ or a given _block_ will be used in creating the new program. # # Program.find # => Program # # MyProgram.find('stuff','here') do |prog| # ... # end # - def self.find(*args,&block) - path = Compat.find_program_by_names(program_names) + def self.find(*arguments,&block) + path = Compat.find_program_by_names(*self.program_names) + unless path - names = program_names.map { |name| name.dump }.join(', ') + names = self.program_names.map { |name| name.dump }.join(', ') raise(ProgramNotFound,"programs #{names} were not found",caller) end - return self.new(path,*args,&block) + return self.new(path,*arguments,&block) end # - # Runs the program with the specified _args_ and returns + # Runs the program with the specified _arguments_ and returns # either +true+ or +false+, depending on the exit status of the # program. # # echo = Program.find_by_name('echo') # echo.run('hello')