pattern_generator 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +0 -5
- data/lib/generators/policy/policy_generator.rb +24 -0
- data/lib/generators/policy/templates/policy.rb +9 -0
- data/lib/generators/policy/templates/policy_spec.rb +9 -0
- data/lib/generators/policy/templates/policy_test.rb +7 -0
- data/lib/generators/service/service_generator.rb +7 -2
- data/lib/generators/service/templates/service.rb +0 -1
- data/lib/generators/service/templates/service_test.rb +7 -0
- data/lib/pattern_generator/version.rb +1 -1
- data/lib/pattern_generator.rb +2 -0
- data/test/dummy/log/development.log +0 -0
- data/test/dummy/log/test.log +1133 -0
- data/test/generators/policy_generator_test.rb +41 -0
- data/test/generators/{service/service_generator_test.rb → service_generator_test.rb} +13 -4
- metadata +30 -8
- data/README.rdoc +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 590d40cb953dc48bf726b092c90affa70dae57d6
|
4
|
+
data.tar.gz: 5c0937a0e7fbb3b816d9bb3393b153d12b0c0f2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f58698f7929877b1aca8a19523aeeeba8d5b6c5b174a8adaccf2b3359bcb3c3d9dda11119c921f37a3accd81e81e5dece240122d6cdcbd39c2b4cc693314c191
|
7
|
+
data.tar.gz: 795e6487260871a165d6d61093a28840edf91b3d3b465633088b478ea616a314374a3fbbadaa97a589337efc8c3c5b9f8de50d30d5745bb4d1a0360d21310375
|
data/Rakefile
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'active_support/inflector'
|
2
|
+
|
3
|
+
class PolicyGenerator < Rails::Generators::NamedBase
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
class_option :test_suite, type: :string, default: 'rspec', desc: 'Test framework to generate test. (rspec or minitest)'
|
6
|
+
|
7
|
+
def generate_template
|
8
|
+
template 'policy.rb', "app/policies/#{file_name}_policy.rb"
|
9
|
+
end
|
10
|
+
|
11
|
+
def generate_test
|
12
|
+
if options.test_suite == 'rspec'
|
13
|
+
template 'policy_spec.rb', "spec/policies/#{file_name}_policy_spec.rb"
|
14
|
+
elsif options.test_suite == 'minitest'
|
15
|
+
template 'policy_test.rb', "test/policies/#{file_name}_policy_test.rb"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def class_name
|
22
|
+
file_name.classify
|
23
|
+
end
|
24
|
+
end
|
@@ -2,13 +2,18 @@ require "active_support/inflector"
|
|
2
2
|
|
3
3
|
class ServiceGenerator < Rails::Generators::NamedBase
|
4
4
|
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
class_option :test_suite, type: :string, default: 'rspec', desc: 'Test framework to generate test. (rspec or minitest)'
|
5
6
|
|
6
7
|
def copy_service_file
|
7
8
|
template 'service.rb', "app/services/#{file_name}_service.rb"
|
8
9
|
end
|
9
10
|
|
10
|
-
def
|
11
|
-
|
11
|
+
def copy_service_test_file
|
12
|
+
if options.test_suite == 'rspec'
|
13
|
+
template 'service_spec.rb', "spec/services/#{file_name}_service_spec.rb"
|
14
|
+
elsif options.test_suite == 'minitest'
|
15
|
+
template 'service_test.rb', "test/services/#{file_name}_service_test.rb"
|
16
|
+
end
|
12
17
|
end
|
13
18
|
|
14
19
|
private
|
data/lib/pattern_generator.rb
CHANGED
File without changes
|