mvcli 0.0.4 → 0.0.5

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: 79165f026197eb88758309a18703c91449f6849b
4
- data.tar.gz: b2b3e3ee52b717fb962e3675e97cf16595fdc101
3
+ metadata.gz: 9df77365dc96a8d03660f3ae22bc647cf343a821
4
+ data.tar.gz: b81d0467d45b9df8a6bb57804ca61c901eb1052d
5
5
  SHA512:
6
- metadata.gz: 3f48d494fbada3facb993260ceffeff544a16d0853ae3cdb73ffffd6af815f43ce5199058d525592885e553db16c60353ae1ba78845abdf1c2a5b4037a6067a7
7
- data.tar.gz: 6c374042c711e0802bcfa3e287835a25b0471e4f56a2ac61d722f66aeb8cc58302369e9b5b2650921d727a075d6c9fdd8a715dc13cae5494cb3ccc55bef98030
6
+ metadata.gz: ce07168bc53a0c1610ce83bde155dbd88b841533bee80a27391df950ddf68b2c4463ad26809a99c24eadad12cad08173643c22664f164c28bb2ec040a944f63e
7
+ data.tar.gz: 2599b6e46b9d33ebbd8d880f798caa1747f2052cbb6b07d8d6846b1d868e0234c9e6e854d0cc74e438b91bb61faa84055f61c7b447667b7669ff34a792cdb8ad
data/lib/mvcli/app.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require "mvcli"
2
+ require "mvcli/middleware/exit_status"
3
+ require "mvcli/middleware/exception_logger"
2
4
  require_relative "middleware"
3
5
  require_relative "command"
4
6
  require_relative "actions"
@@ -13,6 +15,8 @@ module MVCLI
13
15
  ActiveSupport::Dependencies.autoload_paths << root.join('app/providers')
14
16
  ActiveSupport::Dependencies.autoload_paths << root.join('app/controllers')
15
17
  @middleware = Middleware.new
18
+ @middleware << Middleware::ExitStatus.new
19
+ @middleware << Middleware::ExceptionLogger.new
16
20
  @middleware << Provisioning::Middleware.new
17
21
  @middleware << @router
18
22
  end
@@ -0,0 +1,12 @@
1
+ module MVCLI
2
+ class Middleware
3
+ class ExceptionLogger
4
+ def call(command)
5
+ yield command
6
+ rescue Exception => e
7
+ command.log << e.message + "\n"
8
+ raise e
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ class MVCLI::Middleware
2
+ EX_SOFTWARE = 70
3
+
4
+ class ExitStatus
5
+ def call(command)
6
+ result = yield command
7
+ result.is_a?(Integer) ? result : 0
8
+ rescue Exception => e
9
+ return EX_SOFTWARE
10
+ end
11
+ end
12
+ end
data/lib/mvcli/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module MVCLI
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -0,0 +1,18 @@
1
+ require "spec_helper"
2
+ require "mvcli/middleware/exception_logger"
3
+
4
+ describe "MVCLI::Middleware::ExceptionLogger" do
5
+ use_natural_assertions
6
+
7
+ Given(:command) {mock(:Command, :log => "")}
8
+ Given(:logger) {MVCLI::Middleware::ExceptionLogger.new}
9
+ context "with a cleanly running application" do
10
+ When(:result) {logger.call(command) {0}}
11
+ Then {result == 0}
12
+ end
13
+ context "with an app that raises an exception" do
14
+ When(:result) {logger.call(command) {fail "boom!"}}
15
+ Then {command.log == "boom!\n"}
16
+ And {result.should have_failed StandardError, "boom!"}
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+ require "mvcli/middleware/exit_status"
3
+
4
+ describe MVCLI::Middleware::ExitStatus do
5
+ use_natural_assertions
6
+ Given(:command) {mock(:Command)}
7
+ Given(:middleware) {MVCLI::Middleware::ExitStatus.new}
8
+ context "when called with code that succeeds" do
9
+ When(:status) {middleware.call(command) {0}}
10
+ Then {status == 0}
11
+ end
12
+ context "when called with an app that fails with an exit status of 99" do
13
+ When(:status) {middleware.call(command) {99}}
14
+ Then{ status == 99}
15
+ end
16
+
17
+ context "when the upstream app yields a non-integer" do
18
+ When(:status) {middleware.call(command) {"whoopeee!"}}
19
+ Then {status == 0}
20
+ end
21
+
22
+ context "when the upstream app raises an exception" do
23
+ When(:status) {middleware.call(command) {fail "boom!"}}
24
+ Then {status == 70}
25
+ end
26
+ 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
4
+ version: 0.0.5
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-28 00:00:00.000000000 Z
32
+ date: 2013-05-30 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: map
@@ -81,6 +81,8 @@ files:
81
81
  - lib/mvcli/erb.rb
82
82
  - lib/mvcli/loader.rb
83
83
  - lib/mvcli/middleware.rb
84
+ - lib/mvcli/middleware/exception_logger.rb
85
+ - lib/mvcli/middleware/exit_status.rb
84
86
  - lib/mvcli/provisioning.rb
85
87
  - lib/mvcli/renderer.rb
86
88
  - lib/mvcli/router.rb
@@ -91,6 +93,8 @@ files:
91
93
  - spec/mvcli/dummy/app/providers/test_provider.rb
92
94
  - spec/mvcli/erb_spec.rb
93
95
  - spec/mvcli/loader_spec.rb
96
+ - spec/mvcli/middleware/exception_logger_spec.rb
97
+ - spec/mvcli/middleware/exit_status_spec.rb
94
98
  - spec/mvcli/middleware_spec.rb
95
99
  - spec/mvcli/provisioning_spec.rb
96
100
  - spec/mvcli/router/pattern_spec.rb
@@ -125,6 +129,8 @@ test_files:
125
129
  - spec/mvcli/dummy/app/providers/test_provider.rb
126
130
  - spec/mvcli/erb_spec.rb
127
131
  - spec/mvcli/loader_spec.rb
132
+ - spec/mvcli/middleware/exception_logger_spec.rb
133
+ - spec/mvcli/middleware/exit_status_spec.rb
128
134
  - spec/mvcli/middleware_spec.rb
129
135
  - spec/mvcli/provisioning_spec.rb
130
136
  - spec/mvcli/router/pattern_spec.rb