active_generator 2.0.4 → 2.0.5

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: 23a631e7a338ab863dc38c335c6dec2d538e4c53
4
- data.tar.gz: d700e66e0782ae761bf022b2da6b2a2a393a5f4d
3
+ metadata.gz: 30f5c2d64b306b4fe28ab6e5e4e3d1eb317ce51b
4
+ data.tar.gz: 1545a9a6060381196f93dff33d760037974cc5f3
5
5
  SHA512:
6
- metadata.gz: f0dfa67411bdbed0a909178f056e05cb31b1ddd56d7f452513326a9a40b44ddfeef723552d9d0524ed4c6c4aca97e0a27dd59719ce50cd88e31701cd7b3d2c74
7
- data.tar.gz: 252dea70662d3233c692ff4a3994f64b85221305b53f0ce53518211d158e99ea3dfda85cb853d1f5024acd539d2c6864d3c4581c1afd52b7c80aef50d2acd39c
6
+ metadata.gz: 332e8c462a9a6bf53c9af03888afa0910a859c53fdf1043022723628d02b8984dfc11a5024d1421295b56d9715a1b76bbc18591e97e11d79e9ac281de214371c
7
+ data.tar.gz: a03e87e8712288c3da3a943f50087fb441fdcd2f1c18a60c505dff9388a347ab0800b92a69221bf53bc97778657b0debf8f96f8c7d73ffecadc28a6d07da4776
@@ -1,47 +1,50 @@
1
1
  require "rails/generators"
2
- require 'rails/generators/rails/controller/controller_generator'
3
- require 'rails/generators/rails/helper/helper_generator'
4
- require 'rails/generators/rails/model/model_generator'
5
-
6
2
 
7
3
  require "active_object"
8
4
  require "active_generator/version"
5
+ require "active_generator/configuration"
9
6
 
10
7
  require "generators/environment/environment_generator"
11
8
  require "generators/initializer/initializer_generator"
12
9
  require "generators/service/service_generator"
13
10
 
14
- %w(api controller helper job mailer model service uploader view).each do |name|
15
- require "generators/locale/#{name}/#{name}_generator"
11
+ %w(api controller helper jbuilder job mailer model responders_controller service task uploader view).each do |generator_name|
12
+ require "generators/locale/#{generator_name}/#{generator_name}_generator"
16
13
  end
17
14
 
18
- Rails::Generators::ControllerGenerator.class_eval do
19
- def copy_locale_file
20
- invoke("locale:controller", [name])
21
- invoke("locale:helper", [name])
15
+ module ActiveGenerator
16
+
17
+ class << self
18
+ attr_accessor :configuration
19
+ end
20
+
21
+ def self.configuration
22
+ @configuration ||= Configuration.new
23
+ end
24
+
25
+ def self.configuration=(config)
26
+ @configuration = config
27
+ end
28
+
29
+ def self.configure
30
+ yield(configuration)
22
31
  end
32
+
23
33
  end
24
34
 
25
- # Rails::Generators::HelperGenerator.class_eval do
26
- # def copy_locale_file
27
- # invoke("locale:helper", [name])
28
- # end
29
- # end
30
-
31
- # Rails::Generators::JobGenerator.class_eval do
32
- # def copy_locale_file
33
- # invoke("locale:job", [name])
34
- # end
35
- # end
36
-
37
- # Rails::Generators::MailerGenerator.class_eval do
38
- # def copy_locale_file
39
- # invoke("locale:mailer", [name])
40
- # end
41
- # end
42
-
43
- # Rails::Generators::ModelGenerator.class_eval do
44
- # def copy_locale_file
45
- # invoke("locale:model", [name])
46
- # end
47
- # end
35
+ %w(controller helper jbuilder job mailer model responders_controller task).each do |generator_name|
36
+ if ActiveGenerator.configuration.send("autoload_#{generator_name}_generator_locale")
37
+ begin
38
+ require "rails/generators/rails/#{generator_name}/#{generator_name}_generator"
39
+
40
+ "Rails::Generators::#{generator_name.to_s.camelize}Generator".constantize.class_eval do
41
+ def copy_locale_file
42
+ invoke("locale:#{generator_name}", [name])
43
+ invoke("locale:helper", [name]) if generator_name == "controller"
44
+ end
45
+ end
46
+ rescue LoadError => e
47
+ # Skip over missing files
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,23 @@
1
+ class ActiveGenerator::Configuration
2
+
3
+ attr_accessor :autoload_controller_generator_locale,
4
+ :autoload_helper_generator_locale,
5
+ :autoload_jbuilder_generator_locale,
6
+ :autoload_job_generator_locale,
7
+ :autoload_mailer_generator_locale,
8
+ :autoload_model_generator_locale,
9
+ :autoload_responders_controller_generator_locale,
10
+ :autoload_task_generator_locale
11
+
12
+ def initialize
13
+ @autoload_controller_generator_locale = true
14
+ @autoload_helper_generator_locale = true
15
+ @autoload_jbuilder_generator_locale = true
16
+ @autoload_job_generator_locale = true
17
+ @autoload_mailer_generator_locale = true
18
+ @autoload_model_generator_locale = true
19
+ @autoload_responders_controller_generator_locale = true
20
+ @autoload_task_generator_locale = true
21
+ end
22
+
23
+ end
@@ -1,3 +1,3 @@
1
1
  module ActiveGenerator
