runnable 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
@@ -37,7 +37,7 @@ class CommandParser
37
37
 
38
38
  # This method has to be overwritten in the child
39
39
  # @abstract
40
- # @return [String]
40
+ # @return [Array]
41
41
  def parse
42
42
  end
43
43
  end
@@ -20,14 +20,10 @@ require 'runnable/command_parser'
20
20
  # Parse the parameter hash using the extended standard.
21
21
  class Extended < CommandParser
22
22
 
23
- # Convert a hash in a Extended style string options.
24
- # @return [String] Extended-style parsed params in a raw character array.
23
+ # Convert a hash in an array of 'Extended style' option strings.
24
+ # @return [Array] Extended-style parsed params.
25
25
  def parse
26
- options = ""
27
- @params.each do | param , value |
28
- options = "#{options} -#{param} #{value} "
29
- end
30
- options.strip
26
+ @params.collect { |param , value| ["-#{param}", "#{value}"] }
31
27
  end
32
28
 
33
29
  end
data/lib/runnable/gnu.rb CHANGED
@@ -20,30 +20,26 @@ require 'runnable/command_parser'
20
20
  # Parse the parameter hash using the GNU standard.
21
21
  class Gnu < CommandParser
22
22
 
23
- # This method convert a hash in a string ready to
23
+ # This method convert a hash in an array of strings ready to
24
24
  # be passed to a command that uses GNU style to parse command line
25
25
  # parameters.
26
- # @return [String] Gnu-style parsed params in a raw character array.
26
+ # @return [Array] Gnu-style parsed params in a string array.
27
27
  def parse
28
- result = ""
29
-
30
- @params.each do |param, value|
28
+ @params.collect do |param, value|
31
29
  # We assume that an one character words is preceed by one
32
30
  # lead and two or more characters words are preceed by two
33
31
  # leads
34
- result.concat( param.length == 1 ? "-#{param}" : "--#{param}" )
32
+ option = ( param.length == 1 ? "-#{param}" : "--#{param}" )
35
33
 
36
34
  # In case the param have parameter we use the correct assignation
37
- # -Param followed by value (without whitespace) to one character params
35
+ # -Param followed by value (whitout whitespace) to one character params
38
36
  # -Param followed by '=' and value to more than one character params
39
37
  if( value != nil )
40
- result.concat( param.length == 1 ? "#{value}" : "=#{value}" )
38
+ option.concat( param.length == 1 ? "#{value}" : "=#{value}" )
41
39
  end
42
40
 
43
- # Final whitespace
44
- result.concat( " " )
41
+ option
45
42
  end
46
-
47
- return result.strip
48
43
  end
44
+
49
45
  end
data/lib/runnable.rb CHANGED
@@ -141,18 +141,35 @@ class Runnable
141
141
  out_rd, out_wr = IO.pipe
142
142
  # Redirect Error I/O
143
143
  err_rd, err_wr = IO.pipe
144
-
144
+
145
+ # Reset exceptions array to not store exceptions for
146
+ # past executions
147
+ @excep_array = []
148
+
145
149
  # Set up the command line
146
150
  command = []
147
- command << @command
148
- command << @input
149
- command << @options
151
+ #command << @command
152
+ command << @input.to_s
153
+ command << @options.to_s
150
154
  command << @command_line_interface.parse
151
- command << @output
152
- command = command.join( " " )
153
-
154
- @pid = Process.spawn( command, { :out => out_wr, :err => err_wr } )
155
+ command << @output.to_s
156
+ #command = command.join( " " )
157
+ command.flatten!
155
158
 
159
+ command = command.select do |value|
160
+ !value.to_s.strip.empty?
161
+ end
162
+ =begin
163
+ # Debugging purpose
164
+ puts "I: #{@input}"
165
+ puts "OP: #{@options}"
166
+ puts "CLI: #{@command_line_interface.parse}"
167
+ puts "O: #{@output}"
168
+ puts "C: #{command}"
169
+ =end
170
+ #@pid = Process.spawn( command, { :out => out_wr, :err => err_wr } )
171
+ @pid = Process.spawn( @command, *command, { :out => out_wr, :err => err_wr } )
172
+
156
173
  # Include instance in class variable
