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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9df77365dc96a8d03660f3ae22bc647cf343a821
4
- data.tar.gz: b81d0467d45b9df8a6bb57804ca61c901eb1052d
3
+ metadata.gz: d1f731e4ba8f382b06704c3051bda33ded0ef7ce
4
+ data.tar.gz: 2ad3d53e76c0eb40e9980275c3dcb1fbbe33ea82
5
5
  SHA512:
6
- metadata.gz: ce07168bc53a0c1610ce83bde155dbd88b841533bee80a27391df950ddf68b2c4463ad26809a99c24eadad12cad08173643c22664f164c28bb2ec040a944f63e
7
- data.tar.gz: 2599b6e46b9d33ebbd8d880f798caa1747f2052cbb6b07d8d6846b1d868e0234c9e6e854d0cc74e438b91bb61faa84055f61c7b447667b7669ff34a792cdb8ad
6
+ metadata.gz: 8b329020fa0bd200d8d85b177a905b434838a68748ad67fc344e438693e7e293bdc61b998495a73271e13aa0ab21d9150a520b8cea0bc7c057d9c53c865221c8
7
+ data.tar.gz: fdd24ba8968d733efae785848919313ba4e8cd77ca15063ae9dde273fc4b61bb95fdd712140ca826b417a7cdcb9a0dafd0b8ef12fbd7d023326ea283d0b8e7b8
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ rvm:
2
+ - 2.0.0
3
+ notifications:
4
+ recipients:
5
+ - cowboyd@thefrontside.net
6
+
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
- It's terribly frustrating when repos don't have a good README. But a
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
@@ -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 = @loader.load :provider, name
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
@@ -1,3 +1,3 @@
1
1
  module MVCLI
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -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(:container) {MVCLI::Provisioning::Scope.new provisioner}
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) {container.evaluate {obj.foo}}
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 container" do
23
- When(:result) {container.evaluate {obj.foo}}
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.5
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-05-30 00:00:00.000000000 Z
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