dws-registry 0.1.3 → 0.2.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -1
- data.tar.gz.sig +0 -0
- data/lib/dws-registry.rb +66 -6
- metadata +33 -25
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b4169a56e3e56b6fd66f9b81566834ef41a816d
|
4
|
+
data.tar.gz: d09171ac4c5d3146860c395aac9e1fbf691c72e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 380191f0c98a023a6d8eab0ad7f71ba1e271ea9172c0afb9c3a415b73cacd8b6c5b055b1ddfd616857ddcf53d2518e6ae851071d7051f926c1d7cdb4a2441484
|
7
|
+
data.tar.gz: 6d46159964b2fe6f8495e0cc4cb11e49a2a9ebff12298aada0de8bd79b9e50902c9f013df832757bb003d96724461ac12a9ea277ac8d078fcb655ce02ffd3eba
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
!Z� o#T���D�m/����0ZI=
|
2
|
+
�9����7��m�����qs)��H����]�7�n��J��G�W(d���:>�������F��o16m��wLF�/�����'��mz��0q|�W���0������;˙ʨ!��G�ZY��./I��*.�J���1�DΒ�^oՒ])j�e��y9�v��o��헡�*Ĥs��`t;���QO��SI��
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/dws-registry.rb
CHANGED
@@ -2,15 +2,17 @@
|
|
2
2
|
|
3
3
|
# file: dws-registry.rb
|
4
4
|
|
5
|
-
|
5
|
+
require 'time'
|
6
6
|
require 'xml-registry'
|
7
7
|
|
8
8
|
class DWSRegistry < XMLRegistry
|
9
9
|
|
10
|
-
def initialize(filename=
|
10
|
+
def initialize(filename='registry.xml', autosave: true)
|
11
11
|
|
12
12
|
super()
|
13
13
|
|
14
|
+
@autosave = autosave
|
15
|
+
|
14
16
|
if filename then
|
15
17
|
|
16
18
|
@filename = filename
|
@@ -23,15 +25,56 @@ class DWSRegistry < XMLRegistry
|
|
23
25
|
|
24
26
|
end
|
25
27
|
end
|
28
|
+
|
29
|
+
def get_key(path)
|
30
|
+
|
31
|
+
e = super path
|
32
|
+
c = e.attributes[:class]
|
33
|
+
s = e.text
|
34
|
+
|
35
|
+
return e if s.nil?
|
36
|
+
return s unless c
|
37
|
+
|
38
|
+
h = {
|
39
|
+
string: ->(x) {x},
|
40
|
+
boolean: ->(x){
|
41
|
+
case x
|
42
|
+
when 'true' then true
|
43
|
+
when 'false' then false
|
44
|
+
else x
|
45
|
+
end
|
46
|
+
},
|
47
|
+
number: ->(x){ x[/^[0-9]+$/] ? x.to_i : x.to_f },
|
48
|
+
time: ->(x) {Time.parse x}
|
49
|
+
}
|
50
|
+
|
51
|
+
h[c.to_sym].call s
|
52
|
+
|
53
|
+
end
|
26
54
|
|
27
55
|
def set_key(path, value)
|
28
|
-
|
29
|
-
|
56
|
+
|
57
|
+
value, type = case value.class.to_s.downcase.to_sym
|
58
|
+
when :string then value
|
59
|
+
when :time then ["#%s#" % value.to_s, :time]
|
60
|
+
when :fixnum then [value.to_s, :number]
|
61
|
+
when :float then [value.to_s, :number]
|
62
|
+
when :falseclass then [value.to_s, :boolean]
|
63
|
+
when :trueclass then [value.to_s, :boolean]
|
64
|
+
end
|
65
|
+
|
66
|
+
e = super(path, value)
|
67
|
+
|
68
|
+
type = find_class value unless type
|
69
|
+
e.attributes[:class] = type if type
|
70
|
+
|
71
|
+
save() if @autosave
|
72
|
+
e
|
30
73
|
end
|
31
74
|
|
32
75
|
def delete_key(path)
|
33
76
|
super(path)
|
34
|
-
save()
|
77
|
+
save() if @autosave
|
35
78
|
end
|
36
79
|
|
37
80
|
def save(filename=nil)
|
@@ -41,11 +84,28 @@ class DWSRegistry < XMLRegistry
|
|
41
84
|
|
42
85
|
def import(s)
|
43
86
|
super(s)
|
44
|
-
save()
|
87
|
+
save() if @autosave
|
45
88
|
end
|
46
89
|
|
47
90
|
def refresh()
|
48
91
|
load_xml(@filename)
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
def add_value(key, value)
|
97
|
+
e = @doc.root.element(key)
|
98
|
+
e.text = value
|
99
|
+
return e
|
100
|
+
end
|
101
|
+
|
102
|
+
def find_class(v)
|
103
|
+
|
104
|
+
if v.to_i.to_s.length == v.length then :number
|
105
|
+
elsif v.to_f.to_s.length == v.length then :number
|
106
|
+
elsif v.downcase[/^(?:true|false|on|off|yes|no)$/] then :boolean
|
107
|
+
elsif v[/^\#.*\#$/] then :time
|
108
|
+
end
|
49
109
|
end
|
50
110
|
|
51
111
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dws-registry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,41 +10,49 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
14
|
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
-
|
15
|
+
8ixkARkWAmV1MB4XDTE1MDMwMzIxNDAwMFoXDTE2MDMwMjIxNDAwMFowSDESMBAG
|
16
16
|
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
17
|
EjAQBgoJkiaJk/IsZAEZFgJldT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JuQ1Zarci4pykJT0fKNLn8ihGSvb/MmH
|
31
|
+
PGZIlz7FJwJ4++0ZB4E5454Xa7aPv5k3PP+urajaDnG0vSBYhI76SWHkG0+PBDau
|
32
|
+
8P/40FmSZqbOtg==
|
31
33
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
34
|
+
date: 2015-03-03 00:00:00.000000000 Z
|
33
35
|
dependencies:
|
34
36
|
- !ruby/object:Gem::Dependency
|
35
37
|
name: xml-registry
|
36
38
|
requirement: !ruby/object:Gem::Requirement
|
37
39
|
requirements:
|
38
|
-
- -
|
40
|
+
- - "~>"
|
39
41
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
42
|
+
version: '0.3'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.3.1
|
41
46
|
type: :runtime
|
42
47
|
prerelease: false
|
43
48
|
version_requirements: !ruby/object:Gem::Requirement
|
44
49
|
requirements:
|
45
|
-
- -
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0.3'
|
53
|
+
- - ">="
|
46
54
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
55
|
+
version: 0.3.1
|
48
56
|
description:
|
49
57
|
email: james@r0bertson.co.uk
|
50
58
|
executables: []
|
@@ -62,17 +70,17 @@ require_paths:
|
|
62
70
|
- lib
|
63
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
64
72
|
requirements:
|
65
|
-
- -
|
73
|
+
- - ">="
|
66
74
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
75
|
+
version: 2.1.2
|
68
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
77
|
requirements:
|
70
|
-
- -
|
78
|
+
- - ">="
|
71
79
|
- !ruby/object:Gem::Version
|
72
80
|
version: '0'
|
73
81
|
requirements: []
|
74
82
|
rubyforge_project:
|
75
|
-
rubygems_version: 2.
|
83
|
+
rubygems_version: 2.2.2
|
76
84
|
signing_key:
|
77
85
|
specification_version: 4
|
78
86
|
summary: dws-registry
|
metadata.gz.sig
CHANGED
Binary file
|