157
174
  @@processes[@pid] = self
158
175
 
data/runnable.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{runnable}
8
- s.version = "0.2.3"
8
+ s.version = "0.2.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Rafael García", "Luis Ciudad", "Pedro Navajas", "Javier Aranda"]
12
- s.date = %q{2011-08-26}
12
+ s.date = %q{2011-10-27}
13
13
  s.description = %q{Convert a executable command in a Ruby-like class you are able to start, define params and send signals (like kill, or stop)}
14
14
  s.email = ["rgarcia@nosolosoftware.biz", "lciudad@nosolosoftware.biz", "pnavajas@nosolosoftware.biz", "jaranda@nosolosoftware.biz"]
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runnable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,12 +12,12 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2011-08-26 00:00:00.000000000 +02:00
15
+ date: 2011-10-27 00:00:00.000000000 +02:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rake
20
- requirement: &24798400 !ruby/object:Gem::Requirement
20
+ requirement: &21080560 !ruby/object:Gem::Requirement
21
21
  none: false
22
22
  requirements:
23
23
  - - ! '>='
@@ -25,10 +25,10 @@ dependencies:
25
25
  version: 0.8.7
26
26
  type: :development
27
27
  prerelease: false
28
- version_requirements: *24798400
28
+ version_requirements: *21080560
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: yard
31
- requirement: &24797260 !ruby/object:Gem::Requirement
31
+ requirement: &21079240 !ruby/object:Gem::Requirement
32
32
  none: false
33
33
  requirements:
34
34
  - - ! '>='
@@ -36,10 +36,10 @@ dependencies:
36
36
  version: 0.6.8
37
37
  type: :development
38
38
  prerelease: false
39
- version_requirements: *24797260
39
+ version_requirements: *21079240
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rspec
42
- requirement: &24796600 !ruby/object:Gem::Requirement
42
+ requirement: &21076920 !ruby/object:Gem::Requirement
43
43
  none: false
44
44
  requirements:
45
45
  - - ! '>='
@@ -47,10 +47,10 @@ dependencies:
47
47
  version: 2.5.0
48
48
  type: :development
49
49
  prerelease: false
50
- version_requirements: *24796600
50
+ version_requirements: *21076920
51
51
  - !ruby/object:Gem::Dependency
52
52
  name: cucumber
53
- requirement: &24795620 !ruby/object:Gem::Requirement
53
+ requirement: &21075340 !ruby/object:Gem::Requirement
54
54
  none: false
55
55
  requirements:
56
56
  - - ! '>='
@@ -58,10 +58,10 @@ dependencies:
58
58
  version: 0.10.2
59
59
  type: :development
60
60
  prerelease: false
61
- version_requirements: *24795620
61
+ version_requirements: *21075340
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: jeweler
64
- requirement: &24794100 !ruby/object:Gem::Requirement
64
+ requirement: &21070000 !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
67
  - - ! '>='
@@ -69,10 +69,10 @@ dependencies:
69
69
  version: 1.6.0
70
70
  type: :development
71
71
  prerelease: false
72
- version_requirements: *24794100
72
+ version_requirements: *21070000
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: bluecloth
75
- requirement: &24792600 !ruby/object:Gem::Requirement
75
+ requirement: &21067180 !ruby/object:Gem::Requirement
76
76
  none: false
77
77
  requirements:
78
78
  - - ! '>='
@@ -80,7 +80,7 @@ dependencies:
80
80
  version: 2.1.0
81
81
  type: :development
82
82
  prerelease: false
83
- version_requirements: *24792600
83
+ version_requirements: *21067180
84
84
  description: Convert a executable command in a Ruby-like class you are able to start,
85
85
  define params and send signals (like kill, or stop)
86
86
  email:
@@ -117,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  segments:
119
119
  - 0
120
- hash: 1440204115093721090
120
+ hash: -599557484973593353
121
121
  required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  none: false
123
123
  requirements: