paradigm 0.1.1 → 0.1.2

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: 7ad68d46e1eddf73bceac76787eb0372428d2326
4
- data.tar.gz: 889aed4c96624cff703fec7c5cc1214bf2b15146
3
+ metadata.gz: 52245ad5ba70c75fe570e27715bb49cda29ad243
4
+ data.tar.gz: 0481c691d64ea18d7a00de9bb25b370588627faf
5
5
  SHA512:
6
- metadata.gz: 6b857819dcffb7e22ac27980320ca6063a93dc5bdf8bbe0ef7dcfdc72806f2216d1a2981101f41be08d80bd6f6e3284d23d72181ff5652c520bae092623910d3
7
- data.tar.gz: 4f9da553437aedbf58261fbc4f70d8c3dde423185245b5c896167f18356c906f1644b3d27679184efc627b410bb1a8ef3778f733d593dc33375b4cc0015f23ff
6
+ metadata.gz: 788573fd3fd5297faefe113b042300de38d37e681c4ab7a3a00a2a09be7223e416c8bb4be0658bd41f17576c081d7531161d604bd23eac32d40ccc5fdf64238c
7
+ data.tar.gz: 3b7d0618ac3172581cc3bf546b7a981b0e0909672d409ea98961e5651f4dd026739a7df2144e45cd0a5331509dc2cc09e5ec7f9bcd529285dd7cecd1fe950654
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
- # Paradigm
1
+ [![Version](https://img.shields.io/badge/gem-v0.1.2-blue.svg)](https://rubygems.org/gems/paradigm)
2
+ [![Rating ](https://img.shields.io/badge/rating-100%2F5-brightgreen.svg)](https://rubygems.org/gems/paradigm)
3
+
4
+ # Paradigm: abstractions so good you'll cry
2
5
 
3
6
  Easily add Service abstractions into your Rails app with template generators
4
7
 
@@ -12,16 +15,31 @@ gem 'paradigm'
12
15
 
13
16
  Run `bundle install`
14
17
 
18
+ Next, you need to run the generator:
19
+
20
+ ```
21
+ rails generate paradigm:install
22
+ ```
23
+
15
24
  ## Generators
16
25
 
17
26
  ### Services
18
27
 
28
+ #### Top level services
29
+
19
30
  ```
20
- rails g paradigm:service user_creation
31
+ rails generate paradigm:service user_creation
21
32
  ```
22
33
 
23
- Sets up a `app/services` directory with a `user_creation_service.rb` file. Also adds a `user_creation_service_test.rb` file in your test directory.
34
+ Sets up a `app/services` directory with a `user_creation_service.rb` file. Also adds a `user_creation_service_test.rb` file in the `test/services` directory.
35
+
36
+ #### Nested services
37
+
38
+ ```
39
+ rails generate paradigm:service account:user_creation
40
+ ```
24
41
 
42
+ Sets up a `app/services/account` directory with a `user_creation_service.rb` file. Also adds a `user_creation_service_test.rb` file in the `test/services/account` directory.
25
43
 
26
44
  ## Copyright and Licenses
27
45
 
@@ -0,0 +1,13 @@
1
+ module Paradigm
2
+ module Generators
3
+ class InstallGenerator < ::Rails::Generators::Base
4
+ desc 'Creates Service module in app/services'
5
+
6
+ source_root File.expand_path('../../templates/install', __FILE__)
7
+
8
+ def copy_service
9
+ template 'service.rb', 'app/services/service.rb'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -3,11 +3,28 @@ module Paradigm
3
3
  class ServiceGenerator < ::Rails::Generators::NamedBase
4
4
  desc 'Creates a new service object with accompanying test file'
5
5
 
6
- source_root File.expand_path('../../templates', __FILE__)
6
+ source_root File.expand_path('../../templates/service', __FILE__)
7
7
 
8
8
  def create_service_file
9
- template 'service.tt', "app/services/#{file_name.underscore}_service.rb"
10
- template 'service_test.tt', "test/services/#{file_name.underscore}_service_test.rb"
9
+ @file_name = file_name
10
+
11
+ if nested_file_name?
12
+ @path = file_name.partition(':').delete_if { |x| x == ':' }
13
+
14
+ template 'nested_service.rb', "app/services/#{path[0]}/#{path[1].underscore}_service.rb"
15
+ template 'nested_service_test.rb', "test/services/#{path[0]}/#{path[1].underscore}_service_test.rb"
16
+ else
17
+ template 'service.rb', "app/services/#{file_name.underscore}_service.rb"
18
+ template 'service_test.rb', "test/services/#{file_name.underscore}_service_test.rb"
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ attr_reader :file_name, :path
25
+
26
+ def nested_file_name?
27
+ file_name.include?(':')
11
28
  end
12
29
  end
13
30
  end
@@ -0,0 +1,9 @@
1
+ module Service
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ def self.call(*args)
6
+ new(*args).call
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ class <%= @path[0].camelcase %>::<%= @path[1].camelcase %>Service
2
+ include Service
3
+
4
+ def call
5
+ # add service logic here
6
+ end
7
+
8
+ private
9
+
10
+ # keep the #call method readable by extracting private methods
11
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class <%= @path[0].camelcase %>::<%= @path[1].camelcase %>ServiceTest < ActiveSupport::TestCase
4
+ # test '.call' do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,11 @@
1
+ class <%= file_name.camelcase %>Service
2
+ include Service
3
+
4
+ def call
5
+ # add service logic here
6
+ end
7
+
8
+ private
9
+
10
+ # keep the #call method readable by extracting private methods
11
+ end
@@ -1,7 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class <%= file_name.camelcase %>ServiceTest < ActiveSupport::TestCase
4
- test '.call' do
5
- assert false
6
- end
4
+ # test '.call' do
5
+ # assert true
6
+ # end
7
7
  end
@@ -1,5 +1,5 @@
1
1
  module Paradigm
2
2
  module Rails
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -34,3 +34,399 @@ ParadigmTest: test_Paradigm_has_a_version_number
34
34
  --------------------------------------------------
35
35
  ServiceGeneratorTest: test_service_file_is_created
36
36
  --------------------------------------------------
37
+ ------------------------------------
38
+ SendUserEmailServiceTest: test_.call
39
+ ------------------------------------
40
+ --------------------------------------------------
41
+ ServiceGeneratorTest: test_service_file_is_created
42
+ --------------------------------------------------
43
+ ------------------------------------------------
44
+ ParadigmTest: test_Paradigm_has_a_version_number
45
+ ------------------------------------------------
46
+ ------------------------------------------------
47
+ ParadigmTest: test_Paradigm_has_a_version_number
48
+ ------------------------------------------------
49
+ --------------------------------------------------
50
+ ServiceGeneratorTest: test_service_file_is_created
51
+ --------------------------------------------------
52
+ ------------------------------------
53
+ SendUserEmailServiceTest: test_.call
54
+ ------------------------------------
55
+ ------------------------------------------------
56
+ ParadigmTest: test_Paradigm_has_a_version_number
57
+ ------------------------------------------------
58
+ --------------------------------------------------
59
+ ServiceGeneratorTest: test_service_file_is_created
60
+ --------------------------------------------------
61
+ --------------------------------------------------
62
+ ServiceGeneratorTest: test_service_file_is_created
63
+ --------------------------------------------------
64
+ ------------------------------------------------
65
+ ParadigmTest: test_Paradigm_has_a_version_number
66
+ ------------------------------------------------
67
+ ------------------------------------------------
68
+ ParadigmTest: test_Paradigm_has_a_version_number
69
+ ------------------------------------------------
70
+ --------------------------------------------------
71
+ ServiceGeneratorTest: test_service_file_is_created
72
+ --------------------------------------------------
73
+ ------------------------------------
74
+ SendUserEmailServiceTest: test_.call
75
+ ------------------------------------
76
+ --------------------------------------------------
77
+ ServiceGeneratorTest: test_service_file_is_created
78
+ --------------------------------------------------
79
+ ------------------------------------------------
80
+ ParadigmTest: test_Paradigm_has_a_version_number
81
+ ------------------------------------------------
82
+ --------------------------------------------------
83
+ ServiceGeneratorTest: test_service_file_is_created
84
+ --------------------------------------------------
85
+ ------------------------------------------------
86
+ ParadigmTest: test_Paradigm_has_a_version_number
87
+ ------------------------------------------------
88
+ --------------------------------------------------
89
+ ServiceGeneratorTest: test_service_file_is_created
90
+ --------------------------------------------------
91
+ ------------------------------------------------
92
+ ParadigmTest: test_Paradigm_has_a_version_number
93
+ ------------------------------------------------
94
+ ------------------------------------
95
+ SendUserEmailServiceTest: test_.call
96
+ ------------------------------------
97
+ ------------------------------------------------
98
+ ParadigmTest: test_Paradigm_has_a_version_number
99
+ ------------------------------------------------
100
+ --------------------------------------------------
101
+ ServiceGeneratorTest: test_service_file_is_created
102
+ --------------------------------------------------
103
+ --------------------------------------------------
104
+ ServiceGeneratorTest: test_service_file_is_created
105
+ --------------------------------------------------
106
+ ------------------------------------
107
+ SendUserEmailServiceTest: test_.call
108
+ ------------------------------------
109
+ ------------------------------------------------
110
+ ParadigmTest: test_Paradigm_has_a_version_number
111
+ ------------------------------------------------
112
+ ------------------------------------------------
113
+ ParadigmTest: test_Paradigm_has_a_version_number
114
+ ------------------------------------------------
115
+ --------------------------------------------------
116
+ ServiceGeneratorTest: test_service_file_is_created
117
+ --------------------------------------------------
118
+ ------------------------------------
119
+ SendUserEmailServiceTest: test_.call
120
+ ------------------------------------
121
+ ------------------------------------------------
122
+ ParadigmTest: test_Paradigm_has_a_version_number
123
+ ------------------------------------------------
124
+ --------------------------------------------------
125
+ ServiceGeneratorTest: test_service_file_is_created
126
+ --------------------------------------------------
127
+ ------------------------------------
128
+ SendUserEmailServiceTest: test_.call
129
+ ------------------------------------
130
+ --------------------------------------------------
131
+ ServiceGeneratorTest: test_service_file_is_created
132
+ --------------------------------------------------
133
+ ------------------------------------
134
+ SendUserEmailServiceTest: test_.call
135
+ ------------------------------------
136
+ ------------------------------------------------
137
+ ParadigmTest: test_Paradigm_has_a_version_number
138
+ ------------------------------------------------
139
+ ------------------------------------
140
+ SendUserEmailServiceTest: test_.call
141
+ ------------------------------------
142
+ --------------------------------------------------
143
+ ServiceGeneratorTest: test_service_file_is_created
144
+ --------------------------------------------------
145
+ ------------------------------------------------
146
+ ParadigmTest: test_Paradigm_has_a_version_number
147
+ ------------------------------------------------
148
+ --------------------------------------------------
149
+ ServiceGeneratorTest: test_service_file_is_created
150
+ --------------------------------------------------
151
+ ------------------------------------------------
152
+ ParadigmTest: test_Paradigm_has_a_version_number
153
+ ------------------------------------------------
154
+ ------------------------------------------------
155
+ ParadigmTest: test_Paradigm_has_a_version_number
156
+ ------------------------------------------------
157
+ ------------------------------------
158
+ SendUserEmailServiceTest: test_.call
159
+ ------------------------------------
160
+ --------------------------------------------------
161
+ ServiceGeneratorTest: test_service_file_is_created
162
+ --------------------------------------------------
163
+ --------------------------------------------------
164
+ ServiceGeneratorTest: test_service_file_is_created
165
+ --------------------------------------------------
166
+ ------------------------------------
167
+ SendUserEmailServiceTest: test_.call
168
+ ------------------------------------
169
+ ------------------------------------------------
170
+ ParadigmTest: test_Paradigm_has_a_version_number
171
+ ------------------------------------------------
172
+ ------------------------------------------------
173
+ ParadigmTest: test_Paradigm_has_a_version_number
174
+ ------------------------------------------------
175
+ --------------------------------------------------
176
+ ServiceGeneratorTest: test_service_file_is_created
177
+ --------------------------------------------------
178
+ ------------------------------------
179
+ SendUserEmailServiceTest: test_.call
180
+ ------------------------------------
181
+ --------------------------------------------------
182
+ ServiceGeneratorTest: test_service_file_is_created
183
+ --------------------------------------------------
184
+ ------------------------------------------------
185
+ ParadigmTest: test_Paradigm_has_a_version_number
186
+ ------------------------------------------------
187
+ ------------------------------------------------
188
+ ParadigmTest: test_Paradigm_has_a_version_number
189
+ ------------------------------------------------
190
+ --------------------------------------------------------
191
+ ServiceGeneratorTest: test_service.rb_is_not_overwritten
192
+ --------------------------------------------------------
193
+ -------------------------------------------------------------
194
+ ServiceGeneratorTest: test_service_template_files_are_created
195
+ -------------------------------------------------------------
196
+ ------------------------------------------------
197
+ ParadigmTest: test_Paradigm_has_a_version_number
198
+ ------------------------------------------------
199
+ --------------------------------------------------------
200
+ ServiceGeneratorTest: test_service.rb_is_not_overwritten
201
+ --------------------------------------------------------
202
+ -------------------------------------------------------------
203
+ ServiceGeneratorTest: test_service_template_files_are_created
204
+ -------------------------------------------------------------
205
+ --------------------------------------------------------
206
+ ServiceGeneratorTest: test_service.rb_is_not_overwritten
207
+ --------------------------------------------------------
208
+ -------------------------------------------------------------
209
+ ServiceGeneratorTest: test_service_template_files_are_created
210
+ -------------------------------------------------------------
211
+ ------------------------------------------------
212
+ ParadigmTest: test_Paradigm_has_a_version_number
213
+ ------------------------------------------------
214
+ --------------------------------------------------------
215
+ ServiceGeneratorTest: test_service.rb_is_not_overwritten
216
+ --------------------------------------------------------
217
+ -------------------------------------------------------------
218
+ ServiceGeneratorTest: test_service_template_files_are_created
219
+ -------------------------------------------------------------
220
+ ------------------------------------------------
221
+ ParadigmTest: test_Paradigm_has_a_version_number
222
+ ------------------------------------------------
223
+ ------------------------------------------------
224
+ ParadigmTest: test_Paradigm_has_a_version_number
225
+ ------------------------------------------------
226
+ -------------------------------------------------------------
227
+ ServiceGeneratorTest: test_service_template_files_are_created
228
+ -------------------------------------------------------------
229
+ --------------------------------------------------------
230
+ ServiceGeneratorTest: test_service.rb_is_not_overwritten
231
+ --------------------------------------------------------
232
+ -------------------------------------------------------------
233
+ ServiceGeneratorTest: test_service_template_files_are_created
234
+ -------------------------------------------------------------
235
+ --------------------------------------------------------
236
+ ServiceGeneratorTest: test_service.rb_is_not_overwritten
237
+ --------------------------------------------------------
238
+ ------------------------------------------------
239
+ ParadigmTest: test_Paradigm_has_a_version_number
240
+ ------------------------------------------------
241
+ --------------------------------------------------------
242
+ ServiceGeneratorTest: test_service.rb_is_not_overwritten
243
+ --------------------------------------------------------
244
+ -------------------------------------------------------------
245
+ ServiceGeneratorTest: test_service_template_files_are_created
246
+ -------------------------------------------------------------
247
+ ------------------------------------------------
248
+ ParadigmTest: test_Paradigm_has_a_version_number
249
+ ------------------------------------------------
250
+ --------------------------------------------------------
251
+ ServiceGeneratorTest: test_service.rb_is_not_overwritten
252
+ --------------------------------------------------------
253
+ -------------------------------------------------------------
254
+ ServiceGeneratorTest: test_service_template_files_are_created
255
+ -------------------------------------------------------------
256
+ ------------------------------------------------
257
+ ParadigmTest: test_Paradigm_has_a_version_number
258
+ ------------------------------------------------
259
+ --------------------------------------------------------
260
+ ServiceGeneratorTest: test_service.rb_is_not_overwritten
261
+ --------------------------------------------------------
262
+ -------------------------------------------------------------
263
+ ServiceGeneratorTest: test_service_template_files_are_created
264
+ -------------------------------------------------------------
265
+ ------------------------------------------------
266
+ ParadigmTest: test_Paradigm_has_a_version_number
267
+ ------------------------------------------------
268
+ ------------------------------------------------
269
+ ParadigmTest: test_Paradigm_has_a_version_number
270
+ ------------------------------------------------
271
+ --------------------------------------------------------
272
+ ServiceGeneratorTest: test_service.rb_is_not_overwritten
273
+ --------------------------------------------------------
274
+ -------------------------------------------------------------
275
+ ServiceGeneratorTest: test_service_template_files_are_created
276
+ -------------------------------------------------------------
277
+ ------------------------------------------------
278
+ ParadigmTest: test_Paradigm_has_a_version_number
279
+ ------------------------------------------------
280
+ -------------------------------------------------------------
281
+ ServiceGeneratorTest: test_service_template_files_are_created
282
+ -------------------------------------------------------------
283
+ --------------------------------------------------------
284
+ ServiceGeneratorTest: test_service.rb_is_not_overwritten
285
+ --------------------------------------------------------
286
+ ------------------------------------------------
287
+ ParadigmTest: test_Paradigm_has_a_version_number
288
+ ------------------------------------------------
289
+ -------------------------------------------------------------
290
+ ServiceGeneratorTest: test_service_template_files_are_created
291
+ -------------------------------------------------------------
292
+ --------------------------------------------------------
293
+ ServiceGeneratorTest: test_service.rb_is_not_overwritten
294
+ --------------------------------------------------------
295
+ ------------------------------------------------
296
+ ParadigmTest: test_Paradigm_has_a_version_number
297
+ ------------------------------------------------
298
+ -------------------------------------------------------------
299
+ ServiceGeneratorTest: test_service_template_files_are_created
300
+ -------------------------------------------------------------
301
+ ------------------------------------------------
302
+ ParadigmTest: test_Paradigm_has_a_version_number
303
+ ------------------------------------------------
304
+ -------------------------------------------------------------
305
+ ServiceGeneratorTest: test_service_template_files_are_created
306
+ -------------------------------------------------------------
307
+ ------------------------------------------------
308
+ ParadigmTest: test_Paradigm_has_a_version_number
309
+ ------------------------------------------------
310
+ -------------------------------------------------------------
311
+ ServiceGeneratorTest: test_service_template_files_are_created
312
+ -------------------------------------------------------------
313
+ ----------------------------------------------------
314
+ InstallGeneratorTest: test_service_module_is_created
315
+ ----------------------------------------------------
316
+ ------------------------------------------------
317
+ ParadigmTest: test_Paradigm_has_a_version_number
318
+ ------------------------------------------------
319
+ ----------------------------------------------------
320
+ InstallGeneratorTest: test_service_module_is_created
321
+ ----------------------------------------------------
322
+ -------------------------------------------------------------
323
+ ServiceGeneratorTest: test_service_template_files_are_created
324
+ -------------------------------------------------------------
325
+ ------------------------------------------------
326
+ ParadigmTest: test_Paradigm_has_a_version_number
327
+ ------------------------------------------------
328
+ ----------------------------------------------------
329
+ InstallGeneratorTest: test_service_module_is_created
330
+ ----------------------------------------------------
331
+ -------------------------------------------------------------
332
+ ServiceGeneratorTest: test_service_template_files_are_created
333
+ -------------------------------------------------------------
334
+ ----------------------------------------------------
335
+ InstallGeneratorTest: test_service_module_is_created
336
+ ----------------------------------------------------
337
+ ------------------------------------------------
338
+ ParadigmTest: test_Paradigm_has_a_version_number
339
+ ------------------------------------------------
340
+ -------------------------------------------------------------
341
+ ServiceGeneratorTest: test_service_template_files_are_created
342
+ -------------------------------------------------------------
343
+ ----------------------------------------------------
344
+ InstallGeneratorTest: test_service_module_is_created
345
+ ----------------------------------------------------
346
+ -------------------------------------------------------------
347
+ ServiceGeneratorTest: test_service_template_files_are_created
348
+ -------------------------------------------------------------
349
+ ------------------------------------------------
350
+ ParadigmTest: test_Paradigm_has_a_version_number
351
+ ------------------------------------------------
352
+ ----------------------------------------------------
353
+ InstallGeneratorTest: test_service_module_is_created
354
+ ----------------------------------------------------
355
+ ------------------------------------------------
356
+ ParadigmTest: test_Paradigm_has_a_version_number
357
+ ------------------------------------------------
358
+ -------------------------------------------------------------
359
+ ServiceGeneratorTest: test_service_template_files_are_created
360
+ -------------------------------------------------------------
361
+ -------------------------------------------------------------
362
+ ServiceGeneratorTest: test_service_template_files_are_created
363
+ -------------------------------------------------------------
364
+ ---------------------------------------------------------------
365
+ ServiceGeneratorTest: test_service_template_files_can_be_nested
366
+ ---------------------------------------------------------------
367
+ ------------------------------------------------
368
+ ParadigmTest: test_Paradigm_has_a_version_number
369
+ ------------------------------------------------
370
+ ----------------------------------------------------
371
+ InstallGeneratorTest: test_service_module_is_created
372
+ ----------------------------------------------------
373
+ ---------------------------------------------------------------
374
+ ServiceGeneratorTest: test_service_template_files_can_be_nested
375
+ ---------------------------------------------------------------
376
+ -------------------------------------------------------------
377
+ ServiceGeneratorTest: test_service_template_files_are_created
378
+ -------------------------------------------------------------
379
+ ------------------------------------------------
380
+ ParadigmTest: test_Paradigm_has_a_version_number
381
+ ------------------------------------------------
382
+ ----------------------------------------------------
383
+ InstallGeneratorTest: test_service_module_is_created
384
+ ----------------------------------------------------
385
+ -------------------------------------------------------------
386
+ ServiceGeneratorTest: test_service_template_files_are_created
387
+ -------------------------------------------------------------
388
+ ---------------------------------------------------------------
389
+ ServiceGeneratorTest: test_service_template_files_can_be_nested
390
+ ---------------------------------------------------------------
391
+ ------------------------------------------------
392
+ ParadigmTest: test_Paradigm_has_a_version_number
393
+ ------------------------------------------------
394
+ ----------------------------------------------------
395
+ InstallGeneratorTest: test_service_module_is_created
396
+ ----------------------------------------------------
397
+ ----------------------------------------------------
398
+ InstallGeneratorTest: test_service_module_is_created
399
+ ----------------------------------------------------
400
+ ------------------------------------------------
401
+ ParadigmTest: test_Paradigm_has_a_version_number
402
+ ------------------------------------------------
403
+ -------------------------------------------------------------
404
+ ServiceGeneratorTest: test_service_template_files_are_created
405
+ -------------------------------------------------------------
406
+ ---------------------------------------------------------------
407
+ ServiceGeneratorTest: test_service_template_files_can_be_nested
408
+ ---------------------------------------------------------------
409
+ ------------------------------------------------
410
+ ParadigmTest: test_Paradigm_has_a_version_number
411
+ ------------------------------------------------
412
+ -------------------------------------------------------------
413
+ ServiceGeneratorTest: test_service_template_files_are_created
414
+ -------------------------------------------------------------
415
+ ---------------------------------------------------------------
416
+ ServiceGeneratorTest: test_service_template_files_can_be_nested
417
+ ---------------------------------------------------------------
418
+ ----------------------------------------------------
419
+ InstallGeneratorTest: test_service_module_is_created
420
+ ----------------------------------------------------
421
+ -------------------------------------------------------------
422
+ ServiceGeneratorTest: test_service_template_files_are_created
423
+ -------------------------------------------------------------
424
+ ---------------------------------------------------------------
425
+ ServiceGeneratorTest: test_service_template_files_can_be_nested
426
+ ---------------------------------------------------------------
427
+ ------------------------------------------------
428
+ ParadigmTest: test_Paradigm_has_a_version_number
429
+ ------------------------------------------------
430
+ ----------------------------------------------------
431
+ InstallGeneratorTest: test_service_module_is_created
432
+ ----------------------------------------------------
@@ -0,0 +1,9 @@
1
+ module Service
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ def self.call(*args)
6
+ new(*args).call
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ require 'test_helper'
2
+ require 'generators/paradigm/install_generator'
3
+
4
+ class InstallGeneratorTest < Rails::Generators::TestCase
5
+ tests Paradigm::Generators::InstallGenerator
6
+
7
+ destination File.join(Rails.root, 'tmp')
8
+ setup :prepare_destination
9
+
10
+ test 'service module is created' do
11
+ run_generator
12
+
13
+ assert_file 'app/services/service.rb', %r{module Service}
14
+ end
15
+ end
@@ -7,10 +7,17 @@ class ServiceGeneratorTest < Rails::Generators::TestCase
7
7
  destination File.join(Rails.root, 'tmp')
8
8
  setup :prepare_destination
9
9
 
10
- test 'service file is created' do
10
+ test 'service template files are created' do
11
11
  run_generator %w(send_user_email)
12
12
 
13
13
  assert_file 'app/services/send_user_email_service.rb', %r{SendUserEmailService}
14
14
  assert_file 'test/services/send_user_email_service_test.rb', %r{SendUserEmailServiceTest}
15
15
  end
16
+
17
+ test 'service template files can be nested' do
18
+ run_generator %w(account:send_user_email)
19
+
20
+ assert_file 'app/services/account/send_user_email_service.rb', %r{Account::SendUserEmailService}
21
+ assert_file 'test/services/account/send_user_email_service_test.rb', %r{Account::SendUserEmailServiceTest}
22
+ end
16
23
  end
@@ -2,7 +2,7 @@
2
2
  ENV["RAILS_ENV"] = "test"
3
3
 
4
4
  require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
5
- require "rails/test_help"
5
+ require 'rails/test_help'
6
6
 
7
7
  # Filter out Minitest backtrace while allowing backtrace from other libraries
8
8
  # to be shown.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paradigm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glenn Espinosa
@@ -48,9 +48,13 @@ files:
48
48
  - MIT-LICENSE
49
49
  - README.md
50
50
  - Rakefile
51
+ - lib/generators/paradigm/install_generator.rb
51
52
  - lib/generators/paradigm/service_generator.rb
52
- - lib/generators/templates/service.tt
53
- - lib/generators/templates/service_test.tt
53
+ - lib/generators/templates/install/service.rb
54
+ - lib/generators/templates/service/nested_service.rb
55
+ - lib/generators/templates/service/nested_service_test.rb
56
+ - lib/generators/templates/service/service.rb
57
+ - lib/generators/templates/service/service_test.rb
54
58
  - lib/paradigm/rails.rb
55
59
  - lib/paradigm/rails/version.rb
56
60
  - test/dummy/README.rdoc
@@ -87,8 +91,8 @@ files:
87
91
  - test/dummy/public/422.html
88
92
  - test/dummy/public/500.html
89
93
  - test/dummy/public/favicon.ico
90
- - test/dummy/tmp/app/services/send_user_email_service.rb
91
- - test/dummy/tmp/test/services/send_user_email_service_test.rb
94
+ - test/dummy/tmp/app/services/service.rb
95
+ - test/generators/install_generator_test.rb
92
96
  - test/generators/service_generator_test.rb
93
97
  - test/paradigm_test.rb
94
98
  - test/test_helper.rb
@@ -151,8 +155,8 @@ test_files:
151
155
  - test/dummy/public/favicon.ico
152
156
  - test/dummy/Rakefile
153
157
  - test/dummy/README.rdoc
154
- - test/dummy/tmp/app/services/send_user_email_service.rb
155
- - test/dummy/tmp/test/services/send_user_email_service_test.rb
158
+ - test/dummy/tmp/app/services/service.rb
159
+ - test/generators/install_generator_test.rb
156
160
  - test/generators/service_generator_test.rb
157
161
  - test/paradigm_test.rb
158
162
  - test/test_helper.rb
@@ -1,5 +0,0 @@
1
- class <%= file_name.camelcase %>Service
2
- def self.call
3
- # add service logic here
4
- end
5
- end
@@ -1,8 +0,0 @@
1
- class SendUserEmailService
2
-
3
- def self.call(invite, user)
4
- invite.accept!(user)
5
- UserMailer.invite_accepted(invite).deliver
6
- end
7
-
8
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class SendUserEmailServiceTest < ActiveSupport::TestCase
4
- test '.call' do
5
- assert false
6
- end
7
- end