hexx 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -1
- data/README.rdoc +77 -181
- data/Rakefile +7 -21
- data/lib/hexx/models/base_coercer.rb +36 -0
- data/lib/hexx/models.rb +12 -57
- data/lib/hexx/service/invalid.rb +48 -0
- data/lib/hexx/service/message.rb +57 -0
- data/lib/hexx/service/messages.rb +34 -0
- data/lib/hexx/service/parameters.rb +45 -0
- data/lib/hexx/service/transactions.rb +30 -0
- data/lib/hexx/service/validations.rb +18 -0
- data/lib/hexx/service.rb +21 -0
- data/lib/hexx/version.rb +2 -2
- data/lib/hexx.rb +8 -2
- data/spec/hexx/models_spec.rb +6 -9
- data/spec/hexx/service/invalid_spec.rb +51 -0
- data/spec/hexx/service/message_spec.rb +99 -0
- data/spec/hexx/service_spec.rb +183 -0
- data/spec/{support/initializers → initializers}/coveralls.rb +0 -0
- data/spec/{support/initializers → initializers}/focus.rb +0 -0
- data/spec/{support/initializers → initializers}/garbage_collection.rb +0 -0
- data/spec/{support/initializers → initializers}/i18n.rb +2 -0
- data/spec/{support/initializers → initializers}/random_order.rb +0 -0
- data/spec/{support/initializers → initializers}/rspec.rb +0 -0
- data/spec/spec_helper.rb +3 -5
- metadata +31 -117
- data/CHANGELOG.rdoc +0 -12
- data/bin/hexx +0 -54
- data/lib/generators/base.rb +0 -59
- data/lib/generators/controller/controller.rb +0 -114
- data/lib/generators/controller/templates/controller.erb +0 -10
- data/lib/generators/controller/templates/controller_action.erb +0 -7
- data/lib/generators/controller/templates/controller_action_spec.erb +0 -21
- data/lib/generators/controller/templates/controller_spec.erb +0 -20
- data/lib/generators/controller/templates/responder_controller.erb +0 -40
- data/lib/generators/controller/templates/responder_controller_spec.erb +0 -65
- data/lib/generators/controller/templates/routing_action_spec.erb +0 -13
- data/lib/generators/controller/templates/routing_spec.erb +0 -11
- data/lib/generators/controller/templates/views_errors.erb +0 -3
- data/lib/generators/controller/templates/views_messages.erb +0 -3
- data/lib/generators/dependency/dependency.rb +0 -50
- data/lib/generators/dependency/templates/dependency_setting.erb +0 -4
- data/lib/generators/dependency/templates/dependency_setting_spec.erb +0 -39
- data/lib/generators/dependency/templates/initializer.erb +0 -4
- data/lib/generators/dependency/templates/initializer_setting.erb +0 -4
- data/lib/generators/dependency/templates/module_spec.erb +0 -22
- data/lib/generators/domain/domain.rb +0 -24
- data/lib/generators/domain/templates/spec.erb +0 -84
- data/lib/generators/install/install.rb +0 -133
- data/lib/generators/install/templates/bin/rails.erb +0 -11
- data/lib/generators/install/templates/config/routes.erb +0 -6
- data/lib/generators/install/templates/json_schemas/error.erb +0 -14
- data/lib/generators/install/templates/json_schemas/get_errors.erb +0 -18
- data/lib/generators/install/templates/json_schemas/success.erb +0 -14
- data/lib/generators/install/templates/lib/engine.erb +0 -12
- data/lib/generators/install/templates/lib/lib.erb +0 -10
- data/lib/generators/install/templates/lib/task.erb +0 -60
- data/lib/generators/install/templates/lib/version.erb +0 -4
- data/lib/generators/install/templates/matchers/controllers.erb +0 -14
- data/lib/generators/install/templates/matchers/json_schema.erb +0 -10
- data/lib/generators/install/templates/root/Gemfile.erb +0 -9
- data/lib/generators/install/templates/root/Guardfile.erb +0 -14
- data/lib/generators/install/templates/root/LICENSE.erb +0 -21
- data/lib/generators/install/templates/root/README.erb +0 -68
- data/lib/generators/install/templates/root/Rakefile.erb +0 -45
- data/lib/generators/install/templates/root/coveralls.erb +0 -1
- data/lib/generators/install/templates/root/gemspec.erb +0 -33
- data/lib/generators/install/templates/root/gitignore.erb +0 -28
- data/lib/generators/install/templates/root/rspec.erb +0 -1
- data/lib/generators/install/templates/root/rubocop.erb +0 -65
- data/lib/generators/install/templates/root/travis.erb +0 -3
- data/lib/generators/install/templates/spec/caching.erb +0 -12
- data/lib/generators/install/templates/spec/coveralls.erb +0 -4
- data/lib/generators/install/templates/spec/database_cleaner.erb +0 -28
- data/lib/generators/install/templates/spec/factory_girl_rails.erb +0 -5
- data/lib/generators/install/templates/spec/focus.erb +0 -5
- data/lib/generators/install/templates/spec/garbage_collection.erb +0 -11
- data/lib/generators/install/templates/spec/i18n.erb +0 -1
- data/lib/generators/install/templates/spec/migrations.erb +0 -3
- data/lib/generators/install/templates/spec/rails.erb +0 -6
- data/lib/generators/install/templates/spec/random_order.erb +0 -4
- data/lib/generators/install/templates/spec/rspec.erb +0 -10
- data/lib/generators/install/templates/spec/spec_helper.erb +0 -9
- data/lib/generators/install/templates/spec/timecop.erb +0 -1
- data/lib/generators/request/request.rb +0 -52
- data/lib/generators/request/templates/request_spec.erb +0 -66
- data/lib/generators/use_case/templates/use_case.erb +0 -54
- data/lib/generators/use_case/templates/use_case_spec.erb +0 -74
- data/lib/generators/use_case/use_case.rb +0 -31
- data/lib/hexx/exceptions/not_found_error.rb +0 -18
- data/lib/hexx/exceptions/runtime_error.rb +0 -27
- data/lib/hexx/exceptions/use_case_invalid.rb +0 -18
- data/lib/hexx/message.rb +0 -20
- data/lib/hexx/settings.rb +0 -47
- data/lib/hexx/use_case.rb +0 -256
- data/spec/hexx/exceptions/not_found_error_spec.rb +0 -21
- data/spec/hexx/exceptions/runtime_error_spec.rb +0 -43
- data/spec/hexx/exceptions/use_case_invalid_spec.rb +0 -21
- data/spec/hexx/message_spec.rb +0 -31
- data/spec/hexx/settings_spec.rb +0 -51
- data/spec/hexx/use_case_spec.rb +0 -274
- data/spec/support/exception_matchers.rb +0 -7
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hexx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kozin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.1'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: extlib
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.9'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0.9'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: wisper
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,108 +122,40 @@ dependencies:
|
|
136
122
|
- - "~>"
|
137
123
|
- !ruby/object:Gem::Version
|
138
124
|
version: '4.11'
|
139
|
-
description:
|
140
|
-
Rails controllers.
|
125
|
+
description: Defines domain service object and model attributes coercion.
|
141
126
|
email: andrew.kozin@gmail.com
|
142
|
-
executables:
|
143
|
-
- hexx
|
127
|
+
executables: []
|
144
128
|
extensions: []
|
145
129
|
extra_rdoc_files:
|
146
|
-
- CHANGELOG.rdoc
|
147
130
|
- LICENSE.rdoc
|
148
131
|
- README.rdoc
|
149
132
|
files:
|
150
133
|
- ".rubocop.yml"
|
151
|
-
- CHANGELOG.rdoc
|
152
134
|
- LICENSE.rdoc
|
153
135
|
- README.rdoc
|
154
136
|
- Rakefile
|
155
|
-
- bin/hexx
|
156
|
-
- lib/generators/base.rb
|
157
|
-
- lib/generators/controller/controller.rb
|
158
|
-
- lib/generators/controller/templates/controller.erb
|
159
|
-
- lib/generators/controller/templates/controller_action.erb
|
160
|
-
- lib/generators/controller/templates/controller_action_spec.erb
|
161
|
-
- lib/generators/controller/templates/controller_spec.erb
|
162
|
-
- lib/generators/controller/templates/responder_controller.erb
|
163
|
-
- lib/generators/controller/templates/responder_controller_spec.erb
|
164
|
-
- lib/generators/controller/templates/routing_action_spec.erb
|
165
|
-
- lib/generators/controller/templates/routing_spec.erb
|
166
|
-
- lib/generators/controller/templates/views_errors.erb
|
167
|
-
- lib/generators/controller/templates/views_messages.erb
|
168
|
-
- lib/generators/dependency/dependency.rb
|
169
|
-
- lib/generators/dependency/templates/dependency_setting.erb
|
170
|
-
- lib/generators/dependency/templates/dependency_setting_spec.erb
|
171
|
-
- lib/generators/dependency/templates/initializer.erb
|
172
|
-
- lib/generators/dependency/templates/initializer_setting.erb
|
173
|
-
- lib/generators/dependency/templates/module_spec.erb
|
174
|
-
- lib/generators/domain/domain.rb
|
175
|
-
- lib/generators/domain/templates/spec.erb
|
176
|
-
- lib/generators/install/install.rb
|
177
|
-
- lib/generators/install/templates/bin/rails.erb
|
178
|
-
- lib/generators/install/templates/config/routes.erb
|
179
|
-
- lib/generators/install/templates/json_schemas/error.erb
|
180
|
-
- lib/generators/install/templates/json_schemas/get_errors.erb
|
181
|
-
- lib/generators/install/templates/json_schemas/success.erb
|
182
|
-
- lib/generators/install/templates/lib/engine.erb
|
183
|
-
- lib/generators/install/templates/lib/lib.erb
|
184
|
-
- lib/generators/install/templates/lib/task.erb
|
185
|
-
- lib/generators/install/templates/lib/version.erb
|
186
|
-
- lib/generators/install/templates/matchers/controllers.erb
|
187
|
-
- lib/generators/install/templates/matchers/json_schema.erb
|
188
|
-
- lib/generators/install/templates/root/Gemfile.erb
|
189
|
-
- lib/generators/install/templates/root/Guardfile.erb
|
190
|
-
- lib/generators/install/templates/root/LICENSE.erb
|
191
|
-
- lib/generators/install/templates/root/README.erb
|
192
|
-
- lib/generators/install/templates/root/Rakefile.erb
|
193
|
-
- lib/generators/install/templates/root/coveralls.erb
|
194
|
-
- lib/generators/install/templates/root/gemspec.erb
|
195
|
-
- lib/generators/install/templates/root/gitignore.erb
|
196
|
-
- lib/generators/install/templates/root/rspec.erb
|
197
|
-
- lib/generators/install/templates/root/rubocop.erb
|
198
|
-
- lib/generators/install/templates/root/travis.erb
|
199
|
-
- lib/generators/install/templates/spec/caching.erb
|
200
|
-
- lib/generators/install/templates/spec/coveralls.erb
|
201
|
-
- lib/generators/install/templates/spec/database_cleaner.erb
|
202
|
-
- lib/generators/install/templates/spec/factory_girl_rails.erb
|
203
|
-
- lib/generators/install/templates/spec/focus.erb
|
204
|
-
- lib/generators/install/templates/spec/garbage_collection.erb
|
205
|
-
- lib/generators/install/templates/spec/i18n.erb
|
206
|
-
- lib/generators/install/templates/spec/migrations.erb
|
207
|
-
- lib/generators/install/templates/spec/rails.erb
|
208
|
-
- lib/generators/install/templates/spec/random_order.erb
|
209
|
-
- lib/generators/install/templates/spec/rspec.erb
|
210
|
-
- lib/generators/install/templates/spec/spec_helper.erb
|
211
|
-
- lib/generators/install/templates/spec/timecop.erb
|
212
|
-
- lib/generators/request/request.rb
|
213
|
-
- lib/generators/request/templates/request_spec.erb
|
214
|
-
- lib/generators/use_case/templates/use_case.erb
|
215
|
-
- lib/generators/use_case/templates/use_case_spec.erb
|
216
|
-
- lib/generators/use_case/use_case.rb
|
217
137
|
- lib/hexx.rb
|
218
|
-
- lib/hexx/exceptions/not_found_error.rb
|
219
|
-
- lib/hexx/exceptions/runtime_error.rb
|
220
|
-
- lib/hexx/exceptions/use_case_invalid.rb
|
221
|
-
- lib/hexx/message.rb
|
222
138
|
- lib/hexx/models.rb
|
223
|
-
- lib/hexx/
|
224
|
-
- lib/hexx/
|
139
|
+
- lib/hexx/models/base_coercer.rb
|
140
|
+
- lib/hexx/service.rb
|
141
|
+
- lib/hexx/service/invalid.rb
|
142
|
+
- lib/hexx/service/message.rb
|
143
|
+
- lib/hexx/service/messages.rb
|
144
|
+
- lib/hexx/service/parameters.rb
|
145
|
+
- lib/hexx/service/transactions.rb
|
146
|
+
- lib/hexx/service/validations.rb
|
225
147
|
- lib/hexx/version.rb
|
226
|
-
- spec/hexx/exceptions/not_found_error_spec.rb
|
227
|
-
- spec/hexx/exceptions/runtime_error_spec.rb
|
228
|
-
- spec/hexx/exceptions/use_case_invalid_spec.rb
|
229
|
-
- spec/hexx/message_spec.rb
|
230
148
|
- spec/hexx/models_spec.rb
|
231
|
-
- spec/hexx/
|
232
|
-
- spec/hexx/
|
149
|
+
- spec/hexx/service/invalid_spec.rb
|
150
|
+
- spec/hexx/service/message_spec.rb
|
151
|
+
- spec/hexx/service_spec.rb
|
152
|
+
- spec/initializers/coveralls.rb
|
153
|
+
- spec/initializers/focus.rb
|
154
|
+
- spec/initializers/garbage_collection.rb
|
155
|
+
- spec/initializers/i18n.rb
|
156
|
+
- spec/initializers/random_order.rb
|
157
|
+
- spec/initializers/rspec.rb
|
233
158
|
- spec/spec_helper.rb
|
234
|
-
- spec/support/exception_matchers.rb
|
235
|
-
- spec/support/initializers/coveralls.rb
|
236
|
-
- spec/support/initializers/focus.rb
|
237
|
-
- spec/support/initializers/garbage_collection.rb
|
238
|
-
- spec/support/initializers/i18n.rb
|
239
|
-
- spec/support/initializers/random_order.rb
|
240
|
-
- spec/support/initializers/rspec.rb
|
241
159
|
homepage: https://github.com/nepalez/hexx
|
242
160
|
licenses:
|
243
161
|
- MIT
|
@@ -261,23 +179,19 @@ rubyforge_project:
|
|
261
179
|
rubygems_version: 2.2.2
|
262
180
|
signing_key:
|
263
181
|
specification_version: 4
|
264
|
-
summary:
|
182
|
+
summary: Service objects for Rails.
|
265
183
|
test_files:
|
266
184
|
- spec/spec_helper.rb
|
267
|
-
- spec/hexx/
|
268
|
-
- spec/hexx/
|
269
|
-
- spec/hexx/
|
270
|
-
- spec/hexx/exceptions/use_case_invalid_spec.rb
|
271
|
-
- spec/hexx/exceptions/runtime_error_spec.rb
|
185
|
+
- spec/hexx/service_spec.rb
|
186
|
+
- spec/hexx/service/message_spec.rb
|
187
|
+
- spec/hexx/service/invalid_spec.rb
|
272
188
|
- spec/hexx/models_spec.rb
|
273
|
-
- spec/
|
274
|
-
- spec/
|
275
|
-
- spec/
|
276
|
-
- spec/
|
277
|
-
- spec/
|
278
|
-
- spec/
|
279
|
-
- spec/support/initializers/random_order.rb
|
280
|
-
- spec/support/initializers/rspec.rb
|
189
|
+
- spec/initializers/garbage_collection.rb
|
190
|
+
- spec/initializers/i18n.rb
|
191
|
+
- spec/initializers/focus.rb
|
192
|
+
- spec/initializers/coveralls.rb
|
193
|
+
- spec/initializers/random_order.rb
|
194
|
+
- spec/initializers/rspec.rb
|
281
195
|
- Rakefile
|
282
196
|
- ".rubocop.yml"
|
283
197
|
has_rdoc:
|
data/CHANGELOG.rdoc
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
= CHANGELOG
|
2
|
-
|
3
|
-
== 0.1.0 (28.09.2014)
|
4
|
-
|
5
|
-
=== Changed features:
|
6
|
-
|
7
|
-
* `install` generator refactored for usage of json_schema in requests specs:
|
8
|
-
- `json_schema` matchers added to support
|
9
|
-
- `request` matchers removed from support
|
10
|
-
- `controllers` matchers refactored
|
11
|
-
|
12
|
-
* `controller` generator refactored
|
data/bin/hexx
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require "thor"
|
3
|
-
require "rubygems"
|
4
|
-
|
5
|
-
root = File.dirname File.dirname(__FILE__)
|
6
|
-
Dir[File.join(root, "lib/generators/**/*.rb")].each { |file| require file }
|
7
|
-
|
8
|
-
# Scaffold tasks for the Hexx based projects.
|
9
|
-
class HexxRunner < Thor
|
10
|
-
|
11
|
-
desc "install", "scaffolds a new project"
|
12
|
-
def install
|
13
|
-
script = Hexx::Generators::Install.new [project]
|
14
|
-
script.invoke_all
|
15
|
-
end
|
16
|
-
|
17
|
-
desc "request", "scaffolds a new request spec (acceptance test)"
|
18
|
-
def request(name)
|
19
|
-
script = Hexx::Generators::Request.new [project, name]
|
20
|
-
script.invoke_all
|
21
|
-
end
|
22
|
-
|
23
|
-
desc "controller", "scaffolds a new route with a controller action"
|
24
|
-
def controller(name, route, usecase)
|
25
|
-
script = Hexx::Generators::Controller.new [project, name, route, usecase]
|
26
|
-
script.invoke_all
|
27
|
-
end
|
28
|
-
|
29
|
-
desc "domain", "scaffolds a new acceptance test for the domain"
|
30
|
-
def domain(name)
|
31
|
-
script = Hexx::Generators::Domain.new [project, name]
|
32
|
-
script.invoke_all
|
33
|
-
end
|
34
|
-
|
35
|
-
desc "use_case", "scaffolds a new use case"
|
36
|
-
def use_case(name)
|
37
|
-
script = Hexx::Generators::UseCase.new [project, name]
|
38
|
-
script.invoke_all
|
39
|
-
end
|
40
|
-
|
41
|
-
desc "depencency", "scaffolds a dependency"
|
42
|
-
def dependency(name)
|
43
|
-
script = Hexx::Generators::Dependency.new [project, name]
|
44
|
-
script.invoke_all
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def project
|
50
|
-
Dir.getwd.split("/").last.to_s.downcase
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
HexxRunner.start
|
data/lib/generators/base.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
require "thor"
|
2
|
-
require "extlib"
|
3
|
-
|
4
|
-
module Hexx
|
5
|
-
module Generators
|
6
|
-
|
7
|
-
# Base class for scaffolders.
|
8
|
-
class Base < Thor::Group
|
9
|
-
include Thor::Actions
|
10
|
-
|
11
|
-
argument :project
|
12
|
-
argument :name
|
13
|
-
|
14
|
-
def self.source_root(file = __FILE__)
|
15
|
-
root = File.dirname File.expand_path(file)
|
16
|
-
@source_root ||= File.join(root, "templates")
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def gem_name
|
22
|
-
@gem_name ||= project.snake_case
|
23
|
-
end
|
24
|
-
|
25
|
-
def module_name
|
26
|
-
@module_name ||= project.camel_case
|
27
|
-
end
|
28
|
-
|
29
|
-
def class_name
|
30
|
-
@class_name ||= name.camel_case
|
31
|
-
end
|
32
|
-
|
33
|
-
def file_name
|
34
|
-
@file_name ||= name.snake_case
|
35
|
-
end
|
36
|
-
|
37
|
-
def action_type(string)
|
38
|
-
return @action_type if @action_type
|
39
|
-
list = string.split(":")
|
40
|
-
list.count > 1 ? list.first.downcase : "get"
|
41
|
-
end
|
42
|
-
|
43
|
-
def action_name(string)
|
44
|
-
string.split(":").last.downcase
|
45
|
-
end
|
46
|
-
|
47
|
-
def inject_template_into_file(source, file, options)
|
48
|
-
source = File.expand_path(find_in_source_paths(source.to_s))
|
49
|
-
context = instance_eval("binding")
|
50
|
-
content = ERB.new(::File.binread(source), nil, "-", "@output_buffer")
|
51
|
-
.result(context)
|
52
|
-
|
53
|
-
inject_into_file file, options do
|
54
|
-
content
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,114 +0,0 @@
|
|
1
|
-
require_relative "../base"
|
2
|
-
|
3
|
-
module Hexx
|
4
|
-
module Generators
|
5
|
-
|
6
|
-
# Scaffolds rails controller action and a corresponding route spec.
|
7
|
-
class Controller < Base
|
8
|
-
|
9
|
-
argument :route
|
10
|
-
argument :usecase
|
11
|
-
|
12
|
-
def self.source_root
|
13
|
-
super __FILE__
|
14
|
-
end
|
15
|
-
|
16
|
-
def create_routing_spec
|
17
|
-
template(
|
18
|
-
"routing_spec.erb",
|
19
|
-
"spec/routing/#{api_path}/#{file_name}_routing_spec.rb",
|
20
|
-
skip: true
|
21
|
-
)
|
22
|
-
end
|
23
|
-
|
24
|
-
def add_route_spec
|
25
|
-
inject_template_into_file(
|
26
|
-
"routing_action_spec.erb",
|
27
|
-
"spec/routing/#{api_path}/#{file_name}_routing_spec.rb",
|
28
|
-
before: " end\nend"
|
29
|
-
)
|
30
|
-
end
|
31
|
-
|
32
|
-
def create_responder_controller_spec
|
33
|
-
template(
|
34
|
-
"responder_controller_spec.erb",
|
35
|
-
"spec/controllers/#{api_path}/responder_controller_spec.rb",
|
36
|
-
skip: true
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
def create_responder_controller
|
41
|
-
template(
|
42
|
-
"responder_controller.erb",
|
43
|
-
"app/controllers/#{api_path}/responder_controller.rb",
|
44
|
-
skip: true
|
45
|
-
)
|
46
|
-
end
|
47
|
-
|
48
|
-
def create_controller_spec
|
49
|
-
template(
|
50
|
-
"controller_spec.erb",
|
51
|
-
"spec/controllers/#{api_path}/#{file_name}_controller_spec.rb",
|
52
|
-
skip: true
|
53
|
-
)
|
54
|
-
end
|
55
|
-
|
56
|
-
def add_controller_action_spec
|
57
|
-
inject_template_into_file(
|
58
|
-
"controller_action_spec.erb",
|
59
|
-
"spec/controllers/#{api_path}/#{file_name}_controller_spec.rb",
|
60
|
-
before: "\n end"
|
61
|
-
)
|
62
|
-
end
|
63
|
-
|
64
|
-
def create_controller
|
65
|
-
template(
|
66
|
-
"controller.erb",
|
67
|
-
"app/controllers/#{api_path}/#{file_name}_controller.rb",
|
68
|
-
skip: true
|
69
|
-
)
|
70
|
-
end
|
71
|
-
|
72
|
-
def add_controller_action
|
73
|
-
inject_template_into_file(
|
74
|
-
"controller_action.erb",
|
75
|
-
"app/controllers/#{api_path}/#{file_name}_controller.rb",
|
76
|
-
before: "\n end"
|
77
|
-
)
|
78
|
-
end
|
79
|
-
|
80
|
-
def create_views
|
81
|
-
dir = "app/views/#{api_path}/#{file_name}"
|
82
|
-
run "mkdir #{dir} -p -v"
|
83
|
-
template "views_errors.erb", "#{ dir }/errors.json.jbuilder", skip: true
|
84
|
-
template(
|
85
|
-
"views_messages.erb", "#{ dir }/_messages.json.jbuilder", skip: true
|
86
|
-
)
|
87
|
-
create_file "#{ dir }/#{action_name}.json.jbuilder", skip: true
|
88
|
-
create_file "#{ dir }/_#{class_name.downcase}.json.jbuilder", skip: true
|
89
|
-
end
|
90
|
-
|
91
|
-
private
|
92
|
-
|
93
|
-
def action_type
|
94
|
-
@action_type ||= super route
|
95
|
-
end
|
96
|
-
|
97
|
-
def action_name
|
98
|
-
@action_name ||= super route
|
99
|
-
end
|
100
|
-
|
101
|
-
def use_case
|
102
|
-
@use_case ||= usecase.camel_case
|
103
|
-
end
|
104
|
-
|
105
|
-
def use_case_file
|
106
|
-
@use_case_file ||= usecase.snake_case
|
107
|
-
end
|
108
|
-
|
109
|
-
def api_path
|
110
|
-
"#{ gem_name }/api/v1"
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
|
2
|
-
# describe "#<%= action_name %>" do
|
3
|
-
|
4
|
-
# let!(:params) { { "something" => "something", "wrong" => "wrong" } }
|
5
|
-
|
6
|
-
# before { allow(<%= use_case %>).to receive(:new).and_return(use_case) }
|
7
|
-
# after { <%= action_type %> :<%= action_name %>, params }
|
8
|
-
|
9
|
-
# it "sets use case with proper parameters" do
|
10
|
-
# expect(<%= use_case %>).to receive(:new)
|
11
|
-
# .with params.slice("something")
|
12
|
-
# end
|
13
|
-
|
14
|
-
# it "listens to the case" do
|
15
|
-
# expect(controller).to listen_to use_case
|
16
|
-
# end
|
17
|
-
|
18
|
-
# it "runs the case after subscribtions" do
|
19
|
-
# expect(use_case).to run_after_subscriptions
|
20
|
-
# end
|
21
|
-
# end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
module <%= module_name %>
|
4
|
-
module Api
|
5
|
-
module V1
|
6
|
-
describe <%= class_name %>Controller do
|
7
|
-
|
8
|
-
# Add this line if your project is a Rails Engine, not the Application
|
9
|
-
# routes { <%= module_name %>::Engine.routes }
|
10
|
-
|
11
|
-
# let(:use_case) { double "use_case" }
|
12
|
-
|
13
|
-
# before do
|
14
|
-
# allow(use_case).to receive(:subscribe)
|
15
|
-
# allow(use_case).to receive(:run) { controller.render inline: "" }
|
16
|
-
# end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module <%= module_name %>
|
2
|
-
|
3
|
-
# Namespace for public JSON API.
|
4
|
-
module Api
|
5
|
-
|
6
|
-
# Namespace for API v.1
|
7
|
-
module V1
|
8
|
-
|
9
|
-
# Responds to the client depending of use case result.
|
10
|
-
class ResponderController < ApplicationController
|
11
|
-
|
12
|
-
# # Renders an error messages.
|
13
|
-
# #
|
14
|
-
# # Params:
|
15
|
-
# # +messages+:: a list of messages (<tt>Hexx::Message</tt> objects)
|
16
|
-
# # to be shown to a client.
|
17
|
-
# #
|
18
|
-
# def on_error(messages, status: 400)
|
19
|
-
# @messages = messages
|
20
|
-
# render "error", status: status
|
21
|
-
# end
|
22
|
-
|
23
|
-
# # Renders an error messages and responds with 404 (Not found).
|
24
|
-
# #
|
25
|
-
# # Params:
|
26
|
-
# # +messages+:: a list of messages (<tt>Hexx::Message</tt> objects)
|
27
|
-
# # to be shown to a client.
|
28
|
-
# #
|
29
|
-
# def on_not_found(messages)
|
30
|
-
# on_error messages, status: 404
|
31
|
-
# end
|
32
|
-
|
33
|
-
# # Responds with 304 (Not changed).
|
34
|
-
# def on_not_changed
|
35
|
-
# render status: 304
|
36
|
-
# end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
module <%= module_name %>
|
4
|
-
module Api
|
5
|
-
module V1
|
6
|
-
describe ResponderController do
|
7
|
-
|
8
|
-
# Add this line if your project is a Rails Engine, not the Application
|
9
|
-
# routes { <%= module_name %>::Engine.routes }
|
10
|
-
|
11
|
-
# describe "#on_not_changed" do
|
12
|
-
|
13
|
-
# controller(<%= class_name %>Controller) do
|
14
|
-
# def index; on_not_changed; end
|
15
|
-
# end
|
16
|
-
# before { get :index, format: :json }
|
17
|
-
|
18
|
-
# it "responds with 304" do
|
19
|
-
# expect(response.status).to eq 304
|
20
|
-
# end
|
21
|
-
# end
|
22
|
-
|
23
|
-
# describe "#on_error" do
|
24
|
-
|
25
|
-
# controller(<%= class_name %>Controller) do
|
26
|
-
# def index; on_error :messages; end
|
27
|
-
# end
|
28
|
-
# before { get :index, format: :json }
|
29
|
-
|
30
|
-
# it "sets @messages" do
|
31
|
-
# expect(assigns(:messages)).to eq :messages
|
32
|
-
# end
|
33
|
-
|
34
|
-
# it "renders 'errors'" do
|
35
|
-
# expect(response).to render_template "errors"
|
36
|
-
# end
|
37
|
-
|
38
|
-
# it "responds with 400" do
|
39
|
-
# expect(response.status).to eq 400
|
40
|
-
# end
|
41
|
-
# end
|
42
|
-
|
43
|
-
# describe "#on_not_found" do
|
44
|
-
|
45
|
-
# controller(<%= class_name %>Controller) do
|
46
|
-
# def index; on_not_found :messages; end
|
47
|
-
# end
|
48
|
-
# before { get :index, format: :json }
|
49
|
-
|
50
|
-
# it "sets @messages" do
|
51
|
-
# expect(assigns(:messages)).to eq :messages
|
52
|
-
# end
|
53
|
-
|
54
|
-
# it "renders 'errors'" do
|
55
|
-
# expect(response).to render_template "errors"
|
56
|
-
# end
|
57
|
-
|
58
|
-
# it "responds with 404" do
|
59
|
-
# expect(response.status).to eq 404
|
60
|
-
# end
|
61
|
-
# end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
|
2
|
-
# describe "#<%= action_name %>" do
|
3
|
-
|
4
|
-
# let(:action) do
|
5
|
-
# { controller: "<%= gem_name %>/#{ root }", action: "<%= action_name %>" }
|
6
|
-
# end
|
7
|
-
|
8
|
-
# subject(:request) { { <%= action_type %>: "/#{ root }/something" } }
|
9
|
-
|
10
|
-
# it "is routable in json" do
|
11
|
-
# expect(request).to route_to action.merge(format: "json")
|
12
|
-
# end
|
13
|
-
# end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
module <%= module_name %>
|
4
|
-
describe "<%= file_name %>" do
|
5
|
-
|
6
|
-
# Add this line if your project is a Rails engine, not the application:
|
7
|
-
# routes { <%= module_name %>::Engine.routes }
|
8
|
-
|
9
|
-
# let(:root) { "api/v1/<%= file_name %>" }
|
10
|
-
end
|
11
|
-
end
|