mvcli 0.0.16 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +4 -0
  3. data/Gemfile +2 -2
  4. data/README.md +6 -2
  5. data/app.rb +7 -0
  6. data/app/routes.rb +0 -0
  7. data/bin/mvcli +5 -0
  8. data/lib/mvcli.rb +1 -0
  9. data/lib/mvcli/action.rb +31 -0
  10. data/lib/mvcli/app.rb +23 -28
  11. data/lib/mvcli/controller.rb +20 -2
  12. data/lib/mvcli/core.rb +101 -0
  13. data/lib/mvcli/cortex.rb +38 -0
  14. data/lib/mvcli/form.rb +13 -0
  15. data/lib/mvcli/loader.rb +45 -1
  16. data/lib/mvcli/middleware.rb +13 -15
  17. data/lib/mvcli/path.rb +41 -0
  18. data/lib/mvcli/plugins.rb +19 -0
  19. data/lib/mvcli/plugins/controllers/plugins_controller.rb +23 -0
  20. data/lib/mvcli/plugins/forms/plugins/install_form.rb +6 -0
  21. data/lib/mvcli/plugins/models/plugins/installation_model.rb +33 -0
  22. data/lib/mvcli/plugins/providers/bundle_provider.rb +116 -0
  23. data/lib/mvcli/plugins/routes.rb +3 -0
  24. data/lib/mvcli/plugins/templates/plugins/index.txt.erb +3 -0
  25. data/lib/mvcli/plugins/templates/plugins/install.txt.erb +1 -0
  26. data/lib/mvcli/plugins/templates/plugins/uninstall.txt.erb +1 -0
  27. data/lib/mvcli/provisioning.rb +48 -38
  28. data/lib/mvcli/router.rb +34 -20
  29. data/lib/mvcli/std/extensions/erb_extension.rb +24 -0
  30. data/lib/mvcli/std/providers/argv_provider.rb +9 -0
  31. data/lib/mvcli/std/providers/config_provider.rb +29 -0
  32. data/lib/mvcli/std/providers/middleware_provider.rb +12 -0
  33. data/lib/mvcli/std/providers/router_provider.rb +17 -0
  34. data/lib/mvcli/std/routes.rb +2 -0
  35. data/lib/mvcli/version.rb +1 -1
  36. data/spec/features/managing_plugins_spec.rb +29 -0
  37. data/spec/fixtures/apps/trivium/app.rb +10 -0
  38. data/spec/fixtures/apps/trivium/app/routes.rb +0 -0
  39. data/spec/fixtures/apps/trivium/bin/trivium +6 -0
  40. data/spec/fixtures/apps/trivium/lib/trivium/version.rb +3 -0
  41. data/spec/fixtures/apps/trivium/trivium.gemspec +8 -0
  42. data/spec/fixtures/bin/trivium +3 -0
  43. data/spec/fixtures/plugins/timing-plugin/app/routes.rb +1 -0
  44. data/spec/fixtures/plugins/timing-plugin/lib/trivium-timing.rb +5 -0
  45. data/spec/fixtures/plugins/timing-plugin/trivium-timing.gemspec +9 -0
  46. data/spec/mvcli/action_spec.rb +31 -0
  47. data/spec/mvcli/controller_spec.rb +35 -0
  48. data/spec/mvcli/core_spec.rb +77 -0
  49. data/spec/mvcli/cortex_spec.rb +50 -0
  50. data/spec/mvcli/erb_spec.rb +1 -1
  51. data/spec/mvcli/form_spec.rb +1 -1
  52. data/spec/mvcli/loader_spec.rb +58 -13
  53. data/spec/mvcli/middleware/exception_logger_spec.rb +3 -3
  54. data/spec/mvcli/middleware/exit_status_spec.rb +10 -10
  55. data/spec/mvcli/middleware_spec.rb +28 -45
  56. data/spec/mvcli/path_spec.rb +13 -0
  57. data/spec/mvcli/path_spec/does/exist +1 -0
  58. data/spec/mvcli/plugins/providers/bundle_provider_spec.rb +23 -0
  59. data/spec/mvcli/provisioning_spec.rb +39 -37
  60. data/spec/mvcli/router_spec.rb +26 -32
  61. data/spec/mvcli/std/extensions/erb_extension_spec.rb +34 -0
  62. data/spec/mvcli/std/providers/middleware_provider_spec.rb +10 -0
  63. data/spec/mvcli/validatable_spec.rb +12 -12
  64. data/spec/spec_helper.rb +13 -1
  65. data/spec/support/aruba_helper.rb +76 -0
  66. metadata +69 -33
  67. data/lib/mvcli/actions.rb +0 -37
  68. data/lib/mvcli/renderer.rb +0 -16
  69. data/spec/mvcli/actions_spec.rb +0 -34
  70. data/spec/mvcli/dummy/app/providers/test_provider.rb +0 -5
