dotenv 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0 - Jan 25, 2013
4
+
5
+ * Load immediately on require in Rails instead of waiting for initialization
6
+ * Add YAML-style variables
7
+ VARIABLE: some value
8
+
3
9
  ## 0.4.0 - Nov 13, 2012
4
10
 
5
11
  * Add support for quoted options, e.g.:
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # dotenv
1
+ # dotenv [![Build Status](https://secure.travis-ci.org/bkeepers/dotenv.png)](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
- gem 'dotenv', :groups => [:development, :test]
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
- require 'dotenv'
28
- Dotenv.load
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
- require 'dotenv/tasks'
36
+ ```ruby
37
+ require 'dotenv/tasks'
33
38
 
34
- task :mytask => :dotenv do
35
- # things that require .env
36
- end
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
- S3_BUCKET=dotenv
43
- SECRET_KEY=sssshhh!
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
- S3_BUCKET=test
48
- SECRET_KEY=test
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
- config.fog_directory = ENV['S3_BUCKET']
69
+ ```ruby
70
+ config.fog_directory = ENV['S3_BUCKET']
71
+ ```
53
72
 
54
73
  ## Contributing
55
74
 
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  Gem::Specification.new do |gem|
4
- gem.version = '0.4.0'
4
+ gem.version = '0.5.0'
5
5
  gem.authors = ["Brandon Keepers"]
6
6
  gem.email = ["brandon@opensoul.org"]
7
7
  gem.description = %q{Loads environment variables from `.env`.}
@@ -7,7 +7,7 @@ module Dotenv
7
7
 
8
8
  def load
9
9
  read.each do |line|
10
- self[$1] = $3 || $4 if line =~ /\A([\w_]+)=('([^']*)'|([^']*))\z/
10
+ self[$1] = $2 || $3 if line =~ /\A(\w+)(?:=|: ?)(?:'([^']*)'|([^']*))\z/
11
11
  end
12
12
  end
13
13
 
@@ -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'
@@ -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
 
@@ -0,0 +1,4 @@
1
+ OPTION_A: 1
2
+ OPTION_B: '2'
3
+ OPTION_C: ''
4
+ OPTION_D: '\n'
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.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: 2012-11-14 00:00:00.000000000 Z
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