mothership 0.3.0 → 0.3.1
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/mothership/inputs.rb +16 -2
- data/lib/mothership/parser.rb +4 -4
- data/lib/mothership/version.rb +1 -1
- data/spec/arguments_spec.rb +1 -2
- data/spec/combination_spec.rb +1 -2
- data/spec/flags_spec.rb +1 -2
- metadata +4 -6
- data/spec/helpers.rb +0 -23
data/lib/mothership/inputs.rb
CHANGED
@@ -31,8 +31,16 @@ class Mothership
|
|
31
31
|
self.class.new(@command, @context, @inputs.merge(inputs), @given, @global)
|
32
32
|
end
|
33
33
|
|
34
|
-
def merge_given(
|
35
|
-
self.class.new(@command, @context, @inputs, @given.merge(
|
34
|
+
def merge_given(given)
|
35
|
+
self.class.new(@command, @context, @inputs, @given.merge(given), @global)
|
36
|
+
end
|
37
|
+
|
38
|
+
def rebase(inputs)
|
39
|
+
self.class.new(@command, @context, inputs.merge(@inputs), @given, @global)
|
40
|
+
end
|
41
|
+
|
42
|
+
def rebase_given(given)
|
43
|
+
self.class.new(@command, @context, @inputs, given.merge(@given), @global)
|
36
44
|
end
|
37
45
|
|
38
46
|
def without(*names)
|
@@ -139,6 +147,12 @@ class Mothership
|
|
139
147
|
else
|
140
148
|
context.instance_exec(given, *args, &convert)
|
141
149
|
end
|
150
|
+
elsif meta[:type] == :integer
|
151
|
+
given.to_i
|
152
|
+
elsif meta[:type] == :float
|
153
|
+
given.to_f
|
154
|
+
elsif meta[:type] == :boolean
|
155
|
+
given == "true"
|
142
156
|
else
|
143
157
|
given
|
144
158
|
end
|
data/lib/mothership/parser.rb
CHANGED
@@ -50,19 +50,19 @@ class Mothership
|
|
50
50
|
case input[:type]
|
51
51
|
when :bool, :boolean
|
52
52
|
if argv.first == "false" || argv.first == "true"
|
53
|
-
@given[name] = argv.shift
|
53
|
+
@given[name] = argv.shift
|
54
54
|
else
|
55
|
-
@given[name] = true
|
55
|
+
@given[name] = "true"
|
56
56
|
end
|
57
57
|
when :float, :floating
|
58
58
|
if !argv.empty? && argv.first =~ /^[0-9]+(\.[0-9]*)?$/
|
59
|
-
@given[name] = argv.shift
|
59
|
+
@given[name] = argv.shift
|
60
60
|
else
|
61
61
|
raise TypeMismatch.new(@command, name, "floating")
|
62
62
|
end
|
63
63
|
when :integer, :number, :numeric
|
64
64
|
if !argv.empty? && argv.first =~ /^[0-9]+$/
|
65
|
-
@given[name] = argv.shift
|
65
|
+
@given[name] = argv.shift
|
66
66
|
else
|
67
67
|
raise TypeMismatch.new(@command, name, "numeric")
|
68
68
|
end
|
data/lib/mothership/version.rb
CHANGED
data/spec/arguments_spec.rb
CHANGED
data/spec/combination_spec.rb
CHANGED
data/spec/flags_spec.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mothership
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alex Suraci
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-12-04 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rake
|
@@ -72,7 +72,6 @@ files:
|
|
72
72
|
- spec/arguments_spec.rb
|
73
73
|
- spec/combination_spec.rb
|
74
74
|
- spec/flags_spec.rb
|
75
|
-
- spec/helpers.rb
|
76
75
|
- spec/Rakefile
|
77
76
|
homepage: https://github.com/vito/mothership
|
78
77
|
licenses: []
|
@@ -111,5 +110,4 @@ test_files:
|
|
111
110
|
- spec/arguments_spec.rb
|
112
111
|
- spec/combination_spec.rb
|
113
112
|
- spec/flags_spec.rb
|
114
|
-
- spec/helpers.rb
|
115
113
|
- spec/Rakefile
|
data/spec/helpers.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module MothershipHelpers
|
2
|
-
def command(inputs = {})
|
3
|
-
cmd = Mothership::Command.new(Mothership)
|
4
|
-
|
5
|
-
inputs.each do |name, opts|
|
6
|
-
cmd.add_input(name, opts)
|
7
|
-
end
|
8
|
-
|
9
|
-
if block_given?
|
10
|
-
yield cmd
|
11
|
-
else
|
12
|
-
cmd
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def inputs(cmd, *argv)
|
17
|
-
Mothership::Parser.new(cmd).parse_argv(argv)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
RSpec.configure do |c|
|
22
|
-
c.include MothershipHelpers
|
23
|
-
end
|