simpleconfig 1.0.2 → 1.1

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.
@@ -100,6 +100,14 @@ module SimpleConfig
100
100
  @settings.key?(key)
101
101
  end
102
102
 
103
+ def to_hash
104
+ hash = @settings.dup
105
+ @groups.each do |key,group|
106
+ hash[key] = group.to_hash
107
+ end
108
+ hash
109
+ end
110
+
103
111
  def load(external_config_file, options={})
104
112
  options = {:if_exists? => false}.merge(options)
105
113
 
@@ -1,6 +1,7 @@
1
1
  require File.join(File.dirname(__FILE__), *%w[test_helper])
2
2
 
3
3
  require 'simple_config'
4
+ require 'fileutils'
4
5
 
5
6
  class SimpleConfigFunctionalTest < Test::Unit::TestCase
6
7
 
@@ -104,5 +104,49 @@ class SimpleConfigConfigTest < Test::Unit::TestCase
104
104
  File.stubs(:exist?).with('external_config.rb').returns(false)
105
105
  @config.load('external_config.rb', :if_exists? => true)
106
106
  end
107
+
108
+ def test_should_respond_to_to_hash
109
+ assert @config.respond_to? :to_hash
110
+ end
111
+
112
+ def test_should_create_hash_for_top_level
113
+ @config = cascaded_test_config
114
+
115
+ hash = {
116
+ :test => "test-setting",
117
+ :test_group => {
118
+ :inner_key => "some other value",
119
+ :object => {
120
+ :key1 => "value1"
121
+ }
122
+ }
123
+ }
124
+ assert_equal hash, @config.to_hash
125
+ end
126
+
127
+ def test_should_create_hash_for_second_level
128
+ @config = cascaded_test_config
129
+
130
+ hash = {
131
+ :inner_key => "some other value",
132
+ :object => {
133
+ :key1 => "value1"
134
+ }
135
+ }
136
+ assert_equal hash, @config.test_group.to_hash
137
+ end
138
+
139
+ private
140
+ def cascaded_test_config
141
+ SimpleConfig.for :simple_config_test do
142
+ set :test, "test-setting"
143
+ group :test_group do
144
+ set :inner_key, "some other value"
145
+ set :object, {
146
+ :key1 => "value1"
147
+ }
148
+ end
149
+ end
150
+ end
107
151
 
108
152
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simpleconfig
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ hash: 13
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 1
9
+ version: "1.1"
5
10
  platform: ruby
6
11
  authors:
7
12
  - Luke Redpath
@@ -9,11 +14,11 @@ autorequire: simple_config
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-02-05 00:00:00 +00:00
17
+ date: 2010-07-07 00:00:00 +01:00
13
18
  default_executable:
14
19
  dependencies: []
15
20
 
16
- description: Simple Config is a plugin designed to make application-wide configuration settings (e.g. in a Rails app) easy to set and access in an object-oriented fashion.
21
+ description: SimpleConfig is a plugin designed to make application-wide configuration settings (e.g. in a Rails app) easy to set and access in an object-oriented fashion.
17
22
  email: luke@lukeredpath.co.uk
18
23
  executables: []
19
24
 
@@ -31,6 +36,11 @@ files:
31
36
  - README.textile
32
37
  - tasks/simple_config.rake
33
38
  - templates/configuration.rb
39
+ - test/controller_mixin_test.rb
40
+ - test/network_host_test.rb
41
+ - test/simple_config_functional_test.rb
42
+ - test/simple_config_test.rb
43
+ - test/yaml_parser_test.rb
34
44
  has_rdoc: true
35
45
  homepage: http://github.com/lukeredpath/simpleconfig
36
46
  licenses: []
@@ -41,24 +51,30 @@ rdoc_options: []
41
51
  require_paths:
42
52
  - lib
43
53
  required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
44
55
  requirements:
45
56
  - - ">="
46
57
  - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
47
61
  version: "0"
48
- version:
49
62
  required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
50
64
  requirements:
51
65
  - - ">="
52
66
  - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
53
70
  version: "0"
54
- version:
55
71
  requirements: []
56
72
 
57
73
  rubyforge_project:
58
- rubygems_version: 1.3.5
74
+ rubygems_version: 1.3.7
59
75
  signing_key:
60
76
  specification_version: 3
61
- summary: Simple object-oriented application settings
77
+ summary: Simple object-oriented application settings for Ruby applications
62
78
  test_files:
63
79
  - test/controller_mixin_test.rb
64
80
  - test/network_host_test.rb