@@ -1,3 +1,15 @@
1
1
  require "mvcli"
2
+ require "aruba/api"
2
3
  require "rspec-given"
3
- require "rspec-spies"
4
+
5
+ Dir[Pathname(__FILE__).dirname.join("support/**/*.rb")].each { |f| require f }
6
+
7
+
8
+ RSpec.configure do |config|
9
+ Given.use_natural_assertions
10
+ config.color_enabled = true
11
+ config.treat_symbols_as_metadata_keys_with_true_values = true
12
+ config.include ArubaHelper, :example_group => {
13
+ :file_path => /spec\/features/
14
+ }
15
+ end
@@ -0,0 +1,76 @@
1
+ module ArubaHelper
2
+ include Aruba::Api
3
+
4
+ def r(command)
5
+ run_simple File.expand_path("../../fixtures/bin/#{command}", __FILE__), true, @timeout
6
+ end
7
+
8
+ def fixture(path)
9
+ Pathname(__FILE__).dirname.join('../fixtures').join path
10
+ end
11
+
12
+ def self.included(base)
13
+ base.before :each, :"disable-bundler" do
14
+ unset_bundler_env_vars
15
+ end
16
+
17
+ base.before :each do
18
+ @__aruba_original_paths = (ENV['PATH'] || '').split(File::PATH_SEPARATOR)
19
+ ENV['PATH'] = ([File.expand_path('bin')] + @__aruba_original_paths).join(File::PATH_SEPARATOR)
20
+ ENV['backtrace'] = 'true'
21
+ set_env "HOME", File.expand_path(current_dir)
22
+ end
23
+
24
+ base.after :each do
25
+ ENV['PATH'] = @__aruba_original_paths.join(File::PATH_SEPARATOR)
26
+ end
27
+
28
+ base.before :each do
29
+ FileUtils.rm_rf(current_dir) unless example.metadata[:"no-clobber"]
30
+ end
31
+
32
+ base.before :each do
33
+ @timeout = example.options[:timeout]
34
+ end
35
+
36
+ base.before :each, :puts do
37
+ @puts = true
38
+ end
39
+
40
+ base.before :each, :"announce-cmd" do
41
+ @announce_cmd = true
42
+ end
43
+
44
+ base.before :each, :"announce-dir" do
45
+ @announce_dir = true
46
+ end
47
+
48
+ base.before :each, :"announce-stdout" do
49
+ @announce_stdout = true
50
+ end
51
+
52
+ base.before :each, :"announce-stderr" do
53
+ @announce_stderr = true
54
+ end
55
+
56
+ base.before :each, :"announce-env" do
57
+ @announce_end = true
58
+ end
59
+
60
+ base.before :each, :announce do
61
+ @announce_stdout = true
62
+ @announce_stderr = true
63
+ @announce_cmd = true
64
+ @announce_dir = true
65
+ @announce_env = true
66
+ end
67
+
68
+ base.before :each, :ansi do
69
+ @aruba_keep_ansi = true
70
+ end
71
+
72
+ base.after :each do
73
+ restore_env
74
+ end
75
+ end
76
+ end
metadata CHANGED
@@ -1,35 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mvcli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Lowell
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain:
11
- - |
12
- -----BEGIN CERTIFICATE-----
13
- MIIDPjCCAiagAwIBAgIBADANBgkqhkiG9w0BAQUFADBFMRAwDgYDVQQDDAdjb3di
14
- b3lkMRwwGgYKCZImiZPyLGQBGRYMdGhlZnJvbnRzaWRlMRMwEQYKCZImiZPyLGQB
15
- GRYDbmV0MB4XDTEzMDEzMDIxMDYwNFoXDTE0MDEzMDIxMDYwNFowRTEQMA4GA1UE
16
- AwwHY293Ym95ZDEcMBoGCgmSJomT8ixkARkWDHRoZWZyb250c2lkZTETMBEGCgmS
17
- JomT8ixkARkWA25ldDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAO45
18
- CUxpETDGYXjCCy2dMg/aIrdrTqBqQW5ZrzhHxF9EkcdmWFr0z/qMz0JSpZ3pF11Z
19
- KYaj5PaQQpjZfLPwbuiGGkuSWi+UAac//V18xo6S4lzRBjO+gpzG9f2AOzt9b+SR
20
- Uc8UhO7QBZ5edUDxMxw9QstD+U0YBAlzsPJbHuUOqdtxXmNQCds3ZnqTgZaIpdUy
21
- CSejtrukSmlthxFzwgMezYQhcYxmkl+Q475JUodnI6Pjc6nja/Or8Y6cEWiLgeUa
22
- a+efcPGLDEbwJC7TGRrvk8yassMByBEJ3XueTMzeqWFd+665ptciojYo6BvIAR0N
23
- iLwks0x567FZyS8SqTcCAwEAAaM5MDcwCQYDVR0TBAIwADAdBgNVHQ4EFgQUxVgR
24
- 5TUqf7Hd24ICb3g4FNbM7oYwCwYDVR0PBAQDAgSwMA0GCSqGSIb3DQEBBQUAA4IB
25
- AQDdJj+NzZhiYXA56z0wzRUA/Fcf6CYqKB+RFRlPssDEcHTor5SnwdWgQof/gNLi
26
- Qel1Om4zO0Shcp89jxaUqtvEdYVhmyfc0vycHmemKttNBT734yMrEJtF8Hhy+Dnz
27
- 9CzixXLvgGaRH+mf3M0+l+zIDJJr2L+39L8cyTSSRnp/srfI8aSmJKhGshudBKoC
28
- Ty6Gi071pwoJXvdMaE/6iPy7bUzlndYdHyYuWSKaO9N47HqQ62oEnBraglw6ghoi
29
- UgImJlChAzCoDP9zi9tdm6jAr7ttF25R9PPYr11ILb7dYe3qUzlNlM6zJx/nb31b
30
- IhdyRVup4qLcqYSTPsm6u7VA
31
- -----END CERTIFICATE-----
32
- date: 2013-07-29 00:00:00.000000000 Z
10
+ cert_chain: []
11
+ date: 2014-05-21 00:00:00.000000000 Z
33
12
  dependencies:
