dotenv 0.4.0 → 0.5.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.
- data/Changelog.md +6 -0
- data/README.md +32 -13
- data/dotenv.gemspec +1 -1
- data/lib/dotenv/environment.rb +1 -1
- data/lib/dotenv/railtie.rb +3 -7
- data/spec/dotenv_spec.rb +12 -0
- data/spec/fixtures/yaml.env +4 -0
- metadata +10 -2
data/Changelog.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# dotenv
|
1
|
+
# dotenv [](https://travis-ci.org/bkeepers/dotenv)
|
2
2
|
|
3
3
|
Loads environment variables from `.env` into `ENV`, automagically.
|
4
4
|
|
@@ -10,7 +10,9 @@ Read more about the [motivation for dotenv at opensoul.org](http://opensoul.org/
|
|
10
10
|
|
11
11
|
Add this line to your application's Gemfile:
|
12
12
|
|
13
|
-
|
13
|
+
```ruby
|
14
|
+
gem 'dotenv', :groups => [:development, :test]
|
15
|
+
```
|
14
16
|
|
15
17
|
And then execute:
|
16
18
|
|
@@ -24,32 +26,49 @@ Install the gem:
|
|
24
26
|
|
25
27
|
As early as possible in your application bootstrap process, load `.env`:
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
+
```ruby
|
30
|
+
require 'dotenv'
|
31
|
+
Dotenv.load
|
32
|
+
```
|
29
33
|
|
30
34
|
To ensure `.env` is loaded in rake, load the tasks:
|
31
35
|
|
32
|
-
|
36
|
+
```ruby
|
37
|
+
require 'dotenv/tasks'
|
33
38
|
|
34
|
-
|
35
|
-
|
36
|
-
|
39
|
+
task :mytask => :dotenv do
|
40
|
+
# things that require .env
|
41
|
+
end
|
42
|
+
```
|
37
43
|
|
38
44
|
## Usage
|
39
45
|
|
40
46
|
Add your application configuration to `.env`.
|
41
47
|
|
42
|
-
|
43
|
-
|
48
|
+
```shell
|
49
|
+
S3_BUCKET=dotenv
|
50
|
+
SECRET_KEY=sssshhh!
|
51
|
+
```
|
44
52
|
|
45
53
|
You can also create files per environment, such as `.env.test`:
|
46
54
|
|
47
|
-
|
48
|
-
|
55
|
+
```shell
|
56
|
+
S3_BUCKET=test
|
57
|
+
SECRET_KEY=test
|
58
|
+
```
|
59
|
+
|
60
|
+
An alternate yaml-like syntax is supported:
|
61
|
+
|
62
|
+
```yaml
|
63
|
+
S3_BUCKET: dotenv
|
64
|
+
SECRET_KEY: 'sesame, open'
|
65
|
+
```
|
49
66
|
|
50
67
|
Whenever your application loads, these variables will be available in `ENV`:
|
51
68
|
|
52
|
-
|
69
|
+
```ruby
|
70
|
+
config.fog_directory = ENV['S3_BUCKET']
|
71
|
+
```
|
53
72
|
|
54
73
|
## Contributing
|
55
74
|
|
data/dotenv.gemspec
CHANGED
data/lib/dotenv/environment.rb
CHANGED
data/lib/dotenv/railtie.rb
CHANGED
@@ -7,12 +7,8 @@ module Dotenv
|
|
7
7
|
task :dotenv do
|
8
8
|
Dotenv.load ".env.#{Rails.env}", '.env'
|
9
9
|
end
|
10
|
-
|
11
|
-
task :environment => :dotenv
|
12
|
-
end
|
13
|
-
|
14
|
-
initializer 'dotenv', :group => :all do
|
15
|
-
Dotenv.load ".env.#{Rails.env}", '.env'
|
16
10
|
end
|
17
11
|
end
|
18
|
-
end
|
12
|
+
end
|
13
|
+
|
14
|
+
Dotenv.load ".env.#{Rails.env}", '.env'
|
data/spec/dotenv_spec.rb
CHANGED
@@ -51,6 +51,18 @@ describe Dotenv do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
end
|
54
|
+
|
55
|
+
context 'with yaml file' do
|
56
|
+
let(:expected) do
|
57
|
+
{'OPTION_A' => '1', 'OPTION_B' => '2', 'OPTION_C' => '', 'OPTION_D' => '\n', 'DOTENV' => 'true'}
|
58
|
+
end
|
59
|
+
let(:env_path) { fixture_path('yaml.env') }
|
60
|
+
|
61
|
+
it 'returns hash of loaded environments' do
|
62
|
+
expect(subject).to eq(expected)
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
54
66
|
end
|
55
67
|
end
|
56
68
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dotenv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- spec/dotenv_spec.rb
|
67
67
|
- spec/fixtures/plain.env
|
68
68
|
- spec/fixtures/quoted.env
|
69
|
+
- spec/fixtures/yaml.env
|
69
70
|
- spec/spec_helper.rb
|
70
71
|
homepage: https://github.com/bkeepers/dotenv
|
71
72
|
licenses: []
|
@@ -79,12 +80,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
80
|
- - ! '>='
|
80
81
|
- !ruby/object:Gem::Version
|
81
82
|
version: '0'
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
hash: -3615033000965864371
|
82
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
87
|
none: false
|
84
88
|
requirements:
|
85
89
|
- - ! '>='
|
86
90
|
- !ruby/object:Gem::Version
|
87
91
|
version: '0'
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
hash: -3615033000965864371
|
88
95
|
requirements: []
|
89
96
|
rubyforge_project:
|
90
97
|
rubygems_version: 1.8.23
|
@@ -95,4 +102,5 @@ test_files:
|
|
95
102
|
- spec/dotenv_spec.rb
|
96
103
|
- spec/fixtures/plain.env
|
97
104
|
- spec/fixtures/quoted.env
|
105
|
+
- spec/fixtures/yaml.env
|
98
106
|
- spec/spec_helper.rb
|