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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 44de9f0654eceba8035b7f78df2c501840f62507
4
- data.tar.gz: 9e6e28cd6386142bdae69d01f6d61b1beb67fec1
3
+ metadata.gz: 17ac7910eb05461115ea5abc7d5946fd6120820c
4
+ data.tar.gz: 4d7b548e5b6d5bcb77b26f7646a291faa266d0b4
5
5
  SHA512:
6
- metadata.gz: 00c3c9d3aa43397d8fedca75dbef24c67ea0288d0ac4e249c0dc6fbac85c4b31935055407255638f342ee53523fa3f636a2fb5824db9d14f3f32b3142141fa0a
7
- data.tar.gz: 7d5b9c97f1de258cf0ab1430d31ce0a5d4fbb2fb0083db1153a4b256293ec718241e992971701e48ece81988ceaa88bef3a51e5ed54d0c032bc0c79b08a61f8f
6
+ metadata.gz: 42a3283c36187908a4dc969315d28186c4be067589cb30291e89fe6667c8cc814d9a704e770c9a46b699e5a46f9c0a56b70225ea8f083d61164a37a9808fc0d0
7
+ data.tar.gz: 535acb7bcf9452307ad84992f749e81ef413c779bdcfaaada65ac9e1f596a9660958888d30d62caa980510e72106b4a2cf9857618caa99066213f8d0cbc72170
data/.fasterer.yml ADDED
@@ -0,0 +1,19 @@
1
+ speedups:
2
+ rescue_vs_respond_to: true
3
+ module_eval: true
4
+ shuffle_first_vs_sample: true
5
+ for_loop_vs_each: true
6
+ each_with_index_vs_while: false
7
+ map_flatten_vs_flat_map: true
8
+ reverse_each_vs_reverse_each: true
9
+ select_first_vs_detect: true
10
+ sort_vs_sort_by: true
11
+ fetch_with_argument_vs_block: true
12
+ keys_each_vs_each_key: true
13
+ hash_merge_bang_vs_hash_brackets: true
14
+ block_vs_symbol_to_proc: true
15
+ proc_call_vs_yield: true
16
+ gsub_vs_tr: true
17
+ select_last_vs_reverse_detect: true
18
+ getter_vs_attr_reader: true
19
+ setter_vs_attr_writer: true
data/.flayignore ADDED
@@ -0,0 +1,2 @@
1
+ ./spec/lib/generators/**/*
2
+ ./spec/support/generators/**/*
data/.reek ADDED
@@ -0,0 +1,20 @@
1
+ ---
2
+ exclude_paths:
3
+ - lib/generators/environment/templates
4
+ - lib/generators/service/templates
5
+ Attribute:
6
+ enabled: false
7
+ IrresponsibleModule:
8
+ enabled: false
9
+ NilCheck:
10
+ enabled: false
11
+ ManualDispatch:
12
+ enabled: false
13
+ NestedIterators:
14
+ max_allowed_nesting: 2
15
+ PrimaDonnaMethod:
16
+ enabled: false
17
+ TooManyStatements:
18
+ max_statements: 10
19
+ UtilityFunction:
20
+ enabled: false
data/.rubocop.yml ADDED
@@ -0,0 +1,37 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ DisplayStyleGuide: true
4
+ TargetRubyVersion: 2.3
5
+ Exclude:
6
+ - 'lib/generators/environment/templates/*'
7
+ - 'lib/generators/initializer/templates/*'
8
+ - 'lib/generators/service/templates/*'
9
+ - 'spec/support/**/*'
10
+ LineLength:
11
+ Max: 120
12
+ Rails/Delegate:
13
+ Enabled: false
14
+ Rails/Output:
15
+ Enabled: false
16
+ Style/Alias:
17
+ EnforcedStyle: prefer_alias_method
18
+ Style/BracesAroundHashParameters:
19
+ Enabled: false
20
+ Style/ClosingParenthesisIndentation:
21
+ Enabled: false
22
+ Style/Documentation:
23
+ Enabled: false
24
+ Style/EmptyLinesAroundBlockBody:
25
+ Enabled: false
26
+ Style/EmptyLinesAroundClassBody:
27
+ Enabled: false
28
+ Style/EmptyLinesAroundModuleBody:
29
+ Enabled: false
30
+ Style/FirstParameterIndentation:
31
+ Enabled: false
32
+ Style/FrozenStringLiteralComment:
33
+ Enabled: false
34
+ Style/MultilineMethodCallIndentation:
35
+ EnforcedStyle: aligned
36
+ Style/RescueModifier:
37
+ Enabled: false
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in active_generator.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -11,7 +11,7 @@ ActiveGenerator extends the base rails generators with commonly used generators.
11
11
  Add this line to your application's Gemfile:
12
12
 
13
13
  ```ruby
14
- gem "active_generator"
14
+ gem 'active_generator'
15
15
  ```
16
16
 
17
17
  And then execute:
@@ -35,33 +35,21 @@ Or install it yourself as:
35
35
 
36
36
  Generates an environment file in the `config/initalizers` directory.
37
37
 
38
- **Options:**
39
- * autoload_controller_generator_locale
40
- * autoload_helper_generator_locale
41
- * autoload_job_generator_locale
42
- * autoload_mailer_generator_locale
43
- * autoload_model_generator_locale
44
- * autoload_service_generator_locale
45
- * autoload_task_generator_locale
46
- * autoload_view_generator_locale
47
-
48
38
  `rails generate active_generator:install` will generate the following `active_generator.rb` file:
49
39
 
50
40
  ```ruby
51
41
  # config/initalizers/active_generator.rb
52
42
 
53
- ActiveGenerator.configure do |config|
54
- # option = default
55
-
43
+ ActiveGenerator::Settings.configure do |config|
56
44
  config.autoload_controller_generator_locale = true
57
- config.autoload_helper_generator_locale = true
58
- config.autoload_job_generator_locale = true
59
- config.autoload_mailer_generator_locale = true
60
- config.autoload_model_generator_locale = true
61
- config.autoload_service_generator_locale = true
62
- config.autoload_task_generator_locale = true
63
- config.autoload_view_generator_locale = true
64
- config.test_framework = "test_unit"
45
+ config.autoload_helper_generator_locale = true
46
+ config.autoload_job_generator_locale = true
47
+ config.autoload_mailer_generator_locale = true
48
+ config.autoload_model_generator_locale = true
49
+ config.autoload_service_generator_locale = true
50
+ config.autoload_task_generator_locale = true
51
+ config.autoload_view_generator_locale = true
52
+ config.test_framework = 'test_unit'
65
53
  end
66
54
  ```
67
55
 
@@ -137,12 +125,12 @@ en-GB:
137
125
  # Actions
138
126
  #--------------------------------------------------
139
127
  actions:
140
- todo: "TODO"
128
+ todo: 'TODO'
141
129
 
142
130
  # Methods
143
131
  #--------------------------------------------------
144
132
  methods:
145
- todo: "TODO"
133
+ todo: 'TODO'
146
134
  ```
147
135
 
148
136
  ## Service
data/Rakefile CHANGED
@@ -1,3 +1,3 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
2
 
3
3
  task default: :spec
@@ -1,29 +1,33 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
2
+ lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "active_generator/version"
4
+ require 'active_generator/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "active_generator"
7
+ spec.name = 'active_generator'
8
8
  spec.version = ActiveGenerator::VERSION
9
- spec.authors = ["Juan Gomez"]
10
- spec.email = ["j.gomez@drexed.com"]
9
+ spec.authors = ['Juan Gomez']
10
+ spec.email = ['j.gomez@drexed.com']
11
11
 
12
- spec.summary = %q{Gem for commonly used generators.}
13
- spec.description = %q{Extend the base rails generators with commonly used generators.}
14
- spec.homepage = "http://drexed.github.io/active_generator"
15
- spec.license = "MIT"
12
+ spec.summary = 'Gem for commonly used generators.'
13
+ spec.description = 'Extend the base rails generators with commonly used generators.'
14
+ spec.homepage = 'http://drexed.github.io/active_generator'
15
+ spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
18
+ spec.bindir = 'exe'
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
20
+ spec.require_paths = ['lib']
21
21
 
22
- spec.add_runtime_dependency "rails"
22
+ spec.add_runtime_dependency 'rails'
23
23
 
24
- spec.add_development_dependency "bundler"
25
- spec.add_development_dependency "coveralls"
26
- spec.add_development_dependency "rake"
27
- spec.add_development_dependency "rspec"
28
- spec.add_development_dependency "generator_spec"
24
+ spec.add_development_dependency 'bundler'
25
+ spec.add_development_dependency 'coveralls'
26
+ spec.add_development_dependency 'rake'
27
+ spec.add_development_dependency 'rspec'
28
+ spec.add_development_dependency 'generator_spec'
29
+ spec.add_development_dependency 'fasterer'
30
+ spec.add_development_dependency 'flay'
31
+ spec.add_development_dependency 'reek'
32
+ spec.add_development_dependency 'rubocop'
29
33
  end
data/bin/console CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "active_generator"
3
+ require 'bundler/setup'
4
+ require 'active_generator'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
9
  # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
10
+ # require 'pry'
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start
data/bin/rake CHANGED
@@ -2,15 +2,14 @@
2
2
  #
3
3
  # This file was generated by Bundler.
4
4
  #
5
- # The application "rake" is installed as part of a gem, and
5
+ # The application 'rake' is installed as part of a gem, and
6
6
  # this file is here to facilitate running it.
7
7
  #
8
8
 
9
- require "pathname"
10
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', Pathname.new(__FILE__).realpath)
12
11
 
13
- require "rubygems"
14
- require "bundler/setup"
12
+ require 'rubygems'
13
+ require 'bundler/setup'
15
14
 
16
- load Gem.bin_path("rake", "rake")
15
+ load Gem.bin_path('rake', 'rake')
@@ -1,38 +1,14 @@
1
- require "rails/generators"
2
-
3
- require "active_generator/version"
4
- require "active_generator/configuration"
5
-
6
- module ActiveGenerator
7
-
8
- class << self
9
- attr_accessor :configuration
10
- end
11
-
12
- def self.configuration
13
- @configuration ||= Configuration.new
14
- end
15
-
16
- def self.configuration=(config)
17
- @configuration = config
18
- end
19
-
20
- def self.configure
21
- yield(configuration)
22
- end
23
-
24
- end
25
-
26
- require "generators/active_generator/install/install_generator"
1
+ require 'rails/generators'
2
+ require 'active_generator/version'
3
+ require 'active_generator/settings'
4
+ require 'generators/active_generator/install/install_generator'
27
5
 
28
6
  %w(environment initializer service view).each do |generator_name|
29
7
  require "generators/#{generator_name}/#{generator_name}_generator"
30
8
  end
31
-
32
9
  %w(api controller helper job mailer model service task uploader view).each do |generator_name|
33
10
  require "generators/locale/#{generator_name}/#{generator_name}_generator"
34
11
  end
35
-
36
12
  %w(controller helper job mailer model scaffold task).each do |generator_name|
37
13
  require "generators/rails/#{generator_name}_generator"
38
14
  end
@@ -8,27 +8,27 @@ module ActiveGenerator
8
8
  end
9
9
 
10
10
  def file_name_human
11
- file_name_table.gsub("_".freeze, " ".freeze).downcase.capitalize
11
+ file_name_table.tr('_', ' ').downcase.capitalize
12
12
  end
13
13
 
14
14
  def namespace
15
- name.downcase.split("/".freeze)[0...-1]
15
+ name.downcase.split('/')[0...-1]
16
16
  end
17
17
 
18
18
  def namespaced?
19
- name.include?("/".freeze)
19
+ name.include?('/')
20
20
  end
21
21
 
22
22
  def namespace_human
23
- namespace.join(" ".freeze).gsub("_".freeze, " ".freeze).downcase.capitalize
23
+ namespace.join(' ').tr('_', ' ').downcase.capitalize
24
24
  end
25
25
 
26
26
  def namespace_table
27
- namespace.join("_".freeze)
27
+ namespace.join('_')
28
28
  end
29
29
 
30
30
  def namespace_path
31
- namespace.join("/".freeze)
31
+ namespace.join('/')
32
32
  end
33
33
 
34
34
  end
@@ -0,0 +1,18 @@
1
+ require 'dry-configurable'
2
+
3
+ module ActiveGenerator
4
+ class Settings
5
+ extend Dry::Configurable
6
+
7
+ setting :autoload_controller_generator_locale, true
8
+ setting :autoload_helper_generator_locale, true
9
+ setting :autoload_job_generator_locale, true
10
+ setting :autoload_mailer_generator_locale, true
11
+ setting :autoload_model_generator_locale, true
12
+ setting :autoload_service_generator_locale, true
13
+ setting :autoload_task_generator_locale, true
14
+ setting :autoload_view_generator_locale, true
15
+ setting :test_framework, 'test_unit'
16
+
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module ActiveGenerator
2
- VERSION = "3.0.0"
2
+ VERSION = '4.0.0'.freeze
3
3
  end
@@ -1,9 +1,9 @@
1
1
  module ActiveGenerator
2
2
  class InstallGenerator < Rails::Generators::Base
3
- source_root File.expand_path("../templates", __FILE__)
3
+ source_root File.expand_path('../templates', __FILE__)
4
4
 
5
5
  def copy_initializer_file
6
- copy_file("install.rb", "config/initializers/active_generator.rb")
6
+ copy_file('install.rb', 'config/initializers/active_generator.rb')
7
7
  end
8
8
 
9
9
  end
@@ -1,4 +1,4 @@
1
- ActiveGenerator.configure do |config|
1
+ ActiveGenerator::Settings.configure do |config|
2
2
  config.autoload_controller_generator_locale = true
3
3
  config.autoload_helper_generator_locale = true
4
4
  config.autoload_job_generator_locale = true
@@ -7,5 +7,5 @@ ActiveGenerator.configure do |config|
7
7
  config.autoload_service_generator_locale = true
8
8
  config.autoload_task_generator_locale = true
9
9
  config.autoload_view_generator_locale = true
10
- config.test_framework = "test_unit"
10
+ config.test_framework = 'test_unit'
11
11
  end
@@ -1,15 +1,15 @@
1
1
  class EnvironmentGenerator < Rails::Generators::NamedBase
2
- source_root File.expand_path("../templates", __FILE__)
3
- argument :environment, type: :string, required: false, default: nil, desc: "The environment template to copy"
2
+ source_root File.expand_path('../templates', __FILE__)
3
+ argument :environment, type: :string, required: false, default: nil, desc: 'The environment template to copy'
4
4
 
5
5
  def create_environment_file
6
6
  assert_valid_environment!
7
- template("environment.rb", File.join("config/environments", class_path, "#{file_name}.rb"))
7
+ template('environment.rb', File.join('config/environments', class_path, "#{file_name}.rb"))
8
8
  end
9
9
 
10
10
  private
11
11
 
12
- ENVIRONMENTS = %w(development test production)
12
+ ENVIRONMENTS = %w(development test production).freeze
13
13
 
14
14
  ENVIRONMENTS.each do |env|
15
15
  define_method("#{env}?") { environment == env }
@@ -19,7 +19,7 @@ class EnvironmentGenerator < Rails::Generators::NamedBase
19
19
  unless environment.nil?
20
20
  unless ENVIRONMENTS.include?(environment)
21
21
  raise ArgumentError,
22
- "Unknown environment: #{environment.inspect}. Valid environments are: #{ENVIRONMENTS.map(&:inspect).join(', ')}"
22
+ "Unknown environment: #{environment.inspect}. Valid options: #{ENVIRONMENTS.map(&:inspect).join(', ')}"
23
23
  end
24
24
  end
25
25
  end
@@ -1,8 +1,8 @@
1
1
  class InitializerGenerator < Rails::Generators::NamedBase
2
- source_root File.expand_path("../templates", __FILE__)
2
+ source_root File.expand_path('../templates', __FILE__)
3
3
 
4
4
  def copy_initializer_file
5
- copy_file("initializer.rb", File.join("config/initializers", class_path, "#{file_name}.rb"))
5
+ copy_file('initializer.rb', File.join('config/initializers', class_path, "#{file_name}.rb"))
6
6
  end
7
7
 
8
8
  end