34
13
  - !ruby/object:Gem::Dependency
35
14
  name: map
@@ -62,22 +41,29 @@ dependencies:
62
41
  description: MVC Framework for Building Command Line Apps
63
42
  email:
64
43
  - cowboyd@thefrontside.net
65
- executables: []
44
+ executables:
45
+ - mvcli
66
46
  extensions: []
67
47
  extra_rdoc_files: []
68
48
  files:
69
49
  - .gitignore
70
50
  - .travis.yml
51
+ - Changelog.md
71
52
  - Gemfile
72
53
  - LICENSE.txt
73
54
  - README.md
74
55
  - Rakefile
56
+ - app.rb
57
+ - app/routes.rb
58
+ - bin/mvcli
75
59
  - lib/mvcli.rb
76
- - lib/mvcli/actions.rb
60
+ - lib/mvcli/action.rb
77
61
  - lib/mvcli/app.rb
78
62
  - lib/mvcli/argv.rb
79
63
  - lib/mvcli/command.rb
80
64
  - lib/mvcli/controller.rb
65
+ - lib/mvcli/core.rb
66
+ - lib/mvcli/cortex.rb
81
67
  - lib/mvcli/decoding.rb
82
68
  - lib/mvcli/erb.rb
83
69
  - lib/mvcli/form.rb
@@ -87,16 +73,43 @@ files:
87
73
  - lib/mvcli/middleware/exception_logger.rb
88
74
  - lib/mvcli/middleware/exception_logger/validation_summary.rb
89
75
  - lib/mvcli/middleware/exit_status.rb
76
+ - lib/mvcli/path.rb
77
+ - lib/mvcli/plugins.rb
78
+ - lib/mvcli/plugins/controllers/plugins_controller.rb
79
+ - lib/mvcli/plugins/forms/plugins/install_form.rb
80
+ - lib/mvcli/plugins/models/plugins/installation_model.rb
81
+ - lib/mvcli/plugins/providers/bundle_provider.rb
82
+ - lib/mvcli/plugins/routes.rb
83
+ - lib/mvcli/plugins/templates/plugins/index.txt.erb
84
+ - lib/mvcli/plugins/templates/plugins/install.txt.erb
85
+ - lib/mvcli/plugins/templates/plugins/uninstall.txt.erb
90
86
  - lib/mvcli/provisioning.rb
91
- - lib/mvcli/renderer.rb
92
87
  - lib/mvcli/router.rb
93
88
  - lib/mvcli/router/pattern.rb
89
+ - lib/mvcli/std/extensions/erb_extension.rb
90
+ - lib/mvcli/std/providers/argv_provider.rb
91
+ - lib/mvcli/std/providers/config_provider.rb
92
+ - lib/mvcli/std/providers/middleware_provider.rb
93
+ - lib/mvcli/std/providers/router_provider.rb
94
+ - lib/mvcli/std/routes.rb
94
95
  - lib/mvcli/validatable.rb
95
96
  - lib/mvcli/version.rb
96
97
  - mvcli.gemspec
97
- - spec/mvcli/actions_spec.rb
98
+ - spec/features/managing_plugins_spec.rb
99
+ - spec/fixtures/apps/trivium/app.rb
100
+ - spec/fixtures/apps/trivium/app/routes.rb
101
+ - spec/fixtures/apps/trivium/bin/trivium
102
+ - spec/fixtures/apps/trivium/lib/trivium/version.rb
103
+ - spec/fixtures/apps/trivium/trivium.gemspec
104
+ - spec/fixtures/bin/trivium
105
+ - spec/fixtures/plugins/timing-plugin/app/routes.rb
106
+ - spec/fixtures/plugins/timing-plugin/lib/trivium-timing.rb
107
+ - spec/fixtures/plugins/timing-plugin/trivium-timing.gemspec
108
+ - spec/mvcli/action_spec.rb
98
109
  - spec/mvcli/argv_spec.rb
99
- - spec/mvcli/dummy/app/providers/test_provider.rb
110
+ - spec/mvcli/controller_spec.rb
111
+ - spec/mvcli/core_spec.rb
112
+ - spec/mvcli/cortex_spec.rb
100
113
  - spec/mvcli/erb_spec.rb
101
114
  - spec/mvcli/form/input_spec.rb
102
115
  - spec/mvcli/form_spec.rb
@@ -105,11 +118,17 @@ files:
105
118
  - spec/mvcli/middleware/exception_logger_spec.rb
106
119
  - spec/mvcli/middleware/exit_status_spec.rb
107
120
  - spec/mvcli/middleware_spec.rb
121
+ - spec/mvcli/path_spec.rb
122
+ - spec/mvcli/path_spec/does/exist
123
+ - spec/mvcli/plugins/providers/bundle_provider_spec.rb
108
124
  - spec/mvcli/provisioning_spec.rb
109
125
  - spec/mvcli/router/pattern_spec.rb
110
126
  - spec/mvcli/router_spec.rb
127
+ - spec/mvcli/std/extensions/erb_extension_spec.rb
128
+ - spec/mvcli/std/providers/middleware_provider_spec.rb
111
129
  - spec/mvcli/validatable_spec.rb
112
130
  - spec/spec_helper.rb
131
+ - spec/support/aruba_helper.rb
113
132
  homepage: https://github.com/cowboyd/mvcli
114
133
  licenses:
115
134
  - MIT
@@ -130,14 +149,26 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
149
  version: '0'
131
150
  requirements: []
132
151
  rubyforge_project:
133
- rubygems_version: 2.0.0
152
+ rubygems_version: 2.0.3
134
153
  signing_key:
135
154
  specification_version: 4
136
155
  summary: Local Apps. Remote Apps. They're all at your fingertips
137
156
  test_files:
138
- - spec/mvcli/actions_spec.rb
157
+ - spec/features/managing_plugins_spec.rb
158
+ - spec/fixtures/apps/trivium/app.rb
159
+ - spec/fixtures/apps/trivium/app/routes.rb
160
+ - spec/fixtures/apps/trivium/bin/trivium
161
+ - spec/fixtures/apps/trivium/lib/trivium/version.rb
162
+ - spec/fixtures/apps/trivium/trivium.gemspec
163
+ - spec/fixtures/bin/trivium
164
+ - spec/fixtures/plugins/timing-plugin/app/routes.rb
165
+ - spec/fixtures/plugins/timing-plugin/lib/trivium-timing.rb
166
+ - spec/fixtures/plugins/timing-plugin/trivium-timing.gemspec
167
+ - spec/mvcli/action_spec.rb
139
168
  - spec/mvcli/argv_spec.rb
