asetus 0.0.3 → 0.0.4
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.
- checksums.yaml +4 -4
- data/asetus.gemspec +1 -1
- data/lib/asetus.rb +4 -1
- data/lib/asetus/configstruct.rb +16 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93b4b06e484007e5694fcf0a6f812f00cb4cbef0
|
4
|
+
data.tar.gz: 33f3b1205a98c67ab7c1cd7815c22c8616ee318e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51fcad0a5a96eca586fc80af0d36ba609cc50745cdfb75cdb8774984125869870156f841eafcb48618a7ce15b22c6ebe153872f8780b79cadaf8043f0013dd6f
|
7
|
+
data.tar.gz: 2ded6f137ebbae0ba0589d1f0ef697fcf353345e7f723b13996bb52f0cffac4e63cf29155cfe24b4f7fada719da02203f9c1c45df67f2be6ab11d87f937399bd
|
data/asetus.gemspec
CHANGED
data/lib/asetus.rb
CHANGED
@@ -5,6 +5,7 @@ require 'fileutils'
|
|
5
5
|
|
6
6
|
class AsetusError < StandardError; end
|
7
7
|
class NoName < AsetusError; end
|
8
|
+
class UnknownOption < AsetusError; end
|
8
9
|
|
9
10
|
class Asetus
|
10
11
|
CONFIG_FILE = 'config'
|
@@ -52,13 +53,15 @@ class Asetus
|
|
52
53
|
@cfg = ConfigStruct.new
|
53
54
|
@load = true
|
54
55
|
@load = opts.delete(:load) if opts.has_key?(:load)
|
56
|
+
@key_to_s = opts.delete(:key_to_s)
|
57
|
+
raise UnknownOption, "option '#{opts}' not recognized" unless opts.empty?
|
55
58
|
load :all if @load
|
56
59
|
end
|
57
60
|
|
58
61
|
def load_cfg dir
|
59
62
|
file = File.join dir, CONFIG_FILE
|
60
63
|
file = File.read file
|
61
|
-
ConfigStruct.new
|
64
|
+
ConfigStruct.new(from(@adapter, file), :key_to_s=>@key_to_s)
|
62
65
|
rescue Errno::ENOENT
|
63
66
|
ConfigStruct.new
|
64
67
|
end
|
data/lib/asetus/configstruct.rb
CHANGED
@@ -7,6 +7,7 @@ class Asetus
|
|
7
7
|
if value.class == ConfigStruct
|
8
8
|
value = value._asetus_to_hash
|
9
9
|
end
|
10
|
+
key = key.to_s if @key_to_s
|
10
11
|
hash[key] = value
|
11
12
|
end
|
12
13
|
hash
|
@@ -16,9 +17,22 @@ class Asetus
|
|
16
17
|
@cfg.empty?
|
17
18
|
end
|
18
19
|
|
20
|
+
def each &block
|
21
|
+
@cfg.each(&block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def key? key
|
25
|
+
@cfg.has_key? key
|
26
|
+
end
|
27
|
+
|
28
|
+
def [] key
|
29
|
+
@cfg[key]
|
30
|
+
end
|
31
|
+
|
19
32
|
private
|
20
33
|
|
21
|
-
def initialize hash=nil
|
34
|
+
def initialize hash=nil, opts={}
|
35
|
+
@key_to_s = opts.delete :key_to_s
|
22
36
|
@cfg = hash ? _asetus_from_hash(hash) : {}
|
23
37
|
end
|
24
38
|
|
@@ -48,7 +62,7 @@ class Asetus
|
|
48
62
|
cfg = {}
|
49
63
|
hash.each do |key, value|
|
50
64
|
if value.class == Hash
|
51
|
-
value = ConfigStruct.new value
|
65
|
+
value = ConfigStruct.new value, :key_to_s=>@key_to_s
|
52
66
|
end
|
53
67
|
cfg[key] = value
|
54
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asetus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Saku Ytti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slop
|
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
59
|
version: '0'
|
60
60
|
requirements: []
|
61
61
|
rubyforge_project: asetus
|
62
|
-
rubygems_version: 2.0.
|
62
|
+
rubygems_version: 2.0.3
|
63
63
|
signing_key:
|
64
64
|
specification_version: 4
|
65
65
|
summary: configuration library
|