runnable 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/runnable/command_parser.rb +1 -1
- data/lib/runnable/extended.rb +3 -7
- data/lib/runnable/gnu.rb +8 -12
- data/lib/runnable.rb +25 -8
- data/runnable.gemspec +2 -2
- metadata +15 -15
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
data/lib/runnable/extended.rb
CHANGED
@@ -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
|
24
|
-
# @return [
|
23
|
+
# Convert a hash in an array of 'Extended style' option strings.
|
24
|
+
# @return [Array] Extended-style parsed params.
|
25
25
|
def parse
|
26
|
-
|
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
|
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 [
|
26
|
+
# @return [Array] Gnu-style parsed params in a string array.
|
27
27
|
def parse
|
28
|
-
|
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
|
-
|
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 (
|
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
|
-
|
38
|
+
option.concat( param.length == 1 ? "#{value}" : "=#{value}" )
|
41
39
|
end
|
42
40
|
|
43
|
-
|
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.
|
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-
|
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.
|
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-
|
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: &
|
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: *
|
28
|
+
version_requirements: *21080560
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: yard
|
31
|
-
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: *
|
39
|
+
version_requirements: *21079240
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: rspec
|
42
|
-
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: *
|
50
|
+
version_requirements: *21076920
|
51
51
|
- !ruby/object:Gem::Dependency
|
52
52
|
name: cucumber
|
53
|
-
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: *
|
61
|
+
version_requirements: *21075340
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: jeweler
|
64
|
-
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: *
|
72
|
+
version_requirements: *21070000
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
74
|
name: bluecloth
|
75
|
-
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: *
|
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:
|
120
|
+
hash: -599557484973593353
|
121
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
122
|
none: false
|
123
123
|
requirements:
|