dotenv 0.3.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/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 1.9.2
5
+ - 1.8.7
6
+ - ree
data/Changelog.md CHANGED
@@ -1,5 +1,17 @@
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
+
9
+ ## 0.4.0 - Nov 13, 2012
10
+
11
+ * Add support for quoted options, e.g.:
12
+ VARIABLE='some value'
13
+ * Fix rake deprecation warnings
14
+
3
15
  ## 0.3.0 - Oct 25, 2012
4
16
 
5
17
  * Avoid overriding existing ENV variables so values set before loading the app are maintained.
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
 
data/dotenv.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  Gem::Specification.new do |gem|
4
- gem.version = '0.3.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] = $2 if line =~ /\A([\w_]+)=(.*)\z/
10
+ self[$1] = $2 || $3 if line =~ /\A(\w+)(?:=|: ?)(?:'([^']*)'|([^']*))\z/
11
11
  end
12
12
  end
13
13
 
@@ -1,16 +1,14 @@
1
1
  module Dotenv
2
2
  class Railtie < Rails::Railtie
3
+ include Rake::DSL if defined?(Rake)
4
+
3
5
  rake_tasks do
4
6
  desc 'Load environment settings from .env'
5
7
  task :dotenv do
6
8
  Dotenv.load ".env.#{Rails.env}", '.env'
7
9
  end
8
-
9
- task :environment => :dotenv
10
- end
11
-
12
- initializer 'dotenv', :group => :all do
13
- Dotenv.load ".env.#{Rails.env}", '.env'
14
10
  end
15
11
  end
16
- end
12
+ end
13
+
14
+ Dotenv.load ".env.#{Rails.env}", '.env'
data/spec/dotenv_spec.rb CHANGED
@@ -39,6 +39,30 @@ describe Dotenv do
39
39
  it 'returns hash of loaded environments' do
40
40
  expect(subject).to eq(expected)
41
41
  end
42
+
43
+ context 'with quoted file' do
44
+ let(:expected) do
45
+ {'OPTION_A' => '1', 'OPTION_B' => '2', 'OPTION_C' => '', 'OPTION_D' => '\n', 'DOTENV' => 'true'}
46
+ end
47
+ let(:env_path) { fixture_path('quoted.env') }
48
+
49
+ it 'returns hash of loaded environments' do
50
+ expect(subject).to eq(expected)
51
+ end
52
+
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
42
66
  end
43
67
  end
44
68
 
@@ -0,0 +1,4 @@
1
+ OPTION_A='1'
2
+ OPTION_B='2'
3
+ OPTION_C=''
4
+ OPTION_D='\n'
@@ -0,0 +1,4 @@
1
+ OPTION_A: 1
2
+ OPTION_B: '2'
3
+ OPTION_C: ''
4
+ OPTION_D: '\n'
metadata CHANGED
@@ -1,62 +1,58 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: dotenv
3
- version: !ruby/object:Gem::Version
4
- hash: 19
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 0
10
- version: 0.3.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Brandon Keepers
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-10-25 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-01-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rake
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
32
22
  type: :development
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: rspec
36
23
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
38
33
  none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
46
38
  type: :development
47
- version_requirements: *id002
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
48
46
  description: Loads environment variables from `.env`.
49
- email:
47
+ email:
50
48
  - brandon@opensoul.org
51
49
  executables: []
52
-
53
50
  extensions: []
54
-
55
51
  extra_rdoc_files: []
56
-
57
- files:
52
+ files:
58
53
  - .env
59
54
  - .gitignore
55
+ - .travis.yml
60
56
  - Changelog.md
61
57
  - Gemfile
62
58
  - LICENSE
@@ -69,41 +65,42 @@ files:
69
65
  - lib/dotenv/tasks.rb
70
66
  - spec/dotenv_spec.rb
71
67
  - spec/fixtures/plain.env
68
+ - spec/fixtures/quoted.env
69
+ - spec/fixtures/yaml.env
72
70
  - spec/spec_helper.rb
73
71
  homepage: https://github.com/bkeepers/dotenv
74
72
  licenses: []
75
-
76
73
  post_install_message:
77
74
  rdoc_options: []
78
-
79
- require_paths:
75
+ require_paths:
80
76
  - lib
81
- required_ruby_version: !ruby/object:Gem::Requirement
77
+ required_ruby_version: !ruby/object:Gem::Requirement
82
78
  none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ segments:
88
84
  - 0
89
- version: "0"
90
- required_rubygems_version: !ruby/object:Gem::Requirement
85
+ hash: -3615033000965864371
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
87
  none: false
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- hash: 3
96
- segments:
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ segments:
97
93
  - 0
98
- version: "0"
94
+ hash: -3615033000965864371
99
95
  requirements: []
100
-
101
96
  rubyforge_project:
102
- rubygems_version: 1.8.15
97
+ rubygems_version: 1.8.23
103
98
  signing_key:
104
99
  specification_version: 3
105
100
  summary: Loads environment variables from `.env`.
106
- test_files:
101
+ test_files:
107
102
  - spec/dotenv_spec.rb
108
103
  - spec/fixtures/plain.env
104
+ - spec/fixtures/quoted.env
105
+ - spec/fixtures/yaml.env
109
106
  - spec/spec_helper.rb