mvcli 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/README.md +4 -2
- data/lib/mvcli/app.rb +0 -2
- data/lib/mvcli/provisioning.rb +8 -4
- data/lib/mvcli/version.rb +1 -1
- data/spec/mvcli/provisioning_spec.rb +10 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1f731e4ba8f382b06704c3051bda33ded0ef7ce
|
4
|
+
data.tar.gz: 2ad3d53e76c0eb40e9980275c3dcb1fbbe33ea82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b329020fa0bd200d8d85b177a905b434838a68748ad67fc344e438693e7e293bdc61b998495a73271e13aa0ab21d9150a520b8cea0bc7c057d9c53c865221c8
|
7
|
+
data.tar.gz: fdd24ba8968d733efae785848919313ba4e8cd77ca15063ae9dde273fc4b61bb95fdd712140ca826b417a7cdcb9a0dafd0b8ef12fbd7d023326ea283d0b8e7b8
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
## Mvcli
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/mvcli.png)](http://badge.fury.io/rb/mvcli)
|
3
|
+
[![Build Status](https://travis-ci.org/cowboyd/mvcli.png?branch=master)](https://travis-ci.org/cowboyd/mvcli)
|
4
|
+
[![Dependency Status](https://gemnasium.com/cowboyd/mvcli.png)](https://gemnasium.com/cowboyd/mvcli)
|
2
5
|
|
3
|
-
|
4
|
-
bad readme is worse than no README at all.
|
6
|
+
This is still an experiment, but I am beginning to suspect it will be nice.
|
data/lib/mvcli/app.rb
CHANGED
@@ -15,8 +15,6 @@ module MVCLI
|
|
15
15
|
ActiveSupport::Dependencies.autoload_paths << root.join('app/providers')
|
16
16
|
ActiveSupport::Dependencies.autoload_paths << root.join('app/controllers')
|
17
17
|
@middleware = Middleware.new
|
18
|
-
@middleware << Middleware::ExitStatus.new
|
19
|
-
@middleware << Middleware::ExceptionLogger.new
|
20
18
|
@middleware << Provisioning::Middleware.new
|
21
19
|
@middleware << @router
|
22
20
|
end
|
data/lib/mvcli/provisioning.rb
CHANGED
@@ -18,12 +18,13 @@ module MVCLI
|
|
18
18
|
end
|
19
19
|
|
20
20
|
class Scope
|
21
|
-
def initialize(provisioner)
|
21
|
+
def initialize(command, provisioner)
|
22
|
+
@command = command
|
22
23
|
@provisioner = provisioner
|
23
24
|
end
|
24
25
|
|
25
26
|
def [](name)
|
26
|
-
@provisioner[name]
|
27
|
+
name.to_s == "command" ? @command : @provisioner[name]
|
27
28
|
end
|
28
29
|
|
29
30
|
def evaluate
|
@@ -54,16 +55,19 @@ module MVCLI
|
|
54
55
|
class Provisioner
|
55
56
|
def initialize
|
56
57
|
@loader = Loader.new
|
58
|
+
@providers = Map.new
|
57
59
|
end
|
58
60
|
def [](name)
|
59
|
-
provider = @
|
61
|
+
unless provider = @providers[name]
|
62
|
+
provider = @providers[name] = @loader.load :provider, name
|
63
|
+
end
|
60
64
|
provider.value
|
61
65
|
end
|
62
66
|
end
|
63
67
|
|
64
68
|
class Middleware
|
65
69
|
def call(command)
|
66
|
-
Scope.new(Provisioner.new).evaluate do
|
70
|
+
Scope.new(command, Provisioner.new).evaluate do
|
67
71
|
yield command
|
68
72
|
end
|
69
73
|
end
|
data/lib/mvcli/version.rb
CHANGED
@@ -8,19 +8,25 @@ describe "Provisioning" do
|
|
8
8
|
Given(:mod) {Module.new {include MVCLI::Provisioning}}
|
9
9
|
Given(:cls) {m = mod; Class.new {include m}}
|
10
10
|
Given(:obj) {cls.new}
|
11
|
-
Given(:
|
11
|
+
Given(:command) {mock(:Command)}
|
12
|
+
Given(:scope) {MVCLI::Provisioning::Scope.new command, provisioner}
|
13
|
+
context "when the command is required" do
|
14
|
+
Given {mod.requires :command}
|
15
|
+
When(:result) {scope.evaluate {obj.command}}
|
16
|
+
Then {result == command}
|
17
|
+
end
|
12
18
|
context "with a requirement is specified on the module" do
|
13
19
|
Given {mod.requires :foo}
|
14
20
|
context "when accessing it but it is not present" do
|
15
|
-
When(:result) {
|
21
|
+
When(:result) {scope.evaluate {obj.foo}}
|
16
22
|
Then {result.should have_failed MVCLI::Provisioning::UnsatisfiedRequirement, /foo/}
|
17
23
|
end
|
18
24
|
context "and there is a scope which satisfies the requirement" do
|
19
25
|
Given(:foo) {Object.new}
|
20
26
|
Given {provisioner[:foo] = foo}
|
21
27
|
|
22
|
-
context "when a dependency is accessed in the context of the
|
23
|
-
When(:result) {
|
28
|
+
context "when a dependency is accessed in the context of the scope" do
|
29
|
+
When(:result) {scope.evaluate {obj.foo}}
|
24
30
|
Then {result == foo}
|
25
31
|
end
|
26
32
|
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.6
|
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-
|
32
|
+
date: 2013-06-07 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: map
|
@@ -67,6 +67,7 @@ extensions: []
|
|
67
67
|
extra_rdoc_files: []
|
68
68
|
files:
|
69
69
|
- .gitignore
|
70
|
+
- .travis.yml
|
70
71
|
- Gemfile
|
71
72
|
- LICENSE.txt
|
72
73
|
- README.md
|