dotenv 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # dotenv
2
2
 
3
- Loads environment settings for your application from `.env`.
3
+ Loads environment variables from `.env` into `ENV`, automagically.
4
4
 
5
- The emerging practice of storing application configuration in environment variables is a great idea, but it's not always practical to set all of those environment variables in your development or continuous integration environments. [Foreman](https://github.com/ddollar/foreman) provides this handy feature of loading settings from `.env`, which works great for anything that you want to put in your `Procfile`. But it makes things difficult when you want to run a console or rake task. `dotenv` solves that problem.
5
+ Read more about the [motivation for dotenv at opensoul.org](http://opensoul.org/blog/archives/2012/07/24/dotenv/).
6
6
 
7
7
  ## Installation
8
8
 
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
12
12
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
13
  gem.name = "dotenv"
14
14
  gem.require_paths = ["lib"]
15
- gem.version = '0.1.0'
15
+ gem.version = '0.1.1'
16
16
 
17
17
  gem.add_development_dependency 'rake'
18
18
  gem.add_development_dependency 'rspec'
@@ -6,4 +6,4 @@ module Dotenv
6
6
  end
7
7
  end
8
8
 
9
- require 'dotenv/railtie' if defined?(Rails)
9
+ require 'dotenv/railtie' if defined?(Rails) and defined?(Rails::Railtie)
@@ -2,7 +2,7 @@ module Dotenv
2
2
  class Environment < Hash
3
3
  def initialize(filename)
4
4
  @filename = filename
5
- load
5
+ load if File.exists? @filename
6
6
  end
7
7
 
8
8
  def load
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Dotenv::Environment do
4
- let(:env_path) { fixture_path('plain.env') }
5
4
  let(:dotenv) { Dotenv::Environment.new(env_path) }
6
5
 
7
6
  before do
@@ -12,17 +11,38 @@ describe Dotenv::Environment do
12
11
  ENV.delete_if { |k,v| !@env_keys.include?(k) }
13
12
  end
14
13
 
15
- describe 'initialize' do
16
- it 'reads environment config' do
17
- expect(dotenv['OPTION_A']).to eq('1')
18
- expect(dotenv['OPTION_B']).to eq('2')
14
+ context 'with a plain env file' do
15
+ let(:env_path) { fixture_path('plain.env') }
16
+
17
+ describe 'initialize' do
18
+ it 'reads environment config' do
19
+ expect(dotenv['OPTION_A']).to eq('1')
20
+ expect(dotenv['OPTION_B']).to eq('2')
21
+ end
22
+ end
23
+
24
+ describe 'apply' do
25
+ it 'sets variables in ENV' do
26
+ dotenv.apply
27
+ expect(ENV['OPTION_A']).to eq('1')
28
+ end
19
29
  end
20
30
  end
21
31
 
22
- describe 'apply' do
23
- it 'sets variables in ENV' do
24
- dotenv.apply
25
- expect(ENV['OPTION_A']).to eq('1')
32
+ context 'when the file does not exist' do
33
+ let(:env_path) { fixture_path('.env_does_not_exist') }
34
+
35
+ describe 'initialize' do
36
+ it 'fails silently' do
37
+ lambda { Dotenv::Environment.new('.env_does_not_exist') }.should_not raise_error
38
+ end
39
+ end
40
+
41
+ describe 'apply' do
42
+ it 'does not effect env' do
43
+ dotenv.apply
44
+ expect(ENV.keys).to eq(@env_keys)
45
+ end
26
46
  end
27
47
  end
28
48
 
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: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
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-07-24 00:00:00 Z
18
+ date: 2012-08-08 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rake