rprogram 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,9 +1,21 @@
1
- == 0.1.4 / 2009-01-07
1
+ === 0.1.5 / 2009-01-14
2
+
3
+ * Use Kernel.system in RProgram::Program#run, instead of Open3.popen3:
4
+ * popen3 is not well supported on Windows.
5
+ * win32-open3 does not allow for the execution of single programs with
6
+ separate command-line arguments. Instead, it merely executes a command
7
+ string in command.com. This seems to allow arbitrary command injection
8
+ via command-line arguments.
9
+ * RProgram::Program#run will now return either +true+ or +false+,
10
+ depending on the exit status of the program.
11
+ * Added some missing documentation.
12
+
13
+ === 0.1.4 / 2009-01-07
2
14
 
3
15
  * Added <tt>lib/rprogram/rprogram.rb</tt> to the Manifest.
4
16
  * Added more documentation.
5
17
 
6
- == 0.1.3 / 2008-01-27
18
+ === 0.1.3 / 2008-01-27
7
19
 
8
20
  * Renamed <tt>Program.create_from_path</tt> to
9
21
  <tt>Program.find_with_path</tt>.
@@ -12,14 +24,14 @@
12
24
  * Renamed <tt>Program.create</tt> to <tt>Program.find</tt>.
13
25
  * Renamed <tt>Program.run_with_task</tt> to <tt>Program.run_task</tt>.
14
26
 
15
- == 0.1.2 / 2008-01-18
27
+ === 0.1.2 / 2008-01-18
16
28
 
17
29
  * DRY'ed up lib/rprogram/task.
18
30
  * Added Task.define_option.
19
31
  * Added OptionList so that Option may contain sub-options.
20
32
  * Touched up documenation.
21
33
 
22
- == 0.1.1 / 2008-01-18
34
+ === 0.1.1 / 2008-01-18
23
35
 
24
36
  * Added support for the Option argument separators.
25
37
 
@@ -32,7 +44,7 @@
32
44
 
33
45
  * Fixed lib/rprogram.rb file.
34
46
 
35
- == 0.1.0 / 2008-01-17
47
+ === 0.1.0 / 2008-01-17
36
48
 
37
49
  * Removed redundent methods in Program:
38
50
  * Program.find_by_name
@@ -41,7 +53,7 @@
41
53
  * Made Program Nameable by default.
42
54
  * Prevented arbitrary command-injection in Program#run.
43
55
 
44
- == 0.0.9 / 2008-01-09
56
+ === 0.0.9 / 2008-01-09
45
57
 
46
58
  * Initial release.
47
59
  * Provides cross-platform access to the PATH variable.
data/README.txt CHANGED
@@ -12,6 +12,8 @@ system.
12
12
 
13
13
  == FEATURES/PROBLEMS:
14
14
 
15
+ * Uses Kernel.system for safe execution of individual programs and their
16
+ separate command-line arguments.
15
17
  * Provides cross-platform access to the PATH variable.
16
18
  * Supports leading/tailing non-options.
17
19
  * Supports long-options and short-options.
@@ -33,6 +33,10 @@ module RProgram
33
33
  @multiple = options[:multiple] || false
34
34
  end
35
35
 
36
+ #
37
+ # Returns an +Array+ of the arguments for the non-option with the
38
+ # specified _value_.
39
+ #
36
40
  def arguments(value)
37
41
  return [] if (value==nil || value==false)
38
42
 
@@ -37,7 +37,9 @@ module RProgram
37
37
 
38
38
  ancestors.each do |base|
39
39
  if base.include?(Options)
40
- return base.non_options[name] if base.non_options.has_key?(name)
40
+ if base.non_options.has_key?(name)
41
+ return base.non_options[name]
42
+ end
41
43
  end
42
44
  end
43
45
 
@@ -90,21 +90,22 @@ module RProgram
90
90
 
91
91
  #
92
92
  # Runs the program with the specified _args_ and returns
93
- # an Array of the programs output.
93
+ # either +true+ or +false+, depending on the exit status of the
94
+ # program.
94
95
  #
95
96
  # echo = Program.find_by_name('echo')
96
- # echo.run("hello") # => ["hello\n"]
97
+ # echo.run('hello')
98
+ # # hello
99
+ # # => true
97
100
  #
98
101
  def run(*args)
99
102
  args = args.map { |arg| arg.to_s }
100
103
 
101
104
  if RProgram.debug
102
- $stderr << ">>> #{@path} #{args.join(' ')}\n"
105
+ STDERR.puts ">>> #{@path} #{args.join(' ')}"
103
106
  end
104
107
 
105
- Open3.popen3(@path,*args) do |stdin,stdout,stderr|
106
- return stdout.readlines
107
- end
108
+ return Kernel.system(@path,*args)
108
109
  end
109
110
 
110
111
  #
@@ -117,9 +118,8 @@ module RProgram
117
118
  #
118
119
  # Returns the path of the program.
119
120
  #
120
- # puts Program.find_by_name('echo')
121
- # /usr/bin/echo
122
- # # => nil
121
+ # Program.find_by_name('echo').to_s
122
+ # # => "/usr/bin/echo"
123
123
  #
124
124
  def to_s
125
125
  @path.to_s
@@ -1,3 +1,3 @@
1
1
  module RProgram
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rprogram
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-07 00:00:00 -08:00
12
+ date: 2009-01-14 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency