dotenv 0.9.0 → 2.7.6

Sign up to get free protection for your applications and to get access to all the features.
data/.env DELETED
@@ -1 +0,0 @@
1
- DOTENV=true
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- tmp
8
- vendor
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.0.0
4
- - 1.9.3
5
- - 1.8.7
6
- - ree
data/Changelog.md DELETED
@@ -1,83 +0,0 @@
1
- # Changelog
2
-
3
- ## 0.9.0 - Aug 29, 2013
4
-
5
- * Add support for variable expansion.
6
-
7
- HOST="example.com"
8
- URL="http://${USER}@${HOST}"
9
- ESCAPED_VARIABLE="this is \$NOT replaced"
10
-
11
- * Allow setting variables without a value.
12
-
13
- BLANK=
14
-
15
- * Add `dotenv` executable to load `.env` for other scripts.
16
-
17
- $ dotenv ./script.py
18
-
19
- [Full Changelog](https://github.com/bkeepers/dotenv/compare/v0.8.0...v0.9.0)
20
-
21
- ## 0.8.0 - June 12, 2013
22
-
23
- * Added a capistrano recipe to symlink in `.env` on deploy.
24
-
25
- * Allow inline comments
26
-
27
- VARIABLE=value # this is a comment
28
-
29
- * Raises Dotenv::FormatError when parsing fails
30
-
31
- [Full Changelog](https://github.com/bkeepers/dotenv/compare/v0.7.0...v0.8.0)
32
-
33
- ## 0.7.0 - April 15, 2013
34
-
35
- * Remove deprectated autoloading. Upgrade to 0.6 first and fix any warnings.
36
-
37
- * Add Dotenv.load! which raises Errno::ENOENT if the file does not exist
38
-
39
- [Full Changelog](https://github.com/bkeepers/dotenv/compare/v0.6.0...v0.7.0)
40
-
41
- ## 0.6.0 - Mar 22, 2013
42
-
43
- * Add dotenv-rails gem for autoloading in a Rails app
44
-
45
- * Deprecated autoloading with plain dotenv gem
46
-
47
- * Support for double quotes
48
-
49
- A="some value"
50
- B="with \"escaped\" quotes"
51
- C="and newline\n expansion"
52
-
53
- * Support for pow-style variables prefixed with export
54
-
55
- export VARIABLE="some value"
56
-
57
- [Full Changelog](https://github.com/bkeepers/dotenv/compare/v0.5.0...v0.6.0)
58
-
59
- ## 0.5.0 - Jan 25, 2013
60
-
61
- * Load immediately on require in Rails instead of waiting for initialization
62
-
63
- * Add YAML-style variables
64
-
65
- VARIABLE: some value
66
-
67
- [Full Changelog](https://github.com/bkeepers/dotenv/compare/v0.4.0...v0.5.0)
68
-
69
- ## 0.4.0 - Nov 13, 2012
70
-
71
- * Add support for quoted options, e.g.:
72
-
73
- VARIABLE='some value'
74
-
75
- * Fix rake deprecation warnings
76
-
77
- [Full Changelog](https://github.com/bkeepers/dotenv/compare/v0.3.0...v0.4.0)
78
-
79
- ## 0.3.0 - Oct 25, 2012
80
-
81
- * Avoid overriding existing ENV variables so values set before loading the app are maintained.
82
-
83
- [Full Changelog](https://github.com/bkeepers/dotenv/compare/v0.2.0...v0.3.0)
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec :name => 'dotenv'
3
-
4
- gem 'guard-rspec'
5
- gem 'guard-bundler'
6
- gem 'rb-fsevent'
data/Guardfile DELETED
@@ -1,9 +0,0 @@
1
- guard 'bundler' do
2
- watch('Gemfile')
3
- end
4
-
5
- guard 'rspec', :cli => '--color' do
6
- watch(%r{^spec/.+_spec\.rb$})
7
- watch(%r{^spec/spec_helper.rb$}) { "spec" }
8
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
9
- end
data/Rakefile DELETED
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env rake
2
-
3
- require 'bundler/gem_helper'
4
-
5
- namespace 'dotenv' do
6
- Bundler::GemHelper.install_tasks :name => 'dotenv'
7
- end
8
-
9
- namespace 'dotenv-rails' do
10
- class DotenvRailsGemHelper < Bundler::GemHelper
11
- def guard_already_tagged; end # noop
12
- def tag_version; end # noop
13
- end
14
-
15
- DotenvRailsGemHelper.install_tasks :name => 'dotenv-rails'
16
- end
17
-
18
- task :build => ["dotenv:build", 'dotenv-rails:build']
19
- task :install => ["dotenv:install", 'dotenv-rails:install']
20
- task :release => ["dotenv:release", 'dotenv-rails:release']
21
-
22
- require 'rspec/core/rake_task'
23
-
24
- desc "Run all specs"
25
- RSpec::Core::RakeTask.new(:spec) do |t|
26
- t.rspec_opts = %w[--color]
27
- t.verbose = false
28
- end
29
-
30
- task :default => :spec
data/dotenv-rails.gemspec DELETED
@@ -1,17 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/dotenv/version', __FILE__)
3
-
4
- Gem::Specification.new do |gem|
5
- gem.version = Dotenv::VERSION
6
- gem.authors = ["Brandon Keepers"]
7
- gem.email = ["brandon@opensoul.org"]
8
- gem.description = %q{Autoload dotenv in Rails.}
9
- gem.summary = %q{Autoload dotenv in Rails.}
10
- gem.homepage = "https://github.com/bkeepers/dotenv"
11
-
12
- gem.files = ["lib/dotenv-rails.rb"]
13
- gem.name = "dotenv-rails"
14
- gem.require_paths = ["lib"]
15
-
16
- gem.add_dependency 'dotenv', Dotenv::VERSION
17
- end
data/dotenv.gemspec DELETED
@@ -1,20 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/dotenv/version', __FILE__)
3
-
4
- Gem::Specification.new do |gem|
5
- gem.version = Dotenv::VERSION
6
- gem.authors = ["Brandon Keepers"]
7
- gem.email = ["brandon@opensoul.org"]
8
- gem.description = %q{Loads environment variables from `.env`.}
9
- gem.summary = %q{Loads environment variables from `.env`.}
10
- gem.homepage = "https://github.com/bkeepers/dotenv"
11
-
12
- gem.files = `git ls-files`.split($\)
13
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
- gem.name = "dotenv"
16
- gem.require_paths = ["lib"]
17
-
18
- gem.add_development_dependency 'rake'
19
- gem.add_development_dependency 'rspec'
20
- end
data/lib/dotenv-rails.rb DELETED
@@ -1 +0,0 @@
1
- require 'dotenv/railtie'
@@ -1,5 +0,0 @@
1
- require 'dotenv/capistrano/recipes'
2
-
3
- Capistrano::Configuration.instance(:must_exist).load do
4
- before "deploy:finalize_update", "dotenv:symlink"
5
- end
@@ -1,10 +0,0 @@
1
- Capistrano::Configuration.instance(:must_exist).load do
2
- _cset(:dotenv_path){ "#{shared_path}/.env" }
3
-
4
- namespace :dotenv do
5
- desc "Symlink shared .env to current release"
6
- task :symlink, roles: :app do
7
- run "ln -nfs #{dotenv_path} #{release_path}/.env"
8
- end
9
- end
10
- end
@@ -1,4 +0,0 @@
1
- module Dotenv
2
- class FormatError < SyntaxError
3
- end
4
- end
@@ -1,14 +0,0 @@
1
- require 'dotenv'
2
-
3
- module Dotenv
4
- class Railtie < Rails::Railtie
5
- rake_tasks do
6
- desc 'Load environment settings from .env'
7
- task :dotenv do
8
- Dotenv.load ".env.#{Rails.env}", '.env'
9
- end
10
- end
11
- end
12
- end
13
-
14
- Dotenv.load ".env.#{Rails.env}", '.env'
@@ -1,137 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dotenv::Environment do
4
- subject { env("OPTION_A=1\nOPTION_B=2") }
5
-
6
- describe 'initialize' do
7
- it 'reads the file' do
8
- expect(subject['OPTION_A']).to eq('1')
9
- expect(subject['OPTION_B']).to eq('2')
10
- end
11
-
12
- it 'fails if file does not exist' do
13
- expect {
14
- Dotenv::Environment.new('.does_not_exists')
15
- }.to raise_error(Errno::ENOENT)
16
- end
17
- end
18
-
19
- describe 'apply' do
20
- it 'sets variables in ENV' do
21
- subject.apply
22
- expect(ENV['OPTION_A']).to eq('1')
23
- end
24
-
25
- it 'does not override defined variables' do
26
- ENV['OPTION_A'] = 'predefined'
27
- subject.apply
28
- expect(ENV['OPTION_A']).to eq('predefined')
29
- end
30
- end
31
-
32
- it 'parses unquoted values' do
33
- expect(env('FOO=bar')).to eql('FOO' => 'bar')
34
- end
35
-
36
- it 'parses values with spaces around equal sign' do
37
- expect(env("FOO =bar")).to eql('FOO' => 'bar')
38
- expect(env("FOO= bar")).to eql('FOO' => 'bar')
39
- end
40
-
41
- it 'parses double quoted values' do
42
- expect(env('FOO="bar"')).to eql('FOO' => 'bar')
43
- end
44
-
45
- it 'parses single quoted values' do
46
- expect(env("FOO='bar'")).to eql('FOO' => 'bar')
47
- end
48
-
49
- it 'parses escaped double quotes' do
50
- expect(env('FOO="escaped\"bar"')).to eql('FOO' => 'escaped"bar')
51
- end
52
-
53
- it 'parses empty values' do
54
- expect(env('FOO=')).to eql('FOO' => '')
55
- end
56
-
57
- it 'expands variables found in values' do
58
- expect(env("FOO=test\nBAR=$FOO")).to eql('FOO' => 'test', 'BAR' => 'test')
59
- end
60
-
61
- it 'parses variables wrapped in brackets' do
62
- expect(env("FOO=test\nBAR=${FOO}bar")).to eql('FOO' => 'test', 'BAR' => 'testbar')
63
- end
64
-
65
- it 'reads variables from ENV when expanding if not found in local env' do
66
- ENV['FOO'] = 'test'
67
- expect(env('BAR=$FOO')).to eql('BAR' => 'test')
68
- end
69
-
70
- it 'expands undefined variables to an empty string' do
71
- expect(env('BAR=$FOO')).to eql('BAR' => '')
72
- end
73
-
74
- it 'expands variables in quoted strings' do
75
- expect(env("FOO=test\nBAR='quote $FOO'")).to eql('FOO' => 'test', 'BAR' => 'quote test')
76
- end
77
-
78
- it 'does not expand escaped variables' do
79
- expect(env('FOO="foo\$BAR"')).to eql('FOO' => 'foo$BAR')
80
- expect(env('FOO="foo\${BAR}"')).to eql('FOO' => 'foo${BAR}')
81
- end
82
-
83
- it 'parses yaml style options' do
84
- expect(env('OPTION_A: 1')).to eql('OPTION_A' => '1')
85
- end
86
-
87
- it 'parses export keyword' do
88
- expect(env('export OPTION_A=2')).to eql('OPTION_A' => '2')
89
- end
90
-
91
- it 'expands newlines in quoted strings' do
92
- expect(env('FOO="bar\nbaz"')).to eql('FOO' => "bar\nbaz")
93
- end
94
-
95
- it 'parses varibales with "." in the name' do
96
- expect(env('FOO.BAR=foobar')).to eql('FOO.BAR' => 'foobar')
97
- end
98
-
99
- it 'strips unquoted values' do
100
- expect(env('foo=bar ')).to eql('foo' => 'bar') # not 'bar '
101
- end
102
-
103
- it 'throws an error if line format is incorrect' do
104
- expect{env('lol$wut')}.to raise_error(Dotenv::FormatError)
105
- end
106
-
107
- it 'ignores empty lines' do
108
- expect(env("\n \t \nfoo=bar\n \nfizz=buzz")).to eql('foo' => 'bar', 'fizz' => 'buzz')
109
- end
110
-
111
- it 'ignores inline comments' do
112
- expect(env("foo=bar # this is foo")).to eql('foo' => 'bar')
113
- end
114
-
115
- it 'allows # in quoted value' do
116
- expect(env('foo="bar#baz" # comment')).to eql('foo' => 'bar#baz')
117
- end
118
-
119
- it 'ignores comment lines' do
120
- expect(env("\n\n\n # HERE GOES FOO \nfoo=bar")).to eql('foo' => 'bar')
121
- end
122
-
123
- it 'parses # in quoted values' do
124
- expect(env('foo="ba#r"')).to eql('foo' => 'ba#r')
125
- expect(env("foo='ba#r'")).to eql('foo' => 'ba#r')
126
- end
127
-
128
- require 'tempfile'
129
- def env(text)
130
- file = Tempfile.new('dotenv')
131
- file.write text
132
- file.close
133
- env = Dotenv::Environment.new(file.path)
134
- file.unlink
135
- env
136
- end
137
- end
data/spec/dotenv_spec.rb DELETED
@@ -1,92 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dotenv do
4
- shared_examples 'load' do
5
- context 'with no args' do
6
- let(:env_files) { [] }
7
-
8
- it 'defaults to .env' do
9
- Dotenv::Environment.should_receive(:new).with(expand('.env')).
10
- and_return(double(:apply => {}))
11
- subject
12
- end
13
- end
14
-
15
- context 'with a tilde path' do
16
- let(:env_files) { ['~/.env'] }
17
-
18
- it 'expands the path' do
19
- expected = expand("~/.env")
20
- File.stub(:exists?){ |arg| arg == expected }
21
- Dotenv::Environment.should_receive(:new).with(expected).
22
- and_return(double(:apply => {}))
23
- subject
24
- end
25
- end
26
-
27
- context 'with multiple files' do
28
- let(:env_files) { ['.env', fixture_path('plain.env')] }
29
-
30
- let(:expected) do
31
- { 'OPTION_A' => '1',
32
- 'OPTION_B' => '2',
33
- 'OPTION_C' => '3',
34
- 'OPTION_D' => '4',
35
- 'OPTION_E' => '5',
36
- 'DOTENV' => 'true' }
37
- end
38
-
39
- it 'loads all files' do
40
- subject
41
- expected.each do |key, value|
42
- expect(ENV[key]).to eq(value)
43
- end
44
- end
45
-
46
- it 'returns hash of loaded environments' do
47
- expect(subject).to eq(expected)
48
- end
49
- end
50
- end
51
-
52
- describe 'load' do
53
- subject { Dotenv.load(*env_files) }
54
-
55
- it_behaves_like 'load'
56
-
57
- context 'when the file does not exist' do
58
- let(:env_files) { ['.env_does_not_exist'] }
59
-
60
- it 'fails silently' do
61
- expect { subject }.not_to raise_error
62
- expect(ENV.keys).to eq(@env_keys)
63
- end
64
- end
65
- end
66
-
67
- describe 'load!' do
68
- subject { Dotenv.load!(*env_files) }
69
-
70
- it_behaves_like 'load'
71
-
72
- context 'when one file exists and one does not' do
73
- let(:env_files) { ['.env', '.env_does_not_exist'] }
74
-
75
- it 'raises an Errno::ENOENT error and does not load any files' do
76
- expect do
77
- expect do
78
- subject
79
- end.to raise_error(Errno::ENOENT)
80
- end.to_not change { ENV.keys }
81
- end
82
- end
83
- end
84
-
85
- def fixture_path(name)
86
- File.join(File.expand_path('../fixtures', __FILE__), name)
87
- end
88
-
89
- def expand(path)
90
- File.expand_path path
91
- end
92
- end