simple-conf 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2Q5Yzc0ZTdhOTJlYzc1YzA0ZWU0ZTMzY2M1ZDliOWI0ZmE2MzJjYw==
4
+ M2QxYWZhN2FlNjc0ZTdmMzFiNDkwOTk5NTBiZWE1ZTIxNjMyYmYwMw==
5
5
  data.tar.gz: !binary |-
6
- Zjc3YThiMzQ0MzU4MGZjYmQyYmFhMGY4YTY0ZmIyMWRmNTQ5MTc1Yg==
6
+ YzQ1MzY0ZjYyYzA0ZjljYmQ2MmQ4YWE3NGU0NDdiYmEwYmZkZTI2MQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzAzOGJhZThlNGFlN2RjZTYzYzRlOGM0YjFiYzUxNDgzYjNiZWIyZTQ4YTg1
10
- N2IzMzYxNzhiNDQ1NjRmZDVkZmZjNGIxZjJlZTAxYjcwN2ZlNzlhZTE5ZjE4
11
- OTAwYzFhZDQxODQ1YWQwOTdhM2UwNDdmMGY3NjZmYWU5ZThiMTc=
9
+ NWVkZjZiNzQ4YWFkOWY4NjQ4YjlhYzcwNDgxZGJlY2FhZDNlZjRjODI4NDVm
10
+ YzQ1NGIwZDcxZGZmNDQyOTJlNDVjZmIxMDYxZWIyYjcwYmFhNmY5MzM1MmU2
11
+ M2ZhMjg4MTg1MGE2NjhmN2YzMzU5YmE0OTUzZDNjMzlmMzA5Mzg=
12
12
  data.tar.gz: !binary |-
13
- NTg1Njk0MThkMTUxZjQ2YzAwODE5ZDA3YzFkNjg0NTAxMWVkNTExYmJlNzhh
14
- Y2VmZTc0YjRmMTQ4ZmZiZWViZWM3MTAxMGQ3MjczZjM5YjE4MDlmYTQzNmVk
15
- ODVjMjM1NjE5YWE5MzA5NmQ0MGQyYTA4OGQ5Y2IwZmVkNGI0OTk=
13
+ OGUzZjg1MTlkYTUyYTAxOWEwNWZjOTFjNjBiMDYwZTgwMzZjNDk2NGUxMzI3
14
+ MjNkY2U3MWVlMzJkZDE0YjUyNDJmOWZiMWEzZDY5OTVhOWMzMmQ3M2Q0NzNk
15
+ NzZmNDJkMWMyNjk4MGQ4MDEwNzM4Y2JjMTcyNTgxMTkyMmI5N2I=
@@ -12,7 +12,11 @@ module SimpleConf
12
12
  attr_reader :keys
13
13
  end
14
14
 
15
- @keys = []
15
+ @keys = Set.new
16
+
17
+ def keys
18
+ @keys.to_a
19
+ end
16
20
  }
17
21
  end
18
22
 
@@ -27,6 +31,10 @@ module SimpleConf
27
31
  def load_file_by_rails_env(path)
28
32
  yaml_file(path).fetch(Rails.env, {}).each_pair do |key, value|
29
33
  set(key, value)
34
+
35
+ klass.class_eval %Q{
36
+ @keys << :#{key}
37
+ }
30
38
  end if rails_environment_defined?
31
39
  end
32
40
 
@@ -39,6 +47,10 @@ module SimpleConf
39
47
  def load_file_by_klass_env(path)
40
48
  yaml_file(path).fetch(klass.env, {}).each_pair do |key, value|
41
49
  set(key, value)
50
+
51
+ klass.class_eval %Q{
52
+ @keys << :#{key}
53
+ }
42
54
  end if klass.respond_to?(:env)
43
55
  end
44
56
 
@@ -57,10 +69,10 @@ module SimpleConf
57
69
 
58
70
  def underscore(camel_case_string)
59
71
  camel_case_string.gsub(/::/, '/').
60
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
61
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
62
- tr("-", "_").
63
- downcase
72
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
73
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
74
+ tr("-", "_").
75
+ downcase
64
76
  end
65
77
 
66
78
  def yaml_file(path)
@@ -76,8 +88,6 @@ module SimpleConf
76
88
  class << self
77
89
  attr_reader :#{key}
78
90
  end
79
-
80
- @keys.push(:#{key})
81
91
  }
82
92
  end
83
93
 
@@ -1,3 +1,3 @@
1
1
  module SimpleConf
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -69,6 +69,12 @@ describe SimpleConf do
69
69
  it 'on include properties depenending on env method' do
70
70
  expect(Settings.domain).to eq('test.example.com')
71
71
  end
72
+
73
+
74
+ it 'should not include env keys' do
75
+ expect(Settings.keys).not_to include(:test)
76
+ expect(Settings.keys).to include(:domain)
77
+ end
72
78
  end
73
79
 
74
80
  describe SimpleConf do
@@ -125,12 +131,6 @@ describe SimpleConf do
125
131
  expect(Options2).to respond_to(:group1)
126
132
  expect(Options2).to respond_to(:group2)
127
133
  end
128
-
129
- it 'should have .keys for iterating by root keys of the configuration file' do
130
- expect(Options2.keys.size).to eq(2)
131
- expect(Options2.keys).to include(:group1)
132
- expect(Options2.keys).to include(:group2)
133
- end
134
134
  end
135
135
 
136
136
  describe SimpleConf do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-conf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Korsak