dotenvious 0.0.3 → 0.0.4
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.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/dotenvious.gemspec +2 -2
- data/lib/dotenvious/loaders/environment.rb +8 -0
- data/spec/dotenvious/loaders/env_spec.rb +23 -9
- data/spec/dotenvious/loaders/example_spec.rb +25 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ded812743d06ce1ec2fbbdf754845a23d15c89ef
|
4
|
+
data.tar.gz: 5496628b478e37c9950ca4abe035428706a34665
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cf2b4106f000e56c5c791f04d27c7aea03d02b388847f2209331366923f8c4cff209e9a01192aecebeb98a47d05e5ba43fec3671c117d777ea11ecaf0dc4634
|
7
|
+
data.tar.gz: a709bd2b181c094ff1320e9eec5719be8d032f0a8ef4c69c81d71e20677fdbddb954b84de3b4a0525198db2ea6562c57798c5b7f169692ac61256f0f713fe491
|
data/README.md
CHANGED
data/dotenvious.gemspec
CHANGED
@@ -3,6 +3,10 @@ module Dotenvious
|
|
3
3
|
class Environment
|
4
4
|
def load
|
5
5
|
#took from Dotenv source code whoops
|
6
|
+
if file_missing?
|
7
|
+
puts "This repo does not have an #{filename} file"
|
8
|
+
return
|
9
|
+
end
|
6
10
|
file.each do |line|
|
7
11
|
environment[$1] = $2 if line =~ /\A([\w_]+)=(.*)\z/
|
8
12
|
end
|
@@ -10,6 +14,10 @@ module Dotenvious
|
|
10
14
|
|
11
15
|
private
|
12
16
|
|
17
|
+
def file_missing?
|
18
|
+
!File.exists?(filename)
|
19
|
+
end
|
20
|
+
|
13
21
|
def environment
|
14
22
|
raise "environment must be defined in child class"
|
15
23
|
end
|
@@ -2,19 +2,33 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Dotenvious::Loaders::Env do
|
4
4
|
describe '#load' do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
context 'when .env are not present' do
|
6
|
+
before do
|
7
|
+
expect(File).to receive(:exists?).and_return false
|
8
|
+
end
|
9
|
+
it 'aborts the process' do
|
10
|
+
described_class.new.load
|
11
|
+
end
|
9
12
|
end
|
10
13
|
|
11
|
-
|
12
|
-
|
14
|
+
context 'when .env is present' do
|
15
|
+
before do
|
16
|
+
expect(File).to receive(:exists?).and_return true
|
17
|
+
end
|
18
|
+
it 'loads files from .env' do
|
19
|
+
expect(File).to receive(:read).with('.env').and_return ""
|
20
|
+
|
21
|
+
described_class.new.load
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'passes those arguments to Dotenvious::ENV_EXAMPLE' do
|
25
|
+
expect(File).to receive(:read).and_return "TEST=123\nEXAMPLE=234"
|
13
26
|
|
14
|
-
|
27
|
+
described_class.new.load
|
15
28
|
|
16
|
-
|
17
|
-
|
29
|
+
expect(Dotenvious::ENV['TEST']).to eq '123'
|
30
|
+
expect(Dotenvious::ENV['EXAMPLE']).to eq '234'
|
31
|
+
end
|
18
32
|
end
|
19
33
|
end
|
20
34
|
end
|
@@ -2,22 +2,36 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Dotenvious::Loaders::Example do
|
4
4
|
describe '#load' do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
expect(File).to receive(:read).with('.example-env').and_return ""
|
5
|
+
context 'when example-env does not exist' do
|
6
|
+
before do
|
7
|
+
expect(File).to receive(:exists?).and_return false
|
8
|
+
end
|
10
9
|
|
11
|
-
|
10
|
+
it 'aborts the process' do
|
11
|
+
described_class.new.load
|
12
|
+
end
|
12
13
|
end
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
context 'when example-env exists' do
|
16
|
+
before do
|
17
|
+
expect(File).to receive(:exists?).and_return true
|
18
|
+
stub_const('Dotenvious::DEFAULT_EXAMPLE_ENV_FILE', '.example-env')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'loads files from Dotenvious::DEFAULT_EXAMPLE_ENV_FILE' do
|
22
|
+
expect(File).to receive(:read).with('.example-env').and_return ""
|
23
|
+
|
24
|
+
described_class.new.load
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'passes those arguments to Dotenvious::ENV_EXAMPLE' do
|
28
|
+
expect(File).to receive(:read).and_return "TEST=123\nEXAMPLE=234"
|
16
29
|
|
17
|
-
|
30
|
+
described_class.new.load
|
18
31
|
|
19
|
-
|
20
|
-
|
32
|
+
expect(Dotenvious::ENV_EXAMPLE['TEST']).to eq '123'
|
33
|
+
expect(Dotenvious::ENV_EXAMPLE['EXAMPLE']).to eq '234'
|
34
|
+
end
|
21
35
|
end
|
22
36
|
end
|
23
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dotenvious
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Faris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|