140
- - spec/mvcli/dummy/app/providers/test_provider.rb
169
+ - spec/mvcli/controller_spec.rb
170
+ - spec/mvcli/core_spec.rb
171
+ - spec/mvcli/cortex_spec.rb
141
172
  - spec/mvcli/erb_spec.rb
142
173
  - spec/mvcli/form/input_spec.rb
143
174
  - spec/mvcli/form_spec.rb
@@ -146,9 +177,14 @@ test_files:
146
177
  - spec/mvcli/middleware/exception_logger_spec.rb
147
178
  - spec/mvcli/middleware/exit_status_spec.rb
148
179
  - spec/mvcli/middleware_spec.rb
180
+ - spec/mvcli/path_spec.rb
181
+ - spec/mvcli/path_spec/does/exist
182
+ - spec/mvcli/plugins/providers/bundle_provider_spec.rb
149
183
  - spec/mvcli/provisioning_spec.rb
150
184
  - spec/mvcli/router/pattern_spec.rb
151
185
  - spec/mvcli/router_spec.rb
186
+ - spec/mvcli/std/extensions/erb_extension_spec.rb
187
+ - spec/mvcli/std/providers/middleware_provider_spec.rb
152
188
  - spec/mvcli/validatable_spec.rb
153
189
  - spec/spec_helper.rb
154
- has_rdoc:
190
+ - spec/support/aruba_helper.rb
@@ -1,37 +0,0 @@
1
- require "map"
2
- require "mvcli/controller"
3
- require "mvcli/form"
4
- require_relative "loader"
5
- require_relative "renderer"
6
-
7
- module MVCLI
8
- class Actions
9
- def initialize(root, loader = Loader.new, renderer = nil)
10
- @loader = loader
11
- @renderer = renderer || Renderer.new(root)
12
- end
13
-
14
- def [](key)
15
- return key if key.respond_to?(:call)
16
- controller, method = key.split('#')
17
- Action.new @loader, @renderer, controller, method
18
- end
19
-
20
- class Action
21
- def initialize(loader, renderer, controller, method)
22
- @loader = loader
23
- @renderer = renderer
24
- @controller = controller
25
- @method = method
26
- end
27
-
28
- def call(command, bindings = Map.new)
29
- controller = @loader.load :controller, @controller, bindings
30
- context = controller.send @method
31
- path = [@controller, @method].join('/')
32
- @renderer.render command.output, path, context
33
- return 0
34
- end
35
- end
36
- end
37
- end
@@ -1,16 +0,0 @@
1
- require 'mvcli/erb'
2
-
3
- module MVCLI
4
- class Renderer
5
- def initialize(root)
6
- @root = root
7
- end
8
-
9
- def render(output, path, context)
10
- filename = @root.join('app/views', path + '.txt.erb').to_s
11
- compiler = MVCLI::ERB.new
12
- template = compiler.compile File.read(filename), filename
13
- template.call(context, output)
14
- end
15
- end
16
- end
@@ -1,34 +0,0 @@
1
- require "spec_helper"
2
- require "mvcli/actions"
3
-
4
- describe "MVCLI::Actions" do
5
- Given(:loader) {mock(:Loader)}
6
- Given(:renderer) {mock(:Renderer, :render => true)}
7
- Given(:actions) {MVCLI::Actions.new '/root', loader, renderer}
8
-
9
- context "when the loader cannot find an appropriate controller" do
10
- Given {loader.stub(:load) {fail LoadError}}
11
- When(:action) {actions['foo']}
12
- Then {action.should_not be_nil}
13
-
14
- context ".calling it" do
15
- When(:result) {action.call(mock(:Command))}
16
- Then {result.should have_failed LoadError}
17
- end
18
- end
19
-
20
- context "when the class exists" do
21
- Given(:output) {mock(:Output)}
22
- Given(:controller) {mock(:Controller)}
23
- Given {loader.stub(:load).with(:controller, 'foo', {}) {controller}}
24
- Given {controller.stub(:bar) {"the context"}}
25
- When {actions['foo#bar'].call(mock(:Command, :output => output), {})}
26
- Then {controller.should have_received(:bar)}
27
- And {renderer.should have_received(:render).with(output, 'foo/bar', 'the context')}
28
- end
29
-
30
- context "when the action is callable" do
31
- Given(:app) { ->(c) {} }
32
- Then { actions[app] == app }
33
- end
34
- end
@@ -1,5 +0,0 @@
1
- class TestProvider
2
- def value
3
- "here is a free value just for you!!"
4
- end
5
- end