active_generator 1.0.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 653ee7cde3813be3fdd62718557e5bab1219c844
4
- data.tar.gz: 721b66b60d1f592925bea673d8b5b3726e689273
3
+ metadata.gz: 1bedacd7f2398a309a9cacd817254e7f248ff4a1
4
+ data.tar.gz: c87818337481be38633b490a983b7c6f39b82199
5
5
  SHA512:
6
- metadata.gz: 541bfd8aa27cec212b8b1821339fec03e37fe33861dac96c5e69f8c1b0646e337e142b630bc135af0268fc76edf6aeaeca8799b23ff7003c496cf46b0b6bcbd1
7
- data.tar.gz: 9dd9ca12828add24e4e6f4aaa0346effa0e82c14811f2007c40225344c819408826ab8f924d24b6cb6a4407b772039559b7b7fe52a3bfaf5a6aada0d39574b56
6
+ metadata.gz: 2a241c4d915d96a721f06f23567606ad49fc4c6928170fc3d0e5f13ce6f3a18ea27cdb30a482f59135e510e7a68dd6b2890f3d2eb9a39d88d1e0f68b1b126e7c
7
+ data.tar.gz: 6322ab1383038955dccf28589971e328490fa74d879f62d8983bc4846f3710d07e4d80ad0263da1f664f8ed9c90690e85bd03aeb8e71c30357d0572d2913345b
data/README.md CHANGED
@@ -24,18 +24,38 @@ Or install it yourself as:
24
24
 
25
25
  ## Table of Contents
26
26
 
