active_generator 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.fasterer.yml +19 -0
  3. data/.flayignore +2 -0
  4. data/.reek +20 -0
  5. data/.rubocop.yml +37 -0
  6. data/Gemfile +1 -1
  7. data/README.md +12 -24
  8. data/Rakefile +1 -1
  9. data/active_generator.gemspec +21 -17
  10. data/bin/console +4 -4
  11. data/bin/rake +6 -7
  12. data/lib/active_generator.rb +4 -28
  13. data/lib/active_generator/base.rb +6 -6
  14. data/lib/active_generator/settings.rb +18 -0
  15. data/lib/active_generator/version.rb +1 -1
  16. data/lib/generators/active_generator/install/install_generator.rb +2 -2
  17. data/lib/generators/active_generator/install/templates/install.rb +2 -2
  18. data/lib/generators/environment/environment_generator.rb +5 -5
  19. data/lib/generators/initializer/initializer_generator.rb +2 -2
  20. data/lib/generators/locale/api/api_generator.rb +5 -5
  21. data/lib/generators/locale/api/templates/api.yml +2 -2
  22. data/lib/generators/locale/base.rb +1 -1
  23. data/lib/generators/locale/controller/controller_generator.rb +6 -5
  24. data/lib/generators/locale/controller/templates/controller.yml +4 -4
  25. data/lib/generators/locale/helper/helper_generator.rb +5 -5
  26. data/lib/generators/locale/helper/templates/helper.yml +2 -2
  27. data/lib/generators/locale/job/job_generator.rb +5 -5
  28. data/lib/generators/locale/job/templates/job.yml +2 -2
  29. data/lib/generators/locale/mailer/mailer_generator.rb +5 -5
  30. data/lib/generators/locale/mailer/templates/mailer.yml +2 -2
  31. data/lib/generators/locale/model/model_generator.rb +5 -5
  32. data/lib/generators/locale/model/templates/model.yml +4 -4
  33. data/lib/generators/locale/service/service_generator.rb +5 -5
  34. data/lib/generators/locale/service/templates/service.yml +2 -2
  35. data/lib/generators/locale/task/task_generator.rb +5 -5
  36. data/lib/generators/locale/task/templates/task.yml +2 -2
  37. data/lib/generators/locale/uploader/templates/uploader.yml +2 -2
  38. data/lib/generators/locale/uploader/uploader_generator.rb +5 -5
  39. data/lib/generators/locale/view/templates/view.yml +4 -4
  40. data/lib/generators/locale/view/view_generator.rb +5 -5
  41. data/lib/generators/rails/base.rb +11 -0
  42. data/lib/generators/rails/controller_generator.rb +15 -10
  43. data/lib/generators/rails/helper_generator.rb +8 -5
  44. data/lib/generators/rails/job_generator.rb +8 -5
  45. data/lib/generators/rails/mailer_generator.rb +15 -10
  46. data/lib/generators/rails/model_generator.rb +14 -7
  47. data/lib/generators/rails/scaffold_generator.rb +8 -5
  48. data/lib/generators/rails/task_generator.rb +2 -2
  49. data/lib/generators/service/service_generator.rb +3 -3
  50. data/lib/generators/view/view_generator.rb +16 -9
  51. metadata +64 -3
  52. data/lib/active_generator/configuration.rb +0 -25
@@ -0,0 +1,11 @@
1
+ module Rails
2
+ module Base
3
+
4
+ private
5
+
6
+ def configuration
7
+ ActiveGenerator::Settings.config
8
+ end
9
+
10
+ end
11
+ end
@@ -1,18 +1,21 @@
1
- require "rails/generators/erb/controller/controller_generator"
2
- require "rails/generators/rails/controller/controller_generator"
1
+ require 'rails/generators/erb/controller/controller_generator'
2
+ require 'rails/generators/rails/controller/controller_generator'
3
+ require 'generators/rails/base'
3
4
 
4
5
  module Erb
5
6
  module Generators
6
7
  class ControllerGenerator
8
+ include Rails::Base
7
9
 
8
10
  def generate_locale_file
9
- invoke("locale:view", [name]) if ActiveGenerator.configuration.autoload_view_generator_locale
11
+ invoke('locale:view', [name]) if configuration.autoload_view_generator_locale
10
12
  end
11
13
 
12
14
  def generate_test_file
13
- unless ActiveGenerator.configuration.test_framework.nil?
14
- invoke("#{ActiveGenerator.configuration.test_framework}:view", [name]) rescue nil
15
- end
15
+ framework = configuration.test_framework
16
+
17
+ return if framework.nil?
18
+ invoke("#{framework}:view", [name]) rescue nil
16
19
  end
17
20
 
18
21
  end
@@ -22,15 +25,17 @@ end
22
25
  module Rails
23
26
  module Generators
24
27
  class ControllerGenerator
28
+ include Rails::Base
25
29
 
26
30
  def generate_locale_file
27
- invoke("locale:controller", [name]) if ActiveGenerator.configuration.autoload_controller_generator_locale
31
+ invoke('locale:controller', [name]) if configuration.autoload_controller_generator_locale
28
32
  end
29
33
 
30
34
  def generate_test_file
31
- unless ActiveGenerator.configuration.test_framework.nil?
32
- invoke("#{ActiveGenerator.configuration.test_framework}:controller", [name]) rescue nil
33
- end
35
+ framework = configuration.test_framework
36
+
37
+ return if framework.nil?
38
+ invoke("#{framework}:controller", [name]) rescue nil
34
39
  end
35
40
 
36
41
  end
@@ -1,17 +1,20 @@
1
- require "rails/generators/rails/helper/helper_generator"
1
+ require 'rails/generators/rails/helper/helper_generator'
2
+ require 'generators/rails/base'
2
3
 
3
4
  module Rails
4
5
  module Generators
5
6
  class HelperGenerator
7
+ include Rails::Base
6
8
 
7
9
  def generate_locale_file
8
- invoke("locale:helper", [name]) if ActiveGenerator.configuration.autoload_helper_generator_locale
10
+ invoke('locale:helper', [name]) if configuration.autoload_helper_generator_locale
9
11
  end
10
12
 
11
13
  def generate_test_file
12
- unless ActiveGenerator.configuration.test_framework.nil?
13
- invoke("#{ActiveGenerator.configuration.test_framework}:helper", [name]) rescue nil
14
- end
14
+ framework = configuration.test_framework
15
+
16
+ return if framework.nil?
17
+ invoke("#{framework}:helper", [name]) rescue nil
15
18
  end
16
19
 
17
20
  end
@@ -1,17 +1,20 @@
1
- require "rails/generators/job/job_generator"
1
+ require 'rails/generators/job/job_generator'
2
+ require 'generators/rails/base'
2
3
 
3
4
  module Rails
4
5
  module Generators
5
6
  class JobGenerator
7
+ include Rails::Base
6
8
 
7
9
  def generate_locale_file
8
- invoke("locale:job", [name]) if ActiveGenerator.configuration.autoload_job_generator_locale
10
+ invoke('locale:job', [name]) if configuration.autoload_job_generator_locale
9
11
  end
10
12
 
11
13
  def generate_test_file
12
- unless ActiveGenerator.configuration.test_framework.nil?
13
- invoke("#{ActiveGenerator.configuration.test_framework}:job", [name]) rescue nil
14
- end
14
+ framework = configuration.test_framework
15
+
16
+ return if framework.nil?
17
+ invoke("#{framework}:job", [name]) rescue nil
15
18
  end
16
19
 
17
20
  end
@@ -1,18 +1,21 @@
1
- require "rails/generators/erb/mailer/mailer_generator"
2
- require "rails/generators/mailer/mailer_generator"
1
+ require 'rails/generators/erb/mailer/mailer_generator'
2
+ require 'rails/generators/mailer/mailer_generator'
3
+ require 'generators/rails/base'
3
4
 
4
5
  module Erb
5
6
  module Generators
6
7
  class MailerGenerator
8
+ include Rails::Base
7
9
 
8
10
  def generate_locale_file
9
- invoke("locale:view", [name]) if ActiveGenerator.configuration.autoload_view_generator_locale
11
+ invoke('locale:view', [name]) if configuration.autoload_view_generator_locale
10
12
  end
11
13
 
12
14
  def generate_test_file
13
- unless ActiveGenerator.configuration.test_framework.nil?
14
- invoke("#{ActiveGenerator.configuration.test_framework}:view", [name]) rescue nil
15
- end
15
+ framework = configuration.test_framework
16
+
17
+ return if framework.nil?
18
+ invoke("#{framework}:view", [name]) rescue nil
16
19
  end
17
20
 
18
21
  end
@@ -22,15 +25,17 @@ end
22
25
  module Rails
23
26
  module Generators
24
27
  class MailerGenerator
28
+ include Rails::Base
25
29
 
26
30
  def generate_locale_file
27
- invoke("locale:mailer", [name]) if ActiveGenerator.configuration.autoload_mailer_generator_locale
31
+ invoke('locale:mailer', [name]) if configuration.autoload_mailer_generator_locale
28
32
  end
