rails_environment 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/README.md +12 -5
- data/lib/rails_environment/version.rb +1 -1
- data/lib/rails_environment.rb +4 -1
- metadata +34 -1
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,23 +1,27 @@
|
|
1
1
|
# rails_environment
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/rails_environment.png)](http://badge.fury.io/rb/rails_environment)
|
3
4
|
[![Build Status](https://travis-ci.org/stevedowney/rails_environment.png)](https://travis-ci.org/stevedowney/rails_environment)
|
4
5
|
[![Code Climate](https://codeclimate.com/github/stevedowney/rails_environment.png)](https://codeclimate.com/github/stevedowney/rails_environment)
|
5
6
|
[![Coverage Status](https://coveralls.io/repos/stevedowney/rails_environment/badge.png)](https://coveralls.io/r/stevedowney/rails_environment)
|
6
7
|
|
7
|
-
|
8
|
+
Error-free convenience methods for determining the running Rails environment.
|
9
|
+
|
10
|
+
This gem enables code like:
|
11
|
+
|
8
12
|
```ruby
|
9
13
|
if RailsEnvironment.production?
|
10
|
-
|
14
|
+
<do_production_only_stuff>
|
11
15
|
end
|
12
16
|
```
|
13
17
|
|
14
|
-
This
|
18
|
+
This prevents typos like:
|
15
19
|
|
16
20
|
```ruby
|
17
21
|
if Rails.env == 'productoin' ...
|
18
22
|
if Rails.env.productoin? ...
|
19
23
|
```
|
20
|
-
|
24
|
+
So we get a runtime error if we misspell an environment instead of a silent bug.
|
21
25
|
|
22
26
|
For standard Rails applications with `development`, `test` and `production` environments you get:
|
23
27
|
|
@@ -41,5 +45,8 @@ For standard Rails applications with `development`, `test` and `production` envi
|
|
41
45
|
* `RailsEnvironment.not_test_or_production?`
|
42
46
|
* etc.
|
43
47
|
|
44
|
-
|
48
|
+
## Notes
|
49
|
+
|
50
|
+
* The methods available are based on the actual environments, i.e., `../config/environments/*.rb`
|
51
|
+
* If you add/remove a file in `../config/environments` you will need to restart your server
|
45
52
|
|
data/lib/rails_environment.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module RailsEnvironment
|
2
2
|
|
3
3
|
@@environments = nil
|
4
|
+
@@mutex = Mutex.new
|
4
5
|
|
5
6
|
class << self
|
6
7
|
|
@@ -9,7 +10,9 @@ module RailsEnvironment
|
|
9
10
|
end
|
10
11
|
|
11
12
|
def load_environments
|
12
|
-
|
13
|
+
@@mutex.synchronize do
|
14
|
+
@@environments = Dir[Rails.root.join('config/environments/*.rb')].map { |f| File.basename(f, '.rb') }
|
15
|
+
end
|
13
16
|
end
|
14
17
|
|
15
18
|
def environments
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_environment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -43,6 +43,38 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: redcarpet
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: yard
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
46
78
|
description: Eliminate silent errors in envionment detection due to typos.
|
47
79
|
email:
|
48
80
|
- steve.downtown@gmail.com
|
@@ -81,3 +113,4 @@ signing_key:
|
|
81
113
|
specification_version: 3
|
82
114
|
summary: Convenience methods for deciding what Rails environment you are in.
|
83
115
|
test_files: []
|
116
|
+
has_rdoc:
|