27
+ * [Environment](#environment)
27
28
  * [Initializer](#initializer)
28
29
  * [Locale](#locale)
29
30
  * [Service](#service)
30
31
 
32
+ ## Environment
33
+
34
+ Generates an environment file in the `config/environments` directory.
35
+
36
+ **Options:**
37
+ * environment: development, test, production
38
+
39
+ `rails generate environment staging production` will generate the following `staging.rb` file:
40
+
41
+ ```ruby
42
+ # config/environments/staging.rb
43
+
44
+ Rails.application.configure do
45
+ # Settings specified here will take precedence over those in config/application.rb.
46
+
47
+ # Production environment code omitted.
48
+ end
49
+ ```
50
+
31
51
  ## Initializer
32
52
 
33
- Generates an initializer file in the `config/initializer` directory.
53
+ Generates an initializer file in the `config/initializers` directory.
34
54
 
35
55
  `rails generate initializer stripe` will generate the following `stripe.rb` file:
36
56
 
37
57
  ```ruby
38
- # config/initializer/stripe.rb
58
+ # config/initializers/stripe.rb
39
59
 
40
60
  # TODO:
41
61
  # Add initializer code here.
@@ -2,6 +2,7 @@ require "rails/generators"
2
2
  require "active_object"
3
3
  require "active_generator/version"
4
4
 
5
+ require "generators/environment/environment_generator"
5
6
  require "generators/initializer/initializer_generator"
6
7
  require "generators/service/service_generator"
7
8
 
@@ -1,3 +1,3 @@
1
1
  module ActiveGenerator
2
- VERSION = "1.0.1"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate an environment file
3
+
4
+ Example:
5
+ rails generate environment NAME [ENVIRONMENT]
6
+
7
+ This will create:
8
+ config/environment/NAME.yml
@@ -0,0 +1,27 @@
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"
4
+
5
+ def copy_environment_file
6
+ assert_valid_environment!
7
+ template("environment.rb", "config/environments/#{file_name}.rb")
8
+ end
9
+
10
+ private
11
+
12
+ ENVIRONMENTS = %w(development test production)
13
+
14
+ ENVIRONMENTS.each do |env|
15
+ define_method("#{env}?") { environment == env }
16
+ end
17
+
18
+ def assert_valid_environment!
19
+ unless environment.nil?
20
+ unless ENVIRONMENTS.include?(environment)
21
+ raise ArgumentError,
22
+ "Unknown environment: #{environment.inspect}. Valid environments are: #{ENVIRONMENTS.map(&:inspect).join(', ')}"
23
+ end
24
+ end
25
+ end
26
+
27
+ end
@@ -0,0 +1,161 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ <% if development? -%>
5
+ # In the development environment your application's code is reloaded on
6
+ # every request. This slows down response time but is perfect for development
7
+ # since you don't have to restart the web server when you make code changes.
8
+ config.cache_classes = false
9
+
10
+ # Do not eager load code on boot.
11
+ config.eager_load = false
12
+
13
+ # Show full error reports and disable caching.
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Don't care if the mailer can't send.
18
+ config.action_mailer.raise_delivery_errors = false
19
+
20
+ # Print deprecation notices to the Rails logger.
21
+ config.active_support.deprecation = :log
22
+
23
+ # Raise an error on page load if there are pending migrations.
24
+ config.active_record.migration_error = :page_load
25
+
26
+ # Debug mode disables concatenation and preprocessing of assets.
27
+ # This option may cause significant delays in view rendering with a large
28
+ # number of complex assets.
29
+ config.assets.debug = true
30
+
31
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
32
+ # yet still be able to expire them through the digest params.
33
+ config.assets.digest = true
34
+
35
+ # Adds additional error checking when serving assets at runtime.
36
+ # Checks for improperly declared sprockets dependencies.
37
+ # Raises helpful error messages.
38
+ config.assets.raise_runtime_errors = true
39
+
40
+ # Raises error for missing translations
41
+ # config.action_view.raise_on_missing_translations = true
42
+ <% elsif test? %>
43
+ # The test environment is used exclusively to run your application's
44
+ # test suite. You never need to work with it otherwise. Remember that
45
+ # your test database is "scratch space" for the test suite and is wiped
46
+ # and recreated between test runs. Don't rely on the data there!
47
+ config.cache_classes = true
48
+
49
+ # Do not eager load code on boot. This avoids loading your whole application
50
+ # just for the purpose of running a single test. If you are using a tool that
51
+ # preloads Rails for running tests, you may have to set it to true.
52
+ config.eager_load = false
53
+
54
+ # Configure static file server for tests with Cache-Control for performance.
55
+ config.serve_static_files = true
56
+ config.static_cache_control = 'public, max-age=3600'
57
+
58
+ # Show full error reports and disable caching.
59
+ config.consider_all_requests_local = true
60
+ config.action_controller.perform_caching = false
61
+
62
+ # Raise exceptions instead of rendering exception templates.
63
+ config.action_dispatch.show_exceptions = false
64
+
65
+ # Disable request forgery protection in test environment.
66
+ config.action_controller.allow_forgery_protection = false
67
+
68
+ # Tell Action Mailer not to deliver emails to the real world.
69
+ # The :test delivery method accumulates sent emails in the
70
+ # ActionMailer::Base.deliveries array.
71
+ config.action_mailer.delivery_method = :test
72
+
73
+ # Randomize the order test cases are executed.
74
+ config.active_support.test_order = :random
75
+
76
+ # Print deprecation notices to the stderr.
77
+ config.active_support.deprecation = :stderr
78
+
79
+ # Raises error for missing translations
80
+ # config.action_view.raise_on_missing_translations = true
81
+ <% elsif production? -%>
82
+ # Code is not reloaded between requests.
83
+ config.cache_classes = true
84
+
85
+ # Eager load code on boot. This eager loads most of Rails and
86
+ # your application in memory, allowing both threaded web servers
87
+ # and those relying on copy on write to perform better.
88
+ # Rake tasks automatically ignore this option for performance.
89
+ config.eager_load = true
90
+
91
+ # Full error reports are disabled and caching is turned on.
92
+ config.consider_all_requests_local = false
93
+ config.action_controller.perform_caching = true
94
+
95
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
96
+ # Add `rack-cache` to your Gemfile before enabling this.
97
+ # For large-scale production use, consider using a caching reverse proxy like
98
+ # NGINX, varnish or squid.
99
+ # config.action_dispatch.rack_cache = true
100
+
101
+ # Disable serving static files from the `/public` folder by default since
102
+ # Apache or NGINX already handles this.
103
+ config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
104
+
105
+ # Compress JavaScripts and CSS.
106
+ config.assets.js_compressor = :uglifier
107
+ # config.assets.css_compressor = :sass
108
+
109
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
110
+ config.assets.compile = false
111
+
112
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
113
+ # yet still be able to expire them through the digest params.
114
+ config.assets.digest = true
115
+
116
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
117
+
118
+ # Specifies the header that your server uses for sending files.
119
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
120
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
121
+
122
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
123
+ # config.force_ssl = true
124
+
125
+ # Use the lowest log level to ensure availability of diagnostic information
126
+ # when problems arise.
127
+ config.log_level = :debug
128
+
129
+ # Prepend all log lines with the following tags.
130
+ # config.log_tags = [ :subdomain, :uuid ]
131
+
132
+ # Use a different logger for distributed setups.
133
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
134
+
135
+ # Use a different cache store in production.
136
+ # config.cache_store = :mem_cache_store
137
+
138
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
139
+ # config.action_controller.asset_host = 'http://assets.example.com'
140
+
141
+ # Ignore bad email addresses and do not raise email delivery errors.
142
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
143
+ # config.action_mailer.raise_delivery_errors = false
144
+
145
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
146
+ # the I18n.default_locale when a translation cannot be found).
147
+ config.i18n.fallbacks = true
148
+
149
+ # Send deprecation notices to registered listeners.
150
+ config.active_support.deprecation = :notify
151
+
152
+ # Use default logging formatter so that PID and timestamp are not suppressed.
153
+ config.log_formatter = ::Logger::Formatter.new
154
+
155
+ # Do not dump schema after migrations.
156
+ config.active_record.dump_schema_after_migration = false
157
+ <% else -%>
158
+ # TODO:
159
+ # Add environment code here.
160
+ <% end -%>
161
+ end
@@ -1,5 +1,3 @@
1
- require "generators/locale/base"
2
-
3
1
  class InitializerGenerator < Rails::Generators::NamedBase
4
2
  source_root File.expand_path('../templates', __FILE__)
5
3
 
@@ -6,7 +6,7 @@ module Locale
6
6
  def assert_valid_language!
7
7
  unless [2, 4, 5, 6].include?(language.size) && (language =~ /^[A-Za-z-]+$/)
8
8
  raise ArgumentError,
9
- "Unknown language format: '#{language}'. Valid format example is: 'en'"
9
+ "Unknown language format: #{language.inspect}. Valid format example is: 'en'"
10
10
  end
11
11
  end
12
12
 
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: 1.0.1
4
+ version: 2.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: 2015-08-18 00:00:00.000000000 Z
11
+ date: 2015-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -130,6 +130,9 @@ files:
130
130
  - lib/active_generator.rb
131
131
  - lib/active_generator/base.rb
132
132
  - lib/active_generator/version.rb
133
+ - lib/generators/environment/USAGE
134
+ - lib/generators/environment/environment_generator.rb
135
+ - lib/generators/environment/templates/environment.rb
133
136
  - lib/generators/initializer/USAGE
134
137
  - lib/generators/initializer/initializer_generator.rb
135
138
  - lib/generators/initializer/templates/initializer.rb