29
33
 
30
34
  def generate_test_file
31
- unless ActiveGenerator.configuration.test_framework.nil?
32
- invoke("#{ActiveGenerator.configuration.test_framework}:mailer", [name]) rescue nil
33
- end
35
+ framework = configuration.test_framework
36
+
37
+ return if framework.nil?
38
+ invoke("#{framework}:mailer", [name]) rescue nil
34
39
  end
35
40
 
36
41
  end
@@ -1,23 +1,30 @@
1
- require "rails/generators/active_record/model/model_generator"
1
+ require 'rails/generators/active_record/model/model_generator'
2
+ require 'generators/rails/base'
2
3
 
3
4
  module ActiveRecord
4
5
  module Generators
5
6
  class ModelGenerator
7
+ include Rails::Base
6
8
 
7
9
  def create_migration_file
8
10
  # return unless options[:migration] && options[:parent].nil?
9
- attributes.each { |a| a.attr_options.delete(:index) if a.reference? && !a.has_index? } if options[:indexes] == false
10
- migration_template "../../migration/templates/create_table_migration.rb", "db/migrate/create_#{table_name}.rb"
11
+
12
+ if options[:indexes] == false
13
+ attributes.each { |attr| attr.attr_options.delete(:index) if attr.reference? && !attr.has_index? }
14
+ end
15
+
16
+ migration_template('../../migration/templates/create_table_migration.rb', "db/migrate/create_#{table_name}.rb")
11
17
  end
12
18
 
13
19
  def generate_locale_file
14
- invoke("locale:model", [name]) if ActiveGenerator.configuration.autoload_model_generator_locale
20
+ invoke('locale:model', [name]) if configuration.autoload_model_generator_locale
15
21
  end
16
22
 
17
23
  def generate_test_file
18
- unless ActiveGenerator.configuration.test_framework.nil?
19
- invoke("#{ActiveGenerator.configuration.test_framework}:model", [name]) rescue nil
20
- end
24
+ framework = configuration.test_framework
25
+
26
+ return if framework.nil?
27
+ invoke("#{framework}:model", [name]) rescue nil
21
28
  end
22
29
 
23
30
  end
@@ -1,17 +1,20 @@
1
- require "rails/generators/erb/scaffold/scaffold_generator"
1
+ require 'rails/generators/erb/scaffold/scaffold_generator'
2
+ require 'generators/rails/base'
2
3
 
3
4
  module Erb
4
5
  module Generators
5
6
  class ScaffoldGenerator
7
+ include Rails::Base
6
8
 
7
9
  def generate_locale_file
8
- invoke("locale:view", [name]) if ActiveGenerator.configuration.autoload_view_generator_locale
10
+ invoke('locale:view', [name]) if configuration.autoload_view_generator_locale
9
11
  end
10
12
 
11
13
  def generate_test_file
12
- unless ActiveGenerator.configuration.test_framework.nil?
13
- invoke("#{ActiveGenerator.configuration.test_framework}:view", [name]) rescue nil
14
- end
14
+ framework = configuration.test_framework
15
+
16
+ return if framework.nil?
17
+ invoke("#{framework}:view", [name]) rescue nil
15
18
  end
16
19
 
17
20
  end
@@ -1,11 +1,11 @@
1
- require "rails/generators/rails/task/task_generator"
1
+ require 'rails/generators/rails/task/task_generator'
2
2
 
3
3
  module Rails
4
4
  module Generators
5
5
  class TaskGenerator
6
6
 
7
7
  def generate_locale_file
8
- invoke("locale:task", [name]) if ActiveGenerator.configuration.autoload_task_generator_locale
8
+ invoke('locale:task', [name]) if ActiveGenerator::Settings.config.autoload_task_generator_locale
9
9
  end
10
10
 
11
11
  end
@@ -1,12 +1,12 @@
1
1
  class ServiceGenerator < Rails::Generators::NamedBase
2
- source_root File.expand_path("../templates", __FILE__)
2
+ source_root File.expand_path('../templates', __FILE__)
3
3
 
4
4
  def create_service_file
5
- template("service.rb", File.join("app/services", class_path, "#{file_name}.rb"))
5
+ template('service.rb', File.join('app/services', class_path, "#{file_name}.rb"))
6
6
  end
7
7
 
8
8
  def generate_locale_file
9
- invoke("locale:service", [name]) if ActiveGenerator.configuration.autoload_service_generator_locale
9
+ invoke('locale:service', [name]) if ActiveGenerator::Settings.config.autoload_service_generator_locale
10
10
  end
