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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb15bdc23646980fbfdea73b3cd1f051467aff7e
4
- data.tar.gz: 2e38b80f19750bf4d47c8f0cc31ba4a1c138aadb
3
+ metadata.gz: f5e10792fd29ac8531f3fad187e62aa0faf29289
4
+ data.tar.gz: 4fcf5e6a896261dd9a269e648c5bbba049b37ff3
5
5
  SHA512:
6
- metadata.gz: dccdfd0d6bef05bdab748537d0f2679441b8d3039865329fae20509c4546fdbf72c47cf8577b6d7aaff959aa902b29db1acef5778add753d112395fb9bbf58b7
7
- data.tar.gz: 923fc371652f94527547153d65a6b9ddb85042641b70c656b8aa940b6283b1a8dc8545149450d81b33866699dc78339598e23c42f9a5237c64ae7ce1960ed73f
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
@@ -35,7 +35,7 @@ module MVCLI
35
35
  end
36
36
 
37
37
  def to_proc
38
- proc {|*_| call(*_)}
38
+ method(:call).to_proc
39
39
  end
40
40
  end
41
41
 
@@ -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
- decoder.call value
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
@@ -4,8 +4,7 @@ require "mvcli/argv"
4
4
 
5
5
  module MVCLI
6
6
  class Router
7
- RoutingError = Class.new StandardError
8
- InvalidRoute = Class.new RoutingError
7
+ class RoutingError < StandardError; end
9
8
 
10
9
  def initialize(actions = nil)
11
10
  @actions = actions || Map.new
@@ -1,3 +1,3 @@
1
1
  module MVCLI
2
- VERSION = "0.0.14"
2
+ VERSION = "0.0.16"
3
3
  end
@@ -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
@@ -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 = *attrs.values_at(:address, :port, :protocol, :condition, :type)
127
+ @address, @port, @protocal, @condition, @type = attrs.values_at(:address, :port, :protocol, :condition, :type)
128
128
  end
129
129
 
130
130
  end
@@ -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.14
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-11 00:00:00.000000000 Z
32
+ date: 2013-07-29 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: map