active_generator 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +9 -0
  4. data/.rspec +4 -0
  5. data/.travis.yml +13 -0
  6. data/CODE_OF_CONDUCT.md +13 -0
  7. data/Gemfile +4 -0
  8. data/README.md +112 -0
  9. data/Rakefile +3 -0
  10. data/active_generator.gemspec +30 -0
  11. data/bin/console +14 -0
  12. data/bin/rake +16 -0
  13. data/bin/setup +7 -0
  14. data/lib/active_generator/base.rb +31 -0
  15. data/lib/active_generator/version.rb +3 -0
  16. data/lib/active_generator.rb +9 -0
  17. data/lib/generators/initializer/USAGE +8 -0
  18. data/lib/generators/initializer/initializer_generator.rb +10 -0
  19. data/lib/generators/initializer/templates/initializer.rb +2 -0
  20. data/lib/generators/locale/api/USAGE +8 -0
  21. data/lib/generators/locale/api/api_generator.rb +18 -0
  22. data/lib/generators/locale/api/templates/api.yml +29 -0
  23. data/lib/generators/locale/base.rb +14 -0
  24. data/lib/generators/locale/controller/USAGE +8 -0
  25. data/lib/generators/locale/controller/controller_generator.rb +18 -0
  26. data/lib/generators/locale/controller/templates/controller.yml +41 -0
  27. data/lib/generators/locale/helper/USAGE +8 -0
  28. data/lib/generators/locale/helper/helper_generator.rb +18 -0
  29. data/lib/generators/locale/helper/templates/helper.yml +31 -0
  30. data/lib/generators/locale/job/USAGE +8 -0
  31. data/lib/generators/locale/job/job_generator.rb +18 -0
  32. data/lib/generators/locale/job/templates/job.yml +14 -0
  33. data/lib/generators/locale/mailer/USAGE +8 -0
  34. data/lib/generators/locale/mailer/mailer_generator.rb +18 -0
  35. data/lib/generators/locale/mailer/templates/mailer.yml +14 -0
  36. data/lib/generators/locale/model/USAGE +8 -0
  37. data/lib/generators/locale/model/model_generator.rb +18 -0
  38. data/lib/generators/locale/model/templates/model.yml +20 -0
  39. data/lib/generators/locale/service/USAGE +8 -0
  40. data/lib/generators/locale/service/service_generator.rb +18 -0
  41. data/lib/generators/locale/service/templates/service.yml +31 -0
  42. data/lib/generators/locale/uploader/USAGE +8 -0
  43. data/lib/generators/locale/uploader/templates/uploader.yml +14 -0
  44. data/lib/generators/locale/uploader/uploader_generator.rb +18 -0
  45. data/lib/generators/locale/view/USAGE +8 -0
  46. data/lib/generators/locale/view/templates/view.yml +41 -0
  47. data/lib/generators/locale/view/view_generator.rb +18 -0
  48. data/lib/generators/service/USAGE +8 -0
  49. data/lib/generators/service/service_generator.rb +17 -0
  50. data/lib/generators/service/templates/service.rb +4 -0
  51. metadata +191 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dc46a45887393e529f431d9f4f10c9726eff7eeb