11
11
 
12
12
  end
@@ -1,29 +1,36 @@
1
- require "fileutils"
1
+ require 'fileutils'
2
2
 
3
3
  class ViewGenerator < Rails::Generators::NamedBase
4
- source_root File.expand_path("../templates", __FILE__)
5
- argument :actions, type: :array, required: false, default: [], desc: "The pages to generate"
4
+ source_root File.expand_path('../templates', __FILE__)
5
+ argument :actions, type: :array, required: false, default: [], desc: 'The pages to generate'
6
6
 
7
7
  def create_root_directory
8
- empty_directory(File.join("app/views", file_name)) if actions.empty?
8
+ empty_directory(File.join('app/views', file_name)) if actions.empty?
9
9
  end
10
10
 
11
11
  def create_view_file
12
12
  unless actions.empty?
13
13
  actions.each do |filename|
14
- template("view.html.erb", File.join("app/views", class_path, file_name, "#{filename}.html.erb"))
14
+ template('view.html.erb', File.join('app/views', class_path, file_name, "#{filename}.html.erb"))
15
15
  end
16
16
  end
17
17
  end
18
18
 
19
19
  def generate_locale_file
20
- invoke("locale:view", [name]) if ActiveGenerator.configuration.autoload_view_generator_locale
20
+ invoke('locale:view', [name]) if configuration.autoload_view_generator_locale
21
21
  end
22
22
 
23
23
  def generate_test_file
24
- unless ActiveGenerator.configuration.test_framework.nil?
25
- invoke("#{ActiveGenerator.configuration.test_framework}:view", [name]) rescue nil
26
- end
24
+ framework = configuration.test_framework
25
+
26
+ return if framework.nil?
27
+ invoke("#{framework}:view", [name]) rescue nil
28
+ end
29
+
30
+ private
31
+
32
+ def configuration
33
+ ActiveGenerator::Settings.config
27
34
  end
28
35
 
29
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-03 00:00:00.000000000 Z
11
+ date: 2016-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -94,6 +94,62 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: fasterer
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: flay
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: reek
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
97
153
  description: Extend the base rails generators with commonly used generators.
98
154
  email:
99
155
  - j.gomez@drexed.com
@@ -102,8 +158,12 @@ extensions: []
102
158
  extra_rdoc_files: []
103
159
  files:
104
160
  - ".coveralls.yml"
161
+ - ".fasterer.yml"
162
+ - ".flayignore"
105
163
  - ".gitignore"
164
+ - ".reek"
106
165
  - ".rspec"
166
+ - ".rubocop.yml"
107
167
  - ".travis.yml"
108
168
  - CODE_OF_CONDUCT.md
109
169
  - Gemfile
@@ -115,7 +175,7 @@ files:
115
175
  - bin/setup
116
176
  - lib/active_generator.rb
117
177
  - lib/active_generator/base.rb
118
- - lib/active_generator/configuration.rb
178
+ - lib/active_generator/settings.rb
119
179
  - lib/active_generator/version.rb
120
180
  - lib/generators/active_generator/install/install_generator.rb
121
181
  - lib/generators/active_generator/install/templates/install.rb
@@ -156,6 +216,7 @@ files:
156
216
  - lib/generators/locale/view/USAGE
157
217
  - lib/generators/locale/view/templates/view.yml
158
218
  - lib/generators/locale/view/view_generator.rb
219
+ - lib/generators/rails/base.rb
159
220
  - lib/generators/rails/controller_generator.rb
160
221
  - lib/generators/rails/helper_generator.rb
161
222
  - lib/generators/rails/job_generator.rb
@@ -1,25 +0,0 @@
1
- class ActiveGenerator::Configuration
2
-
3
- attr_accessor :autoload_controller_generator_locale,
4
- :autoload_helper_generator_locale,
5
- :autoload_job_generator_locale,
6
- :autoload_mailer_generator_locale,
7
- :autoload_model_generator_locale,
8
- :autoload_service_generator_locale,
9
- :autoload_task_generator_locale,
10
- :autoload_view_generator_locale,
11
- :test_framework
12
-
13
- def initialize
14
- @autoload_controller_generator_locale = true
15
- @autoload_helper_generator_locale = true
16
- @autoload_job_generator_locale = true
17
- @autoload_mailer_generator_locale = true
18
- @autoload_model_generator_locale = true
19
- @autoload_service_generator_locale = true
20
- @autoload_task_generator_locale = true
21
- @autoload_view_generator_locale = true
22
- @test_framework = "test_unit"
23
- end
24
-
25
- end