rails_env_local 0.1.0 → 0.2.0

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: 9d91a33d8b8aa5718c65ce4aed867b5a0d39df3c
4
- data.tar.gz: 1860911d7744c0cf5dfdef888539d0c5c48b1dcd
3
+ metadata.gz: 485eb26768f46bc69496783af8234edc0982b99a
4
+ data.tar.gz: 338f1c9c6259986f9a5c204475b08f3f1186192a
5
5
  SHA512:
6
- metadata.gz: 2a6f49e08d571ce7cbc3c267335f909c7818b1a5925ee2729e3f799eb9f81b6806fed720db0ea51d6a927f856a85ada49aaf8408e77ff5c430f29b92199a0891
7
- data.tar.gz: a008f8b8d3147c0a4013ddc94eef9b98c7224a06dd8d1623b066af89730134adae592e460193dc268d8bc0af7d5cad016f21dc895830f287d75b2b8052e3a633
6
+ metadata.gz: 686176257b35842b362bdc9071d9c95dfabbaa29b25c704c953add7afb40c765545aa61d9b2af1ffde0b9e423de28e221532f31fd6301b3ec776f8bfce1d6c90
7
+ data.tar.gz: 5ca9d515a397bbcc2cb535b682e4c42c361d8b3c69e7e4d38649f633dd7e1e09d336f02fbae1646732e16d4bb5d2a887227a846264e86aadbf7f59b0d9aa280f
data/README.md CHANGED
@@ -6,6 +6,22 @@
6
6
 
7
7
  ... But are you going to write specs for code in your `config/boot.rb` file? Really?
8
8
 
9
+
10
+ | Project | FlagShihTzu |
11
+ |------------------------ | ----------------- |
12
+ | gem name | rails_env_local |
13
+ | license | MIT |
14
+ | version | [![Gem Version](https://badge.fury.io/rb/rails_env_local.png)](http://badge.fury.io/rb/rails_env_local) |
15
+ | dependencies | [![Dependency Status](https://gemnasium.com/pboling/rails_env_local.png)](https://gemnasium.com/pboling/rails_env_local) |
16
+ | code quality | [![Code Climate](https://codeclimate.com/github/pboling/rails_env_local.png)](https://codeclimate.com/github/pboling/rails_env_local) |
17
+ | inline documenation | [![Inline docs](http://inch-ci.org/github/pboling/rails_env_local.png)](http://inch-ci.org/github/pboling/rails_env_local) |
18
+ | continuous integration | [![Build Status](https://secure.travis-ci.org/pboling/rails_env_local.png?branch=master)](https://travis-ci.org/pboling/rails_env_local) |
19
+ | homepage | [on github](https://github.com/pboling/rails_env_local) |
20
+ | documentation | [on rdoc.info](http://rdoc.info/github/pboling/rails_env_local/frames) |
21
+ | author | [Peter Boling](https://coderbits.com/pboling) |
22
+ | Spread ~♡ⓛⓞⓥⓔ♡~ | always |
23
+
24
+
9
25
  ## Installation
10
26
 
11
27
  Add this line to your application's Gemfile:
@@ -43,39 +59,57 @@ This gem can should work with any version of Rails that uses `Rails.env`, but it
43
59
 
44
60
  This gem is tested with Ruby 2.2-latest and 2.3-latest. It should work with any version of Ruby that supports both Ruby 1.9 hashes and double splat arguments.
45
61
 
62
+ ## Theory
63
+
64
+ ### Q: Why not just "local"?
65
+
66
+ A: It is too generic. "local" is often used in the same ordinal position as, but with a different meaning than, the environment name. For one example of this see: https://github.com/bkeepers/dotenv#multiple-rails-environments
67
+
68
+ ### Q: Why not just hand roll this when you need it? Only a few lines of code.
69
+
70
+ A: Doing it right requires remembering a number of things that are easily forgotten since this is a set it and forget it type configuration. If you don't start a new project every week, you may lose details on how to properly override the RAILS_ENV for local development (e.g. you may forget that naming it "local" is a bad idea and consequently break the `dotenv` gem). Also if you have a large team you may not want to force them all to add an `export RAILS_ENV=localdev` statement to their shell profile.
71
+
72
+ ### Q: Using this gem takes over the "development" environment namespace to be something else, so it precludes using "development" as a deployed environment.
73
+
74
+ A: Yeah, pretty much. Name your deployed environment "dev", "develop", or "anything_else". Naming your deployed environment "development", when "development" is universally understood to be local development in Rails, is a recipe for confusion.
75
+
46
76
  ### Options:
47
77
 
48
78
  #### `environment`
49
79
  * Type: a string
50
- * Default: `"local"`
80
+ * Default: `"localdev"`
51
81
  * Effect: Sets the Rails environment (`Rails.env`) to the given string
52
82
  * Example:
53
-
54
- RailsEnvLocal.set_local_environment(environment: "panda")
83
+ ```ruby
84
+ RailsEnvLocal.set_local_environment(environment: "panda")
85
+ ```
55
86
 
56
87
  #### `verbose`
57
88
  * Type: boolean
58
89
  * Default: `false`
59
90
  * Effect: Prints the environment to `STDOUT` as it is being set
60
91
  * Example:
61
-
62
- RailsEnvLocal.set_local_environment(verbose: true)
92
+ ```ruby
93
+ RailsEnvLocal.set_local_environment(verbose: true)
94
+ ```
63
95
 
64
96
  #### `set_rack_env`
65
97
  * Type: boolean
66
98
  * Default: `true`
67
99
  * Effect: In addition to setting `Rails.env`, will set `ENV["RAILS_ENV"]` to match `Rails.env`
68
100
  * Example:
69
-
70
- RailsEnvLocal.set_local_environment(set_rack_env: false)
101
+ ```ruby
102
+ RailsEnvLocal.set_local_environment(set_rack_env: false)
103
+ ```
71
104
 
72
105
  #### `set_rails_env`
73
106
  * Type: boolean
74
107
  * Default: `true`
75
108
  * Effect: In addition to setting `Rails.env`, will set `ENV["RACK_ENV"]` to match `Rails.env`
76
109
  * Example:
77
-
78
- RailsEnvLocal.set_local_environment(set_rails_env: false)
110
+ ```ruby
111
+ RailsEnvLocal.set_local_environment(set_rails_env: false)
112
+ ```
79
113
 
80
114
  ## Development
81
115
 
@@ -125,4 +159,4 @@ spec.add_dependency 'rails_env_local', '~> 0.1'
125
159
  [pvc]: http://docs.rubygems.org/read/chapter/16#page74
126
160
  [railsbling]: http://www.railsbling.com
127
161
  [mygithub]: http://github.com/pboling
128
- [contributors]: https://github.com/pboling/flag_shih_tzu/contributors
162
+ [contributors]: https://github.com/pboling/rails_env_local/contributors
@@ -18,7 +18,7 @@ require "rails"
18
18
  #
19
19
  # Options:
20
20
  #
21
- # environment: a string (default is "local")
21
+ # environment: a string (default is "localdev")
22
22
  # Effect: will set the Rails environment (Rails.env) to the given string
23
23
  # Example: RailsEnvLocal.set_local_environment(environment: "panda")
24
24
  #
@@ -35,9 +35,13 @@ require "rails"
35
35
  # Example: RailsEnvLocal.set_local_environment(set_rails_env: false)
36
36
 
37
37
  module RailsEnvLocal
38
- DEVELOPMENT_ENVIRONMENT = "development"
39
- def self.set_local_environment(environment: "local", **options)
40
- if ENV["RAILS_ENV"] == DEVELOPMENT_ENVIRONMENT || Rails.env == DEVELOPMENT_ENVIRONMENT
38
+ ORIGINAL_RAILS_DEVELOPMENT_ENVIRONMENT = "development"
39
+ # Q: Why not just "local"?
40
+ # A: It is too generic. "local" is often used in the same ordinal position as, but with a different meaning than,
41
+ # the environment name. For one example of this see: https://github.com/bkeepers/dotenv#multiple-rails-environments
42
+ ALTERNATE_RAILS_DEVELOPMENT_ENVIRONMENT = "localdev"
43
+ def self.set_local_environment(environment: ALTERNATE_RAILS_DEVELOPMENT_ENVIRONMENT, **options)
44
+ if ENV["RAILS_ENV"] == ORIGINAL_RAILS_DEVELOPMENT_ENVIRONMENT || Rails.env == ORIGINAL_RAILS_DEVELOPMENT_ENVIRONMENT
41
45
  Rails.env = environment
42
46
  options = {set_rails_env: true, set_rack_env: true, verbose: false}.merge(options)
43
47
  ENV["RAILS_ENV"] = Rails.env if options[:set_rails_env]
@@ -1,3 +1,3 @@
1
1
  module RailsEnvLocal
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_env_local
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-08 00:00:00.000000000 Z
11
+ date: 2016-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  requirements: []
147
147
  rubyforge_project:
148
- rubygems_version: 2.4.6
148
+ rubygems_version: 2.5.1
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: '"development" is not always the best name for the local environment'