4
+ data.tar.gz: a4f3364b49a84ca7ebf47950060dbf6852f180de
5
+ SHA512:
6
+ metadata.gz: 9f268916a82805ef33d95990549459d400f5b709311ccfe2a2e378d3bb2a001b52cab32ca860b658cc36c3baa046805f9c99e4d4bb35df78aa40852b80bf0093
7
+ data.tar.gz: 8532683147bccf69a90d508eaf7b864aff2baeb87c09a48670818b259a1386c2f24a1c873616c316950f3fe2084931bdad9d862cabee2df81b45016909ed6a4d
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --backtrace
2
+ --color
3
+ --format progress
4
+ --order random
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ before_install:
2
+ - sudo apt-get install libxml2-dev
3
+ cache: bundler
4
+ language: ruby
5
+ notifications:
6
+ email:
7
+ recipients:
8
+ - j.gomez@drexed.com
9
+ on_failure: change
10
+ on_success: never
11
+ rvm:
12
+ - ruby-head
13
+ script: 'bundle exec rake'
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in active_generator.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # ActiveGenerator
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/active_generator.svg)](http://badge.fury.io/rb/active_generator)
4
+ [![Build Status](https://travis-ci.org/drexed/active_generator.svg?branch=master)](https://travis-ci.org/drexed/active_generator)
5
+ [![Coverage Status](https://coveralls.io/repos/drexed/active_generator/badge.png)](https://coveralls.io/r/drexed/active_generator)
6
+
7
+ ActiveGenerator extends the base rails generators with commonly used generators.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'active_generator'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install active_generator
24
+
25
+ ## Table of Contents
26
+
27
+ * [Initializer](#initializer)
28
+ * [Locale](#locale)
29
+ * [Service](#service)
30
+
31
+ ## Initializer
32
+
33
+ Generates an initializer file in the `config/initializer` directory.
34
+
35
+ `rails generate initializer stripe` will generate the following `stripe.rb` file:
36
+
37
+ ```ruby
38
+ # config/initializer/stripe.rb
39
+
40
+ # TODO:
41
+ # Add initializer code here.
42
+ ```
43
+
44
+ ## Locale
45
+
46
+ Generates an initializer file in the `config/locales` directory.
47
+
48
+ **Generators:**
49
+ * api
50
+ * controller
51
+ * helper
52
+ * job
53
+ * mailer
54
+ * model
55
+ * service
56
+ * uploader
57
+ * view
58
+
59
+ **Options:**
60
+ * language: 2, 4, 6, and 6 character prefix
61
+
62
+ `rails generate locale:controller admin/user en-GB` will generate the following `user.yml` file:
63
+
64
+ ```ruby
65
+ # config/locales/en-GB/controller/admin/user.yml
66
+
67
+ #==================================================
68
+ # Table of Contents
69
+ #==================================================
70
+ # Test
71
+ # V1
72
+ # Actions
73
+ # Methods
74
+
75
+ en-GB:
76
+ test:
77
+ v1:
78
+ controllers:
79
+
80
+ # Actions
81
+ #--------------------------------------------------
82
+ actions:
83
+ todo: "TODO"
84
+
85
+ # Methods
86
+ #--------------------------------------------------
87
+ methods:
88
+ todo: "TODO"
89
+ ```
90
+
91
+ ## Service
92
+
93
+ Generates an service file in the `app/services` directory.
94
+
95
+ `rails generate service social/twitter` will generate the following `twitter.rb` file:
96
+
97
+ ```ruby
98
+ # app/services/social/twitter.rb
99
+
100
+ class Social::Twitter
101
+ # TODO:
102
+ # Add service code here.
103
+ end
104
+ ```
105
+
106
+ ## Contributing
107
+
108
+ 1. Fork it ( https://github.com/[my-github-username]/active_generator/fork )
109
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
110
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
111
+ 4. Push to the branch (`git push origin my-new-feature`)
112
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task default: :spec
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'active_generator/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "active_generator"
8
+ spec.version = ActiveGenerator::VERSION
9
+ spec.authors = ["Juan Gomez"]
10
+ spec.email = ["j.gomez@drexed.com"]
11
+
12
+ spec.summary = %q{Commonly used generators.}
13
+ spec.description = %q{Extend the base rails generators with commonly used generators.}
14
+ spec.homepage = "https://github.com/drexed/active_generator"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_runtime_dependency "rails"
23
+ spec.add_runtime_dependency "active_object"
24
+
25
+ spec.add_development_dependency "bundler"
26
+ spec.add_development_dependency "coveralls"
27
+ spec.add_development_dependency "rake"
28
+ spec.add_development_dependency "rspec"
29
+ spec.add_development_dependency "generator_spec"
30
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "active_generator"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/rake ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rake' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rake', 'rake')
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+ module ActiveGenerator
2
+ module Base
3
+
4
+ private
5
+
6
+ def file_name_table
7
+ file_name.tableize
8
+ end
9
+
10
+ def namespace
11
+ name.downcase.split("/").delete_last
12
+ end
13
+
14
+ def namespaced?
15
+ name.include?("/")
16
+ end
17
+
18
+ def namespace_human
19
+ namespace.map { |w| w.capitalize }.join(" ")
20
+ end
21
+
22
+ def namespace_table
23
+ namespace.join("_")
24
+ end
25
+
26
+ def namespace_path
27
+ namespace.join("/") if namespaced?
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,3 @@
1
+ module ActiveGenerator
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,9 @@
1
+ require "active_object"
2
+ require "active_generator/version"
3
+
4
+ require "generators/initializer/initializer_generator"
5
+ require "generators/service/service_generator"
6
+
7
+ %w(api controller helper job mailer model service uploader view).each do |name|
8
+ require "generators/locale/#{name}/#{name}_generator"
9
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate an initializer file
3
+
4
+ Example:
5
+ rails generate initializer NAME
6
+
7
+ This will create:
8
+ config/initializers/NAME.yml
@@ -0,0 +1,10 @@
1
+ require "generators/locale/base"
2
+
3
+ class InitializerGenerator < Rails::Generators::NamedBase
4
+ source_root File.expand_path('../templates', __FILE__)
5
+
6
+ def copy_initializer_file
7
+ copy_file("initializer.rb", "config/initializers/#{file_name}.rb")
8
+ end
9
+
10
+ end
@@ -0,0 +1,2 @@
1
+ # TODO:
2
+ # Add initializer code here.
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate a locale file for an API
3
+
4
+ Example:
5
+ rails generate locale:api NAME gb
6
+
7
+ This will create:
8
+ config/locales/en/apis/NAME.yml
@@ -0,0 +1,18 @@
1
+ require "active_generator/base"
2
+ require "generators/locale/base"
3
+
4
+ module Locale
5
+ class ApiGenerator < 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_api_file
13
+ assert_valid_language!
14
+ template("api.yml", "config/locales/#{language}/apis/#{namespace_path}/#{file_name}.yml")
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,29 @@
1
+ #==================================================
2
+ # Table of Contents
3
+ #==================================================
4
+ # <%= file_name_table %>
5
+ <% if namespaced? -%>
6
+ # <%= namespace_human %>
7
+ # Methods
8
+
9
+ <%= language %>:
10
+ <%= namespace_table %>:
11
+ <%= file_name_table %>:
12
+ apis:
13
+
14
+ # Methods
15
+ #--------------------------------------------------
16
+ methods:
17
+ todo: "TODO"
18
+ <% else -%>
19
+ # Methods
20
+
21
+ <%= language %>:
22
+ <%= file_name_table %>:
23
+ apis:
24
+
25
+ # Methods
26
+ #--------------------------------------------------
27
+ methods:
28
+ todo: "TODO"
29
+ <% end -%>
@@ -0,0 +1,14 @@
1
+ module Locale
2
+ module Base
3
+
4
+ private
5
+
6
+ def assert_valid_language!
7
+ unless [2, 4, 5, 6].include?(language.size) && (language =~ /^[A-Za-z-]+$/)
8
+ raise ArgumentError,
9
+ "Unknown language format: '#{language}'. Valid format example is: 'en'"
10
+ end
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate a locale file for a controller
3
+
4
+ Example:
5
+ rails generate locale:controller NAME gb
6
+
7
+ This will create:
8
+ config/locales/en/controllers/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_controller_file
13
+ assert_valid_language!
14
+ template("controller.yml", "config/locales/#{language}/controllers/#{namespace_path}/#{file_name}.yml")
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,41 @@
1
+ #==================================================
2
+ # Table of Contents
3
+ #==================================================
4
+ # <%= file_name_table %>
5
+ <% if namespaced? -%>
6
+ # <%= namespace_human %>
7
+ # Actions
8
+ # Methods
9
+
10
+ <%= language %>:
11
+ <%= namespace_table %>:
12
+ <%= file_name_table %>:
13
+ controllers:
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
+ <%= file_name_table %>:
30
+ controllers:
31
+
32
+ # Actions
33
+ #--------------------------------------------------
34
+ actions:
35
+ todo: "TODO"
36
+
37
+ # Methods
38
+ #--------------------------------------------------
39
+ methods:
40
+ todo: "TODO"
41
+ <% end -%>
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate a locale file for a helper
3
+
4
+ Example:
5
+ rails generate locale:helper NAME gb
6
+
7
+ This will create:
8
+ config/locales/en/helpers/NAME.yml
@@ -0,0 +1,18 @@
1
+ require "active_generator/base"
2
+ require "generators/locale/base"
3
+
4
+ module Locale
5
+ class HelperGenerator < 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_helper_file
13
+ assert_valid_language!
14
+ template("helper.yml", "config/locales/#{language}/helpers/#{namespace_path}/#{file_name}.yml")
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,31 @@
1
+ #==================================================
2
+ # Table of Contents
3
+ #==================================================
4
+ # <%= file_name_table %>
5
+ <% if namespaced? -%>
6
+ # <%= namespace_human %>
7
+ # Actions
8
+ # Concerns
9
+
10
+ <%= language %>:
11
+ <%= namespace_table %>:
12
+ <%= file_name_table %>:
13
+ helpers:
14
+
15
+ # Methods
16
+ #--------------------------------------------------
17
+ methods:
18
+ todo: "TODO"
19
+ <% else -%>
20
+ # Actions
21
+ # Concerns
22
+
23
+ <%= language %>:
24
+ <%= file_name_table %>:
25
+ helpers:
26
+
27
+ # Methods
28
+ #--------------------------------------------------
29
+ methods:
30
+ todo: "TODO"
31
+ <% end -%>
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate a locale file for a job
3
+
4
+ Example:
5
+ rails generate locale:job NAME gb
6
+
7
+ This will create:
8
+ config/locales/en/jobs/NAME.yml
@@ -0,0 +1,18 @@
1
+ require "active_generator/base"
2
+ require "generators/locale/base"
3
+
4
+ module Locale
5
+ class JobGenerator < 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_job_file
13
+ assert_valid_language!
14
+ template("job.yml", "config/locales/#{language}/jobs/#{file_name}.yml")
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ #==================================================
2
+ # Table of Contents
3
+ #==================================================
4
+ # <%= file_name_table %>
5
+ # Methods
6
+
7
+ <%= language %>:
8
+ <%= file_name_table %>:
9
+ jobs:
10
+
11
+ # Methods
12
+ #--------------------------------------------------
13
+ methods:
14
+ todo: "TODO"
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate a locale file for a mailer
3
+
4
+ Example:
5
+ rails generate locale:mailer NAME gb
6
+
7
+ This will create:
8
+ config/locales/en/mailers/NAME.yml
@@ -0,0 +1,18 @@
1
+ require "active_generator/base"
2
+ require "generators/locale/base"
3
+
4
+ module Locale
5
+ class MailerGenerator < 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_mailer_file
13
+ assert_valid_language!
14
+ template("mailer.yml", "config/locales/#{language}/mailers/#{file_name}.yml")
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ #==================================================
2
+ # Table of Contents
3
+ #==================================================
4
+ # <%= file_name_table %>
5
+ # Methods
6
+
7
+ <%= language %>:
8
+ <%= file_name_table %>:
9
+ mailers:
10
+
11
+ # Methods
12
+ #--------------------------------------------------
13
+ methods:
14
+ todo: "TODO"
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate a locale file for a model
3
+
4
+ Example:
5
+ rails generate locale:model NAME gb
6
+
7
+ This will create:
8
+ config/locales/en/models/NAME.yml
@@ -0,0 +1,18 @@
1
+ require "active_generator/base"
2
+ require "generators/locale/base"
3
+
4
+ module Locale
5
+ class ModelGenerator < 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_model_file
13
+ assert_valid_language!
14
+ template("model.yml", "config/locales/#{language}/models/#{file_name}.yml")
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ #==================================================
2
+ # Table of Contents
3
+ #==================================================
4
+ # <%= file_name_table %>
5
+ # Attributes
6
+ # Methods
7
+
8
+ <%= language %>:
9
+ <%= file_name_table %>:
10
+ models:
11
+
12
+ # Attributes
13
+ #--------------------------------------------------
14
+ attr:
15
+ todo: "TODO"
16
+
17
+ # Methods
18
+ #--------------------------------------------------
19
+ methods:
20
+ todo: "TODO"
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate a locale file for a service
3
+
4
+ Example:
5
+ rails generate locale:service NAME gb
6
+
7
+ This will create:
8
+ config/locales/en/services/NAME.yml
@@ -0,0 +1,18 @@
1
+ require "active_generator/base"
2
+ require "generators/locale/base"
3
+
4
+ module Locale
5
+ class ServiceGenerator < 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_service_file
13
+ assert_valid_language!
14
+ template("service.yml", "config/locales/#{language}/services/#{namespace_path}/#{file_name}.yml")
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,31 @@
1
+ #==================================================
2
+ # Table of Contents
3
+ #==================================================
4
+ # <%= file_name_table %>
5
+ <% if namespaced? -%>
6
+ # <%= namespace_human %>
7
+ # Actions
8
+ # Concerns
9
+
10
+ <%= language %>:
11
+ <%= namespace_table %>:
12
+ <%= file_name_table %>:
13
+ services:
14
+
15
+ # Methods
16
+ #--------------------------------------------------
17
+ methods:
18
+ todo: "TODO"
19
+ <% else -%>
20
+ # Actions
21
+ # Concerns
22
+
23
+ <%= language %>:
24
+ <%= file_name_table %>:
25
+ services:
26
+
27
+ # Methods
28
+ #--------------------------------------------------
29
+ methods:
30
+ todo: "TODO"
31
+ <% end -%>
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate a locale file for an uploader
3
+
4
+ Example:
5
+ rails generate locale:uploader NAME gb
6
+
7
+ This will create:
8
+ config/locales/en/uploaders/NAME.yml
@@ -0,0 +1,14 @@
1
+ #==================================================
2
+ # Table of Contents
3
+ #==================================================
4
+ # <%= file_name_table %>
5
+ # Methods
6
+
7
+ <%= language %>:
8
+ <%= file_name_table %>:
9
+ uploaders:
10
+
11
+ # Methods
12
+ #--------------------------------------------------
13
+ methods:
14
+ todo: "TODO"
@@ -0,0 +1,18 @@
1
+ require "active_generator/base"
2
+ require "generators/locale/base"
3
+
4
+ module Locale
5
+ class UploaderGenerator < 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_uploader_file
13
+ assert_valid_language!
14
+ template("uploader.yml", "config/locales/#{language}/uploaders/#{file_name}.yml")
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate a locale file for a view
3
+
4
+ Example:
5
+ rails generate locale:view NAME gb
6
+
7
+ This will create:
8
+ config/locales/en/views/NAME.yml
@@ -0,0 +1,41 @@
1
+ #==================================================
2
+ # Table of Contents
3
+ #==================================================
4
+ # <%= file_name_table %>
5
+ <% if namespaced? -%>
6
+ # <%= namespace_human %>
7
+ # Actions
8
+ # Concerns
9
+
10
+ <%= language %>:
11
+ <%= namespace_table %>:
12
+ <%= file_name_table %>:
13
+ views:
14
+
15
+ # Actions
16
+ #--------------------------------------------------
17
+ actions:
18
+ todo: "TODO"
19
+
20
+ # Concerns
21
+ #--------------------------------------------------
22
+ concerns:
23
+ todo: "TODO"
24
+ <% else -%>
25
+ # Actions
26
+ # Concerns
27
+
28
+ <%= language %>:
29
+ <%= file_name_table %>:
30
+ views:
31
+
32
+ # Actions
33
+ #--------------------------------------------------
34
+ actions:
35
+ todo: "TODO"
36
+
37
+ # Concerns
38
+ #--------------------------------------------------
39
+ concerns:
40
+ todo: "TODO"
41
+ <% end -%>
@@ -0,0 +1,18 @@
1
+ require "active_generator/base"
2
+ require "generators/locale/base"
3
+
4
+ module Locale
5
+ class ViewGenerator < 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_view_file
13
+ assert_valid_language!
14
+ template("view.yml", "config/locales/#{language}/views/#{namespace_path}/#{file_name}.yml")
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate a service file
3
+
4
+ Example:
5
+ rails generate service NAME
6
+
7
+ This will create:
8
+ config/services/NAME.yml
@@ -0,0 +1,17 @@
1
+ require "active_generator/base"
2
+ require "generators/locale/base"
3
+
4
+ class ServiceGenerator < Rails::Generators::NamedBase
5
+ include ActiveGenerator::Base
6
+
7
+ source_root File.expand_path('../templates', __FILE__)
8
+
9
+ def copy_service_file
10
+ template("service.rb", "app/services/#{namespace_path}/#{file_name}.rb")
11
+ end
12
+
13
+ def generate_service_locale_file
14
+ invoke("locale:service", [name])
15
+ end
16
+
17
+ end
@@ -0,0 +1,4 @@
1
+ class <%= class_name %>
2
+ # TODO:
3
+ # Add service code here.
4
+ end
metadata ADDED
@@ -0,0 +1,191 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active_generator
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Juan Gomez
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: active_object
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: generator_spec
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
+ description: Extend the base rails generators with commonly used generators.
112
+ email:
113
+ - j.gomez@drexed.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".coveralls.yml"
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".travis.yml"
122
+ - CODE_OF_CONDUCT.md
123
+ - Gemfile
124
+ - README.md
125
+ - Rakefile
126
+ - active_generator.gemspec
127
+ - bin/console
128
+ - bin/rake
129
+ - bin/setup
130
+ - lib/active_generator.rb
131
+ - lib/active_generator/base.rb
132
+ - lib/active_generator/version.rb
133
+ - lib/generators/initializer/USAGE
134
+ - lib/generators/initializer/initializer_generator.rb
135
+ - lib/generators/initializer/templates/initializer.rb
136
+ - lib/generators/locale/api/USAGE
137
+ - lib/generators/locale/api/api_generator.rb
138
+ - lib/generators/locale/api/templates/api.yml
139
+ - lib/generators/locale/base.rb
140
+ - lib/generators/locale/controller/USAGE
141
+ - lib/generators/locale/controller/controller_generator.rb
142
+ - lib/generators/locale/controller/templates/controller.yml
143
+ - lib/generators/locale/helper/USAGE
144
+ - lib/generators/locale/helper/helper_generator.rb
145
+ - lib/generators/locale/helper/templates/helper.yml
146
+ - lib/generators/locale/job/USAGE
147
+ - lib/generators/locale/job/job_generator.rb
148
+ - lib/generators/locale/job/templates/job.yml
149
+ - lib/generators/locale/mailer/USAGE
150
+ - lib/generators/locale/mailer/mailer_generator.rb
151
+ - lib/generators/locale/mailer/templates/mailer.yml
152
+ - lib/generators/locale/model/USAGE
153
+ - lib/generators/locale/model/model_generator.rb
154
+ - lib/generators/locale/model/templates/model.yml
155
+ - lib/generators/locale/service/USAGE
156
+ - lib/generators/locale/service/service_generator.rb
157
+ - lib/generators/locale/service/templates/service.yml
158
+ - lib/generators/locale/uploader/USAGE
159
+ - lib/generators/locale/uploader/templates/uploader.yml
160
+ - lib/generators/locale/uploader/uploader_generator.rb
161
+ - lib/generators/locale/view/USAGE
162
+ - lib/generators/locale/view/templates/view.yml
163
+ - lib/generators/locale/view/view_generator.rb
164
+ - lib/generators/service/USAGE
165
+ - lib/generators/service/service_generator.rb
166
+ - lib/generators/service/templates/service.rb
167
+ homepage: https://github.com/drexed/active_generator
168
+ licenses:
169
+ - MIT
170
+ metadata: {}
171
+ post_install_message:
172
+ rdoc_options: []
173
+ require_paths:
174
+ - lib
175
+ required_ruby_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ required_rubygems_version: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ version: '0'
185
+ requirements: []
186
+ rubyforge_project:
187
+ rubygems_version: 2.4.8
188
+ signing_key:
189
+ specification_version: 4
190
+ summary: Commonly used generators.
191
+ test_files: []