dotenvious 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9fbd0527566372e2936735e868632eae06450968
4
- data.tar.gz: ffab6509a4ce0ef809f5b095ac9f6c0d67c99d43
3
+ metadata.gz: ded812743d06ce1ec2fbbdf754845a23d15c89ef
4
+ data.tar.gz: 5496628b478e37c9950ca4abe035428706a34665
5
5
  SHA512:
6
- metadata.gz: 0533e7fbf6f16111122bb2fba3b718af04ad1de1b65590a6bc549ceadd44a668bf6d8aa2d230ca928b418138c8b24a809bdc0b18eb0d1cdff33449d9f16d6893
7
- data.tar.gz: 176333978d98cc06104debc2d40c5627628a8c9c3dc97dfcfbecd397c7bb9198656854a77c65d5f7c4e4de2b196dc6b406b03ce7cb22919744e6ed5fb7a8c99d
6
+ metadata.gz: 0cf2b4106f000e56c5c791f04d27c7aea03d02b388847f2209331366923f8c4cff209e9a01192aecebeb98a47d05e5ba43fec3671c117d777ea11ecaf0dc4634
7
+ data.tar.gz: a709bd2b181c094ff1320e9eec5719be8d032f0a8ef4c69c81d71e20677fdbddb954b84de3b4a0525198db2ea6562c57798c5b7f169692ac61256f0f713fe491
data/README.md CHANGED
@@ -49,6 +49,11 @@ end
49
49
  These both need to be arrays.
50
50
 
51
51
  `dotenvious` will ignore the variables specified.
52
+
53
+ ### Sorting
54
+
55
+ Running `dotenvious --sort` will sort your `.env` file alphabetically.
56
+
52
57
  ## Future Work
53
58
 
54
59
 
data/dotenvious.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'dotenvious'
3
- s.version = '0.0.3'
4
- s.date = '2016-10-21'
3
+ s.version = '0.0.4'
4
+ s.date = '2016-10-29'
5
5
  s.summary = "Dotenvious"
6
6
  s.description = "A Gem to manage environment variables"
7
7
  s.authors = ["Jake Faris"]
@@ -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
- it 'loads files from .env' do
6
- expect(File).to receive(:read).with('.env').and_return ""
7
-
8
- described_class.new.load
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
- it 'passes those arguments to Dotenvious::ENV_EXAMPLE' do
12
- expect(File).to receive(:read).and_return "TEST=123\nEXAMPLE=234"
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
- described_class.new.load
27
+ described_class.new.load
15
28
 
16
- expect(Dotenvious::ENV['TEST']).to eq '123'
17
- expect(Dotenvious::ENV['EXAMPLE']).to eq '234'
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
- before do
6
- stub_const('Dotenvious::DEFAULT_EXAMPLE_ENV_FILE', '.example-env')
7
- end
8
- it 'loads files from Dotenvious::DEFAULT_EXAMPLE_ENV_FILE' do
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
- described_class.new.load
10
+ it 'aborts the process' do
11
+ described_class.new.load
12
+ end
12
13
  end
13
14
 
14
- it 'passes those arguments to Dotenvious::ENV_EXAMPLE' do
15
- expect(File).to receive(:read).and_return "TEST=123\nEXAMPLE=234"
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
- described_class.new.load
30
+ described_class.new.load
18
31
 
19
- expect(Dotenvious::ENV_EXAMPLE['TEST']).to eq '123'
20
- expect(Dotenvious::ENV_EXAMPLE['EXAMPLE']).to eq '234'
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.3
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-21 00:00:00.000000000 Z
11
+ date: 2016-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler