coulis 0.2.5 → 0.2.6
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/lib/coulis.rb +4 -4
- data/test/coulis_test.rb +14 -13
- metadata +5 -5
data/lib/coulis.rb
CHANGED
@@ -49,7 +49,7 @@ class Coulis
|
|
49
49
|
help.each do |l|
|
50
50
|
args = l.scan(/(\-{1,2}[\w\-]+)[\W]/)
|
51
51
|
unless args.empty?
|
52
|
-
args.each{|a| @_safe_args << a.to_s}
|
52
|
+
args.each{|a| @_safe_args << a[0].to_s}
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -103,7 +103,7 @@ class Coulis
|
|
103
103
|
definition = self.class._definitions[argname.to_sym] || argumentize(argname)
|
104
104
|
|
105
105
|
result = @args.find{|a| a[0].to_s == definition.to_s}
|
106
|
-
return if result.nil?
|
106
|
+
return if result.nil?
|
107
107
|
|
108
108
|
value = result[1]
|
109
109
|
return nil if value.nil?
|
@@ -172,7 +172,7 @@ class Coulis
|
|
172
172
|
#puts "m: #{m}, args: #{args.inspect}, definition: #{definition.inspect}"
|
173
173
|
arg_name = argumentize(m)
|
174
174
|
|
175
|
-
if args.
|
175
|
+
if args.size == 0
|
176
176
|
insert_arg [ definition || arg_name ]
|
177
177
|
return self
|
178
178
|
end
|
@@ -219,7 +219,7 @@ class Coulis
|
|
219
219
|
end
|
220
220
|
|
221
221
|
if arg_to_find = opts[:before] || opts[:after]
|
222
|
-
found = @args.find{|a|
|
222
|
+
found = @args.find{|a|
|
223
223
|
a[0] == (self.class._definitions[arg_to_find.to_sym] || arg_to_find)
|
224
224
|
}
|
225
225
|
|
data/test/coulis_test.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
$LOAD_PATH << "."
|
1
2
|
require "test/unit"
|
2
3
|
require "coulis"
|
3
4
|
|
@@ -65,25 +66,25 @@ class SimpleCliTest < Test::Unit::TestCase
|
|
65
66
|
|
66
67
|
def test_argument_added
|
67
68
|
ls = Ls.options { all }
|
68
|
-
assert
|
69
|
+
assert ls.args[0][0] == "-a"
|
69
70
|
end
|
70
71
|
|
71
72
|
def test_not_defined_short_argument
|
72
73
|
ls = Ls.options { g }
|
73
74
|
assert_equal 1, ls.args.size
|
74
|
-
assert_equal "-g", ls.args
|
75
|
+
assert_equal "-g", ls.args[0][0]
|
75
76
|
end
|
76
|
-
|
77
|
+
|
77
78
|
def test_not_defined_long_argument
|
78
79
|
ls = Ls.options { color }
|
79
80
|
assert_equal 1, ls.args.size
|
80
|
-
assert_equal "--color", ls.args
|
81
|
+
assert_equal "--color", ls.args[0][0]
|
81
82
|
end
|
82
83
|
|
83
84
|
def test_not_defined_long_argument_with_underscore
|
84
85
|
ls = Ls.options { color_test }
|
85
86
|
assert_equal 1, ls.args.size
|
86
|
-
assert_equal "--color-test", ls.args
|
87
|
+
assert_equal "--color-test", ls.args[0][0]
|
87
88
|
end
|
88
89
|
|
89
90
|
def test_no_double_dash_option
|
@@ -152,14 +153,14 @@ class SimpleCliTest < Test::Unit::TestCase
|
|
152
153
|
ls = Ls.options { full }.exec
|
153
154
|
|
154
155
|
assert_instance_of String, ls
|
155
|
-
assert
|
156
|
+
assert ls.size > 0
|
156
157
|
end
|
157
158
|
|
158
159
|
def test_exec_with_block
|
159
160
|
ls = Ls.options { full }
|
160
161
|
process = ls.exec do |out|
|
161
162
|
assert_instance_of String, out
|
162
|
-
assert
|
163
|
+
assert out.size > 0
|
163
164
|
end
|
164
165
|
|
165
166
|
assert_instance_of Process::Status, process
|
@@ -185,7 +186,7 @@ class SimpleCliTest < Test::Unit::TestCase
|
|
185
186
|
res << out
|
186
187
|
end
|
187
188
|
|
188
|
-
assert
|
189
|
+
assert res.size > 0
|
189
190
|
end
|
190
191
|
|
191
192
|
def test_parse_output
|
@@ -193,18 +194,18 @@ class SimpleCliTest < Test::Unit::TestCase
|
|
193
194
|
@args = ["google.com"]
|
194
195
|
}.exec do |ips|
|
195
196
|
assert_instance_of Array, ips
|
196
|
-
assert
|
197
|
+
assert ips.size > 1
|
197
198
|
end
|
198
199
|
end
|
199
200
|
|
200
201
|
def test_success_event
|
201
202
|
process = Ls.options {
|
202
203
|
all
|
203
|
-
}.on_success {|out|
|
204
|
+
}.on_success {|out|
|
204
205
|
assert_instance_of Process::Status, $?
|
205
206
|
assert_equal 0, $?.exitstatus
|
206
207
|
assert_instance_of String, out
|
207
|
-
}.exec {|out|
|
208
|
+
}.exec {|out|
|
208
209
|
assert_instance_of String, out
|
209
210
|
}
|
210
211
|
end
|
@@ -216,7 +217,7 @@ class SimpleCliTest < Test::Unit::TestCase
|
|
216
217
|
assert_instance_of Process::Status, $?
|
217
218
|
assert_equal 1, $?.exitstatus
|
218
219
|
assert_instance_of String, out
|
219
|
-
}.exec {|out|
|
220
|
+
}.exec {|out|
|
220
221
|
assert_instance_of String, out
|
221
222
|
}
|
222
223
|
end
|
@@ -324,7 +325,7 @@ class SimpleCliTest < Test::Unit::TestCase
|
|
324
325
|
|
325
326
|
def test_safe_mode_is_off_if_help_parsing_issue
|
326
327
|
FFMpeg._safe_args = nil
|
327
|
-
FFMpeg._help = "ffmpeg help broken"
|
328
|
+
FFMpeg._help = ["ffmpeg help broken"]
|
328
329
|
FFMpeg._safe_mode
|
329
330
|
|
330
331
|
ffmpeg = FFMpeg.options {
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coulis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 6
|
10
|
+
version: 0.2.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bruno Celeste
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2013-11-02 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: Simple but powerful CLI Wrapper
|
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements: []
|
59
59
|
|
60
60
|
rubyforge_project:
|
61
|
-
rubygems_version: 1.8.
|
61
|
+
rubygems_version: 1.8.28
|
62
62
|
signing_key:
|
63
63
|
specification_version: 3
|
64
64
|
summary: A simple CLI Wrapper
|