cubus-settingslogic 2.0.6 → 2.1.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.
- data/CHANGELOG.rdoc +5 -0
- data/Rakefile +2 -2
- data/VERSION.yml +2 -2
- data/lib/settingslogic.rb +10 -1
- data/settingslogic.gemspec +7 -6
- data/spec/settings.yml +6 -1
- data/spec/settings4.rb +5 -0
- data/spec/settingslogic_spec.rb +11 -0
- data/spec/spec_helper.rb +2 -0
- metadata +16 -6
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
== 2.1.0 released 2010-03-15
|
2
|
+
|
3
|
+
* Added key_by_path (e.g. Settings.key_by_path "some.nested.setting")
|
4
|
+
* Default namespace support (defaults are merged)
|
5
|
+
|
1
6
|
== 2.0.2 released 2009-08-22
|
2
7
|
|
3
8
|
* Define methods during method_missing instead of during initialization. Allows for modification on the fly.
|
data/Rakefile
CHANGED
@@ -4,11 +4,11 @@ require 'rake'
|
|
4
4
|
begin
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "settingslogic"
|
7
|
+
gem.name = "cubus-settingslogic"
|
8
8
|
gem.summary = "A simple and straightforward settings solution that uses an ERB enabled YAML file and a singleton design pattern."
|
9
9
|
gem.email = "bjohnson@binarylogic.com"
|
10
10
|
gem.homepage = "http://github.com/binarylogic/settingslogic"
|
11
|
-
gem.authors = ["Ben Johnson of Binary Logic"]
|
11
|
+
gem.authors = ["Ben Johnson of Binary Logic", "Mihai Târnovan of Cubus Arts", "Gabriel Târnovan of Cubus Arts"]
|
12
12
|
end
|
13
13
|
Jeweler::GemcutterTasks.new
|
14
14
|
rescue LoadError
|
data/VERSION.yml
CHANGED
data/lib/settingslogic.rb
CHANGED
@@ -26,6 +26,14 @@ class Settingslogic < Hash
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
def default_namespace(value = nil)
|
30
|
+
if value.nil?
|
31
|
+
@default_namespace || 'defaults'
|
32
|
+
else
|
33
|
+
@default_namespace = value
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
29
37
|
def key_by_path(key_path, separator = ".")
|
30
38
|
# Settings.get_nested_key('some.nested.setting')
|
31
39
|
tmp = instance
|
@@ -85,8 +93,9 @@ class Settingslogic < Hash
|
|
85
93
|
self.replace hash_or_file
|
86
94
|
else
|
87
95
|
hash = YAML.load(ERB.new(File.read(hash_or_file)).result).to_hash
|
96
|
+
default_hash = hash[self.class.default_namespace] || {}
|
88
97
|
hash = hash[self.class.namespace] if self.class.namespace
|
89
|
-
self.replace hash
|
98
|
+
self.replace default_hash.deep_merge(hash)
|
90
99
|
end
|
91
100
|
@section = section || hash_or_file # so end of error says "in application.yml"
|
92
101
|
create_accessors!
|
data/settingslogic.gemspec
CHANGED
@@ -4,13 +4,13 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "2.0
|
7
|
+
s.name = %q{cubus-settingslogic}
|
8
|
+
s.version = "2.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Ben Johnson of Binary Logic"]
|
12
|
-
s.date = %q{2010-
|
13
|
-
s.email = %q{bjohnson@binarylogic.com}
|
11
|
+
s.authors = ["Ben Johnson of Binary Logic", "Mihai Târnovan of Cubus Arts", "Gabriel Târnovan of Cubus Arts"]
|
12
|
+
s.date = %q{2010-03-15}
|
13
|
+
s.email = %q{bjohnson@binarylogic.com, mihai.tarnovan@cubus.ro, gabriel.tarnovan@cubus.ro}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
16
16
|
"README.rdoc"
|
@@ -36,12 +36,13 @@ Gem::Specification.new do |s|
|
|
36
36
|
s.homepage = %q{http://github.com/binarylogic/settingslogic}
|
37
37
|
s.rdoc_options = ["--charset=UTF-8"]
|
38
38
|
s.require_paths = ["lib"]
|
39
|
-
s.rubygems_version = %q{1.3.
|
39
|
+
s.rubygems_version = %q{1.3.6}
|
40
40
|
s.summary = %q{A simple and straightforward settings solution that uses an ERB enabled YAML file and a singleton design pattern.}
|
41
41
|
s.test_files = [
|
42
42
|
"spec/settings.rb",
|
43
43
|
"spec/settings2.rb",
|
44
44
|
"spec/settings3.rb",
|
45
|
+
"spec/settings4.rb",
|
45
46
|
"spec/settingslogic_spec.rb",
|
46
47
|
"spec/spec_helper.rb"
|
47
48
|
]
|
data/spec/settings.yml
CHANGED
data/spec/settings4.rb
ADDED
data/spec/settingslogic_spec.rb
CHANGED
@@ -30,6 +30,11 @@ describe "Settingslogic" do
|
|
30
30
|
Settings.namespace.should be_nil
|
31
31
|
Settings2.namespace.should == 'setting1'
|
32
32
|
end
|
33
|
+
|
34
|
+
it "should return the default namespace" do
|
35
|
+
Settings.default_namespace.should == 'defaults'
|
36
|
+
Settings4.default_namespace.should == 'default_settings4'
|
37
|
+
end
|
33
38
|
|
34
39
|
it "should get a key by a path" do
|
35
40
|
Settings.key_by_path("language.haskell.paradigm").should == "functional"
|
@@ -44,6 +49,12 @@ describe "Settingslogic" do
|
|
44
49
|
Settings3.collides.does.should == 'not'
|
45
50
|
end
|
46
51
|
|
52
|
+
it "should merge defaults" do
|
53
|
+
Settings4.haskell.paradigm.should == 'functional'
|
54
|
+
Settings4.haskell.foo.should == 'bar'
|
55
|
+
Settings4.smalltalk.paradigm.should == 'object oriented'
|
56
|
+
end
|
57
|
+
|
47
58
|
it "should raise a helpful error message" do
|
48
59
|
e = nil
|
49
60
|
begin
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'spec'
|
2
2
|
require 'rubygems'
|
3
3
|
require 'ruby-debug' if RUBY_VERSION < '1.9' # ruby-debug does not work on 1.9.1 yet
|
4
|
+
require 'active_support'
|
4
5
|
|
5
6
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
6
7
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
@@ -8,6 +9,7 @@ require 'settingslogic'
|
|
8
9
|
require 'settings'
|
9
10
|
require 'settings2'
|
10
11
|
require 'settings3'
|
12
|
+
require 'settings4'
|
11
13
|
|
12
14
|
# Needed to test Settings3
|
13
15
|
def collides
|
metadata
CHANGED
@@ -1,20 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cubus-settingslogic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 2
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 2.1.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Ben Johnson of Binary Logic
|
13
|
+
- "Mihai T\xC3\xA2rnovan of Cubus Arts"
|
14
|
+
- "Gabriel T\xC3\xA2rnovan of Cubus Arts"
|
8
15
|
autorequire:
|
9
16
|
bindir: bin
|
10
17
|
cert_chain: []
|
11
18
|
|
12
|
-
date: 2010-
|
19
|
+
date: 2010-03-15 00:00:00 +02:00
|
13
20
|
default_executable:
|
14
21
|
dependencies: []
|
15
22
|
|
16
23
|
description:
|
17
|
-
email: bjohnson@binarylogic.com
|
24
|
+
email: bjohnson@binarylogic.com, mihai.tarnovan@cubus.ro, gabriel.tarnovan@cubus.ro
|
18
25
|
executables: []
|
19
26
|
|
20
27
|
extensions: []
|
@@ -52,18 +59,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
59
|
requirements:
|
53
60
|
- - ">="
|
54
61
|
- !ruby/object:Gem::Version
|
62
|
+
segments:
|
63
|
+
- 0
|
55
64
|
version: "0"
|
56
|
-
version:
|
57
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
66
|
requirements:
|
59
67
|
- - ">="
|
60
68
|
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 0
|
61
71
|
version: "0"
|
62
|
-
version:
|
63
72
|
requirements: []
|
64
73
|
|
65
74
|
rubyforge_project:
|
66
|
-
rubygems_version: 1.3.
|
75
|
+
rubygems_version: 1.3.6
|
67
76
|
signing_key:
|
68
77
|
specification_version: 3
|
69
78
|
summary: A simple and straightforward settings solution that uses an ERB enabled YAML file and a singleton design pattern.
|
@@ -71,5 +80,6 @@ test_files:
|
|
71
80
|
- spec/settings.rb
|
72
81
|
- spec/settings2.rb
|
73
82
|
- spec/settings3.rb
|
83
|
+
- spec/settings4.rb
|
74
84
|
- spec/settingslogic_spec.rb
|
75
85
|
- spec/spec_helper.rb
|