2
- VERSION = "2.0.4"
2
+ VERSION = "2.0.5"
3
3
  end
@@ -5,4 +5,4 @@ Example:
5
5
  rails generate locale:api NAME gb
6
6
 
7
7
  This will create:
8
- config/locales/en/apis/NAME.yml
8
+ config/locales/gb/apis/NAME.yml
@@ -5,4 +5,4 @@ Example:
5
5
  rails generate locale:controller NAME gb
6
6
 
7
7
  This will create:
8
- config/locales/en/controllers/NAME.yml
8
+ config/locales/gb/controllers/NAME.yml
@@ -5,4 +5,4 @@ Example:
5
5
  rails generate locale:helper NAME gb
6
6
 
7
7
  This will create:
8
- config/locales/en/helpers/NAME.yml
8
+ config/locales/gb/helpers/NAME.yml
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate a locale file for a jbuilder
3
+
4
+ Example:
5
+ rails generate locale:jbuilder NAME gb
6
+
7
+ This will create:
8
+ config/locales/gb/jbuilders/NAME.yml
@@ -0,0 +1,18 @@
1
+ require "active_generator/base"
2
+ require "generators/locale/base"
3
+
4
+ module Locale
5
+ class ControllerGenerator < Rails::Generators::NamedBase
6
+ include ActiveGenerator::Base
7
+ include Locale::Base
8
+
9
+ source_root File.expand_path('../templates', __FILE__)
10
+ argument :language, type: :string, required: false, default: "en", desc: "The locale alpha code"
11
+
12
+ def copy_jbuilder_file
13
+ assert_valid_language!
14
+ template("jbuilder.yml", "config/locales/#{language}/jbuilders/#{namespace_path}/#{file_name}.yml")
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,41 @@
1
+ #==================================================
2
+ # Table of Contents
3
+ #==================================================
4
+ # <%= namespace_human %>
5
+ <% if namespaced? -%>
6
+ # <%= file_name_human %>
7
+ # Actions
8
+ # Methods
9
+
10
+ <%= language %>:
11
+ jbuilders:
12
+ <%= namespace_table %>:
13
+ <%= file_name_table %>:
14
+
15
+ # Actions
16
+ #--------------------------------------------------
17
+ actions:
18
+ todo: "TODO"
19
+
20
+ # Methods
21
+ #--------------------------------------------------
22
+ methods:
23
+ todo: "TODO"
24
+ <% else -%>
25
+ # Actions
26
+ # Methods
27
+
28
+ <%= language %>:
29
+ jbuilders:
30
+ <%= file_name_table %>:
31
+
32
+ # Actions
33
+ #--------------------------------------------------
34
+ actions:
35
+ todo: "TODO"
36
+
37
+ # Methods
38
+ #--------------------------------------------------
39
+ methods:
40
+ todo: "TODO"
41
+ <% end -%>
@@ -5,4 +5,4 @@ Example:
5
5
  rails generate locale:job NAME gb
6
6
 
7
7
  This will create:
8
- config/locales/en/jobs/NAME.yml
8
+ config/locales/gb/jobs/NAME.yml
@@ -5,4 +5,4 @@ Example:
5
5
  rails generate locale:mailer NAME gb
6
6
 
7
7
  This will create:
8
- config/locales/en/mailers/NAME.yml
8
+ config/locales/gb/mailers/NAME.yml
@@ -5,4 +5,4 @@ Example:
5
5
  rails generate locale:model NAME gb
6
6
 
7
7
  This will create:
8
- config/locales/en/models/NAME.yml
8
+ config/locales/gb/models/NAME.yml
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate a locale file for a responders controller
3
+
4
+ Example:
5
+ rails generate locale:responders_controller NAME gb
6
+
7
+ This will create:
8
+ config/locales/gb/responder_controllers/NAME.yml
@@ -0,0 +1,18 @@
1
+ require "active_generator/base"
2
+ require "generators/locale/base"
3
+
4
+ module Locale
5
+ class RespondersControllerGenerator < Rails::Generators::NamedBase
6
+ include ActiveGenerator::Base
7
+ include Locale::Base
8
+
9
+ source_root File.expand_path('../templates', __FILE__)
10
+ argument :language, type: :string, required: false, default: "en", desc: "The locale alpha code"
11
+
12
+ def copy_responders_controller_file
13
+ assert_valid_language!
14
+ template("responders_controller.yml", "config/locales/#{language}/responders_controllers/#{namespace_path}/#{file_name}.yml")
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,41 @@
1
+ #==================================================
2
+ # Table of Contents
3
+ #==================================================
4
+ # <%= namespace_human %>
5
+ <% if namespaced? -%>
6
+ # <%= file_name_human %>
7
+ # Actions
8
+ # Methods
9
+
10
+ <%= language %>:
11
+ responder_controllers:
12
+ <%= namespace_table %>:
13
+ <%= file_name_table %>:
14
+
15
+ # Actions
16
+ #--------------------------------------------------
17
+ actions:
18
+ todo: "TODO"
19
+
20
+ # Methods
21
+ #--------------------------------------------------
22
+ methods:
23
+ todo: "TODO"
24
+ <% else -%>
25
+ # Actions
26
+ # Methods
27
+
28
+ <%= language %>:
29
+ responder_controllers:
30
+ <%= file_name_table %>:
31
+
32
+ # Actions
33
+ #--------------------------------------------------
34
+ actions:
35
+ todo: "TODO"
36
+
37
+ # Methods
38
+ #--------------------------------------------------
39
+ methods:
40
+ todo: "TODO"
41
+ <% end -%>
@@ -5,4 +5,4 @@ Example:
5
5
  rails generate locale:service NAME gb
6
6
 
7
7
  This will create:
8
- config/locales/en/services/NAME.yml
8
+ config/locales/gb/services/NAME.yml
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate a locale file for a task
3
+
4
+ Example:
5
+ rails generate locale:task NAME gb
6
+
7
+ This will create:
8
+ config/locales/gb/tasks/NAME.yml
@@ -0,0 +1,18 @@
1
+ require "active_generator/base"
2
+ require "generators/locale/base"
3
+
4
+ module Locale
5
+ class TaskGenerator < Rails::Generators::NamedBase
6
+ include ActiveGenerator::Base
7
+ include Locale::Base
8
+
9
+ source_root File.expand_path('../templates', __FILE__)
10
+ argument :language, type: :string, required: false, default: "en", desc: "The locale alpha code"
11
+
12
+ def copy_task_file
13
+ assert_valid_language!
14
+ template("task.yml", "config/locales/#{language}/tasks/#{file_name}.yml")
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ #==================================================
2
+ # Table of Contents
3
+ #==================================================
4
+ # <%= file_name_human %>
5
+ # Methods
6
+
7
+ <%= language %>:
8
+ task:
9
+ <%= file_name_table %>:
10
+
11
+ # Methods
12
+ #--------------------------------------------------
13
+ methods:
14
+ todo: "TODO"
@@ -5,4 +5,4 @@ Example:
5
5
  rails generate locale:uploader NAME gb
6
6
 
7
7
  This will create:
8
- config/locales/en/uploaders/NAME.yml
8
+ config/locales/gb/uploaders/NAME.yml
@@ -5,4 +5,4 @@ Example:
5
5
  rails generate locale:view NAME gb
6
6
 
7
7
  This will create:
8
- config/locales/en/views/NAME.yml
8
+ config/locales/gb/views/NAME.yml
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
@@ -129,6 +129,7 @@ files:
129
129
  - bin/setup
130
130
  - lib/active_generator.rb
131
131
  - lib/active_generator/base.rb
132
+ - lib/active_generator/configuration.rb
132
133
  - lib/active_generator/version.rb
133
134
  - lib/generators/environment/USAGE
134
135
  - lib/generators/environment/environment_generator.rb
@@ -146,6 +147,9 @@ files:
146
147
  - lib/generators/locale/helper/USAGE
147
148
  - lib/generators/locale/helper/helper_generator.rb
148
149
  - lib/generators/locale/helper/templates/helper.yml
150
+ - lib/generators/locale/jbuilder/USAGE
151
+ - lib/generators/locale/jbuilder/jbuilder_generator.rb
152
+ - lib/generators/locale/jbuilder/templates/jbuilder.yml
149
153
  - lib/generators/locale/job/USAGE
150
154
  - lib/generators/locale/job/job_generator.rb
151
155
  - lib/generators/locale/job/templates/job.yml
@@ -155,9 +159,15 @@ files:
155
159
  - lib/generators/locale/model/USAGE
156
160
  - lib/generators/locale/model/model_generator.rb
157
161
  - lib/generators/locale/model/templates/model.yml
162
+ - lib/generators/locale/responders_controller/USAGE
163
+ - lib/generators/locale/responders_controller/responders_controller_generator.rb
164
+ - lib/generators/locale/responders_controller/templates/responders_controller.yml
158
165
  - lib/generators/locale/service/USAGE
159
166
  - lib/generators/locale/service/service_generator.rb
160
167
  - lib/generators/locale/service/templates/service.yml
168
+ - lib/generators/locale/task/USAGE
169
+ - lib/generators/locale/task/task_generator.rb
170
+ - lib/generators/locale/task/templates/task.yml
161
171
  - lib/generators/locale/uploader/USAGE
162
172
  - lib/generators/locale/uploader/templates/uploader.yml
163
173
  - lib/generators/locale/uploader/uploader_generator.rb