appcfg 0.2.0 → 0.3.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9cd291cbcd3d423ea2bbdcbc3bc87ddc66568884
4
+ data.tar.gz: 244004f7a5751774f6379c2d751ad80e7ceeb72f
5
+ SHA512:
6
+ metadata.gz: 3c0ea6ebc5e9e9e3ad183b49e213cc5a2aa42bf9dea99859a295dbad297742714084c757d0aa7446cde6abfc6884bfbb0ca329d5d789b3f943059565d3117359
7
+ data.tar.gz: 16e8866006180a18ff4555ca0e94d9bdbfca60d69382f6152bd7c203e5e423fe1e9553b333add1a25bd0932760bd71d834eecdbdda101c945197fd4048e7320c
@@ -1,6 +1,5 @@
1
1
  rvm:
2
- - 1.8.7
3
- - 1.9.2
4
2
  - 1.9.3
3
+ - 2.0.0
4
+ - 2.1.4
5
5
  - jruby
6
- - ree
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  group :development do
4
- gem "rspec"
4
+ gem "rspec", '~> 2.99.0'
5
5
  gem "bundler"
6
6
  gem "jeweler"
7
7
  gem 'simplecov'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -3,11 +3,22 @@ module AppCfg
3
3
  def initialize(options = {})
4
4
  @model_class = options[:class]
5
5
  end
6
-
6
+
7
7
  def reload_data!
8
8
  @hash = {}
9
9
  @model_class.all.each do |instance|
10
- @hash[instance.key] = instance.value
10
+ #@hash[instance.key] = instance.value
11
+ hsh = @hash
12
+ idx = {}
13
+ arr = instance.key.split('.')
14
+ arr.each_with_index do |x,i|
15
+ hsh[x] ||= {}
16
+ if arr.size-1 == i
17
+ hsh[x] = instance.value
18
+ else
19
+ hsh = hsh[x]
20
+ end
21
+ end
11
22
  end
12
23
  end
13
24
  end
@@ -4,6 +4,7 @@ describe "AppCfg retrieval from AR model" do
4
4
  before(:each) do
5
5
  SampleConfig.create(:key => 'app_name', :value => 'AppCfg')
6
6
  SampleConfig.create(:key => 'admin_credentials', :value => {'username' => 'admin', 'password' => 'testpass'})
7
+ SampleConfig.create(:key => 'admin1.credentials', :value => {'username' => 'admin1', 'password' => 'testpass1'})
7
8
  AppCfg::Source.add(SampleConfig)
8
9
  end
9
10
 
@@ -23,6 +24,10 @@ describe "AppCfg retrieval from AR model" do
23
24
  AppCfg.admin_credentials.username.should == 'admin'
24
25
  end
25
26
 
27
+ it "should allow multi-level access with dotted key syntax" do
28
+ AppCfg.admin1.credentials.username.should == 'admin1'
29
+ end
30
+
26
31
  it "should return nil on non-existent key, hash syntax" do
27
32
  AppCfg['wrong_key'].should be_nil
28
33
  end
metadata CHANGED
@@ -1,78 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appcfg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Toms Mikoss
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-14 00:00:00.000000000 Z
11
+ date: 2014-11-08 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: 2.99.0
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '0'
26
+ version: 2.99.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: jeweler
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: simplecov
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  description: A gem for centralizing different sources of application configuration
@@ -84,9 +75,9 @@ extra_rdoc_files:
84
75
  - LICENSE.txt
85
76
  - README.rdoc
86
77
  files:
87
- - .document
88
- - .rspec
89
- - .travis.yml
78
+ - ".document"
79
+ - ".rspec"
80
+ - ".travis.yml"
90
81
  - Gemfile
91
82
  - LICENSE.txt
92
83
  - README.rdoc
@@ -114,29 +105,25 @@ files:
114
105
  homepage: http://github.com/tmikoss/appconfig
115
106
  licenses:
116
107
  - MIT
108
+ metadata: {}
117
109
  post_install_message:
118
110
  rdoc_options: []
119
111
  require_paths:
120
112
  - lib
121
113
  required_ruby_version: !ruby/object:Gem::Requirement
122
- none: false
123
114
  requirements:
124
- - - ! '>='
115
+ - - ">="
125
116
  - !ruby/object:Gem::Version
126
117
  version: '0'
127
- segments:
128
- - 0
129
- hash: -1033711763
130
118
  required_rubygems_version: !ruby/object:Gem::Requirement
131
- none: false
132
119
  requirements:
133
- - - ! '>='
120
+ - - ">="
134
121
  - !ruby/object:Gem::Version
135
122
  version: '0'
136
123
  requirements: []
137
124
  rubyforge_project:
138
- rubygems_version: 1.8.24
125
+ rubygems_version: 2.2.2
139
126
  signing_key:
140
- specification_version: 3
127
+ specification_version: 4
141
128
  summary: A gem for centralizing different sources of application configuration data.
142
129
  test_files: []