starenv 0.0.1 → 0.0.2

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: d259f537e28341d2ba00408a875e0267b7874cca
4
- data.tar.gz: 8e1a771716fb1535fd133e01f26202a0d92f796d
3
+ metadata.gz: f62c737f6641cc377942b154fa174a519839e523
4
+ data.tar.gz: 8702d7433c99c1037320c1b6fc1ab50c964e1849
5
5
  SHA512:
6
- metadata.gz: 5e546387c1e7ac165fa2c6bc91509f8b8b27b30655553b22e82a65e90872b104b7ac0234ffa2df94cf4ea64b0c99333aa0a792afc4bfb9683f0b1537d1060bb8
7
- data.tar.gz: 487ef54e34937b2671cff7c9f21feba0307bcbc371787f6ee80e5de782db4202becf7db029d706faf1365510759550f6c694c8cfedb092bd6221d539a9da3c92
6
+ metadata.gz: ead64a5864fefa2c6659ced490b2f57b624252b119099286632434450a6704b1fab68fad081aa32bf5970d9413cbdf1473d5c4911fcdfad52a118329f10c2604
7
+ data.tar.gz: 1886d2735b635cf18ca05fa9a3102db31da3bd0b6da49da12ff68efc7dbbffa2d68f920188e2ff63dc93283194764f04f3f1c01a497e43077afb6240baebf661
data/.gitignore CHANGED
@@ -13,3 +13,4 @@
13
13
  *.a
14
14
  mkmf.log
15
15
  envs/
16
+ .pryrc
@@ -7,7 +7,7 @@ module Starenv
7
7
 
8
8
  def initialize(source = nil)
9
9
  @source = source ? source : ENV
10
- @variables, @applied, @ignored = {}
10
+ @variables, @applied, @ignored = {}, {}, {}
11
11
  end
12
12
 
13
13
  def [] key
@@ -22,10 +22,18 @@ module Starenv
22
22
  end
23
23
  end
24
24
 
25
+ def has_key?(key)
26
+ self[key] and not self[key].to_s.empty?
27
+ end
28
+
25
29
  def apply(hash)
26
30
  self.tap do |env|
27
31
  hash.each do |key, value|
28
- self[key] ||= value
32
+ if has_key? key
33
+ @ignored[key] = value
34
+ else
35
+ self[key], @applied[key] = value, value
36
+ end
29
37
  end
30
38
  end
31
39
  end
@@ -12,16 +12,20 @@ module Starenv
12
12
 
13
13
  def load
14
14
  tap do
15
- unless loaded?
16
- (hook || default_hook).call self do
17
- File.parse(name).environment
18
- end
15
+ load! unless loaded?
16
+ end
17
+ end
18
+
19
+ def load!
20
+ tap do
21
+ @environment = (hook || default_hook).call self do
22
+ File.parse(name).environment
19
23
  end
20
24
  end
21
25
  end
22
26
 
23
27
  def loaded?
24
- !!file
28
+ !!@environment
25
29
  end
26
30
 
27
31
  private
data/starenv.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "starenv"
7
- spec.version = '0.0.1'
7
+ spec.version = '0.0.2'
8
8
  spec.authors = ["Chris Keele"]
9
9
  spec.email = ["dev@chriskeele.com"]
10
10
  spec.summary = 'Load and manage suites of environment variables.'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: starenv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Keele
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-20 00:00:00.000000000 Z
11
+ date: 2015-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake