mvcli 0.0.14 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/mvcli/form.rb +1 -1
- data/lib/mvcli/form/input.rb +5 -1
- data/lib/mvcli/router.rb +1 -2
- data/lib/mvcli/version.rb +1 -1
- data/spec/mvcli/form/input_spec.rb +6 -1
- data/spec/mvcli/form_spec.rb +1 -1
- data/spec/mvcli/router_spec.rb +8 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5e10792fd29ac8531f3fad187e62aa0faf29289
|
4
|
+
data.tar.gz: 4fcf5e6a896261dd9a269e648c5bbba049b37ff3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4787013d0c68f4eadb8665f0852f8bad35cf1242073bc39693c5eeb3b9a24102ea502e2f5283f346fc67f350bd44c886f3b1085ebfe8619d289aafb93f26f326
|
7
|
+
data.tar.gz: a27d207aa5395d024e1ff71c2dc27e692758172b0e3776719ed35f671d987e734560005b13f338245a921d5c8cef74533b55343f911e46e39c0b6714d6fa13f4
|
data/README.md
CHANGED
@@ -4,3 +4,7 @@
|
|
4
4
|
[![Dependency Status](https://gemnasium.com/cowboyd/mvcli.png)](https://gemnasium.com/cowboyd/mvcli)
|
5
5
|
|
6
6
|
This is still an experiment, but I am beginning to suspect it will be nice.
|
7
|
+
|
8
|
+
For an example of an application that uses this, see [rumm][1]
|
9
|
+
|
10
|
+
[1]: https://github.com/rackerlabs/rumm
|
data/lib/mvcli/form.rb
CHANGED
data/lib/mvcli/form/input.rb
CHANGED
@@ -41,7 +41,11 @@ class MVCLI::Form::Input
|
|
41
41
|
def decoded(source, context)
|
42
42
|
if value = [source[@name]].flatten.first
|
43
43
|
@decoders.reduce(value) do |value, decoder|
|
44
|
-
|
44
|
+
if context.nil?
|
45
|
+
decoder.call value
|
46
|
+
else
|
47
|
+
context.instance_exec value, &decoder
|
48
|
+
end
|
45
49
|
end
|
46
50
|
else
|
47
51
|
default context
|
data/lib/mvcli/router.rb
CHANGED
data/lib/mvcli/version.rb
CHANGED
@@ -72,7 +72,12 @@ describe "Form Inputs" do
|
|
72
72
|
Then {value.nil?}
|
73
73
|
end
|
74
74
|
end
|
75
|
-
|
75
|
+
describe "with a decoding dependeant on context" do
|
76
|
+
Given(:context) { double(:count => 2) }
|
77
|
+
Given(:block) { ->(s) {s * count} }
|
78
|
+
When(:value) { input.value({field: '3'}, context) }
|
79
|
+
Then { value == '33' }
|
80
|
+
end
|
76
81
|
describe "with a default" do
|
77
82
|
Given(:options) {{default: 5}}
|
78
83
|
context "when accesing nil" do
|
data/spec/mvcli/form_spec.rb
CHANGED
@@ -124,7 +124,7 @@ class Node
|
|
124
124
|
validates(:port, "port must be between 0 and 65,535") {|port| port >= 0 && port <= 65535}
|
125
125
|
|
126
126
|
def initialize(attrs)
|
127
|
-
@address, @port, @protocal, @condition, @type =
|
127
|
+
@address, @port, @protocal, @condition, @type = attrs.values_at(:address, :port, :protocol, :condition, :type)
|
128
128
|
end
|
129
129
|
|
130
130
|
end
|
data/spec/mvcli/router_spec.rb
CHANGED
@@ -14,6 +14,10 @@ describe "MVCLI::Router" do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
def invoke(route = '')
|
18
|
+
router.call mock(:Command, :argv => route.split(/\s+/))
|
19
|
+
end
|
20
|
+
|
17
21
|
context "without any routes" do
|
18
22
|
When(:result) {invoke}
|
19
23
|
Then {result.should have_failed self.Router::RoutingError}
|
@@ -40,11 +44,11 @@ describe "MVCLI::Router" do
|
|
40
44
|
end
|
41
45
|
|
42
46
|
context "with a route with captures" do
|
43
|
-
Given {router.match 'show loadbalancer :id' => 'loadbalancers#show'}
|
44
|
-
When {invoke 'show loadbalancer 6'}
|
47
|
+
Given { router.match 'show loadbalancer :id' => 'loadbalancers#show' }
|
48
|
+
When { invoke 'show loadbalancer 6' }
|
45
49
|
Then {@action == 'loadbalancers#show'}
|
46
|
-
And {@command.argv == ['show', 'loadbalancer', '6']}
|
47
|
-
And {@bindings[:id] == '6'}
|
50
|
+
And { @command.argv == ['show', 'loadbalancer', '6'] }
|
51
|
+
And { @bindings[:id] == '6' }
|
48
52
|
end
|
49
53
|
|
50
54
|
context "with macros" do
|
@@ -53,8 +57,4 @@ describe "MVCLI::Router" do
|
|
53
57
|
When { invoke "--help me" }
|
54
58
|
Then { @action == 'help#me' }
|
55
59
|
end
|
56
|
-
|
57
|
-
def invoke(route = '')
|
58
|
-
router.call mock(:Command, :argv => route.split(/\s+/))
|
59
|
-
end
|
60
60
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mvcli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Lowell
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
UgImJlChAzCoDP9zi9tdm6jAr7ttF25R9PPYr11ILb7dYe3qUzlNlM6zJx/nb31b
|
30
30
|
IhdyRVup4qLcqYSTPsm6u7VA
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2013-07-
|
32
|
+
date: 2013-07-29 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: map
|