dotenv 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.3.0 - Oct 25, 2012
4
+
5
+ * Avoid overriding existing ENV variables so values set before loading the app are maintained.
data/README.md CHANGED
@@ -24,6 +24,7 @@ Install the gem:
24
24
 
25
25
  As early as possible in your application bootstrap process, load `.env`:
26
26
 
27
+ require 'dotenv'
27
28
  Dotenv.load
28
29
 
29
30
  To ensure `.env` is loaded in rake, load the tasks:
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.2.0'
4
+ gem.version = '0.3.0'
5
5
  gem.authors = ["Brandon Keepers"]
6
6
  gem.email = ["brandon@opensoul.org"]
7
7
  gem.description = %q{Loads environment variables from `.env`.}
@@ -16,7 +16,7 @@ module Dotenv
16
16
  end
17
17
 
18
18
  def apply
19
- each { |k,v| ENV[k] = v }
19
+ each { |k,v| ENV[k] ||= v }
20
20
  end
21
21
  end
22
22
  end
@@ -1,11 +1,16 @@
1
1
  module Dotenv
2
2
  class Railtie < Rails::Railtie
3
3
  rake_tasks do
4
- load "dotenv/tasks.rb"
4
+ desc 'Load environment settings from .env'
5
+ task :dotenv do
6
+ Dotenv.load ".env.#{Rails.env}", '.env'
7
+ end
8
+
9
+ task :environment => :dotenv
5
10
  end
6
11
 
7
12
  initializer 'dotenv', :group => :all do
8
- Dotenv.load '.env', ".env.#{Rails.env}"
13
+ Dotenv.load ".env.#{Rails.env}", '.env'
9
14
  end
10
15
  end
11
16
  end
data/spec/dotenv_spec.rb CHANGED
@@ -59,6 +59,12 @@ describe Dotenv do
59
59
  subject.apply
60
60
  expect(ENV['OPTION_A']).to eq('1')
61
61
  end
62
+
63
+ it 'does not override defined variables' do
64
+ ENV['OPTION_A'] = 'predefined'
65
+ subject.apply
66
+ expect(ENV['OPTION_A']).to eq('predefined')
67
+ end
62
68
  end
63
69
  end
64
70
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotenv
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 0.2.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brandon Keepers
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-09-06 00:00:00 Z
18
+ date: 2012-10-25 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rake
@@ -57,6 +57,7 @@ extra_rdoc_files: []
57
57
  files:
58
58
  - .env
59
59
  - .gitignore
60
+ - Changelog.md
60
61
  - Gemfile
61
62
  - LICENSE
62
63
  - README.md