dws-registry 0.5.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3e80c19ec4c70b7da325a67538fa476f6ba23ce99ee0d3c29a49c7c869cbe41
4
- data.tar.gz: 84fd88e35751e90df3bae2440e93080a799f388fafcf3e8a80e53d601d8179c3
3
+ metadata.gz: 0d341ebac9fd10a3216588c7651caa6e2b4e28619fc3decbb4d6764c95d7f1c0
4
+ data.tar.gz: 613d9fc137c636f77043f4ebb58e5d1412b4f08d38f1fbf3e192e9eea1f3db14
5
5
  SHA512:
6
- metadata.gz: 8c6e56b80c6e3f3aaf7ad243bb96283d94408622b2704113bf89ceb0cb2267e71b8efae9004462bbc890ff0dd43b00fa16a02406f4ac191bc3e23612e5c91ecb
7
- data.tar.gz: a177bb7faaeaadb88857e2a8ab6b2aaa3efe1627485d69946ed77f9823598d6c97bc13ddfe35689952179d407b0f36a43244dc4596213340a23c90796695eb04
6
+ metadata.gz: 666c0c408e1b783b2b2da18a0843ed59350038f4493af5bbc21dd4928bb37d058e3237d7386561f0a1fcf11ef76663db1544ad9cc4f15d355ad3b9f384a79c39
7
+ data.tar.gz: 629d903bdc1a4d4e8cf70e9fe66937853398a04c9d58e3e9667e68ad99e1c7a9c578322a1bfcceaae7aa744b2ff6688f7f27d08c0f7b52f52809ca1540b1abfd
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/dws-registry.rb CHANGED
@@ -7,74 +7,75 @@ require 'xml-registry'
7
7
  require 'rscript'
8
8
  require 'json'
9
9
  require 'requestor'
10
+ require 'rxfreader'
10
11
 
11
12
 
12
13
  class DWSRegistry < XMLRegistry
13
- include RXFHelperModule
14
-
14
+ include RXFRead
15
+
15
16
  def initialize(filename='registry.xml', autosave: true, debug: false)
16
-
17
+
17
18
  super(debug: debug)
18
-
19
- @autosave = autosave
20
-
19
+
20
+ @autosave = autosave
21
+
21
22
  if filename then
22
23
 
23
- @filename = filename
24
-
24
+ @filename = filename
25
+
25
26
  if FileX.exists? filename then
26
27
  load_xml(filename)
27
28
  else
28
29
  save()
29
- end
30
+ end
30
31
 
31
32
  end
32
33
  end
33
-
34
+
34
35
  def gem_register(gemfile)
35
-
36
+
36
37
  if gemfile =~ /^\w+\:\/\// then
37
-
38
- code = Requestor.read(File.dirname(gemfile)) do |x|
38
+
39
+ code = Requestor.read(File.dirname(gemfile)) do |x|
39
40
  x.require File.basename(gemfile)
40
41
  end
41
-
42
+
42
43
  eval code
43
-
44
+
44
45
  else
45
-
46
+
46
47
  require gemfile
47
-
48
+
48
49
  end
49
-
50
+
50
51
  if defined? RegGem::register then
51
-
52
- self.import RegGem::register
52
+
53
+ self.import RegGem::register
53
54
  true
54
-
55
+
55
56
  else
56
57
  nil
57
58
  end
58
-
59
+
59
60
  end
60
-
61
+
61
62
  def get_key(path, auto_detect_type: false)
62
63
 
63
64
  e = super path
64
65
 
65
66
  return e unless auto_detect_type
66
-
67
+
67
68
  raw_c = e.attributes[:type]
68
69
 
69
70
  c = raw_c if raw_c
70
71
  s = e.text
71
72
 
72
- return e if e.elements.length > 0 or s.nil?
73
+ return e if e.elements.length > 0 or s.nil?
73
74
  return s unless c
74
-
75
+
75
76
  h = {
76
77
  string: ->(x) {x},
77
- boolean: ->(x){
78
+ boolean: ->(x){
78
79
  case x
79
80
  when 'true' then true
80
81
  when 'false' then false
@@ -87,45 +88,45 @@ class DWSRegistry < XMLRegistry
87
88
  time: ->(x) {Time.parse x},
88
89
  json: ->(x) {JSON.parse x}
89
90
  }
90
-
91
- h[c.to_sym].call s
92
-
91
+
92
+ h[c.to_sym].call s
93
+
93
94
  end
94
95
 
95
96
  def set_key(path, value)
96
-
97
+
97
98
  if @debug then
98
- puts 'inside set_key path: ' + path.inspect
99
+ puts 'inside set_key path: ' + path.inspect
99
100
  puts ' value: ' + value.inspect
100
101
  puts ' value.class : ' + value.class.inspect
101
102
  end
102
-
103
+
103
104
  value, type = case value.class.to_s.downcase.to_sym
104
105
  when :string then value
105
106
  when :time then ["#%s#" % value.to_s, :time]
106
107
  when :fixnum then [value.to_s, :number]
107
108
  when :integer then [value.to_s, :number]
108
- when :float then [value.to_s, :number]
109
+ when :float then [value.to_s, :number]
109
110
  when :falseclass then [value.to_s, :boolean]
110
111
  when :trueclass then [value.to_s, :boolean]
111
112
  when :array then ["%s" % value.to_json, :json]
112
113
  else value
113
114
  end
114
-
115
- e = super(path, value)
116
-
115
+
116
+ e = super(path, value)
117
+
117
118
  type = find_type value unless type
118
119
  e.attributes[:type] = type.to_s if type
119
120
  e.parent.attributes[:last_modified] = Time.now.to_s
120
-
121
+
121
122
  save() if @autosave
122
123
 
123
124
  onchange = e.attributes[:onchange]
124
-
125
+
125
126
  if onchange then
126
127
  RScript.new.run onchange.sub('$value', value).split
127
128
  end
128
-
129
+
129
130
  e
130
131
  end
131
132
 
@@ -139,27 +140,27 @@ class DWSRegistry < XMLRegistry
139
140
  super(@filename)
140
141
  end
141
142
 
142
- def import(s)
143
+ def import(s)
143
144
  super(s)
144
145
  save() if @autosave
145
146
  end
146
-
147
+
147
148
  def refresh()
148
- load_xml(@filename)
149
+ load_xml(@filename)
149
150
  end
150
-
151
+
151
152
  private
152
-
153
+
153
154
  def add_value(key, value)
154
155
  e = @doc.root.element(key)
155
156
  e.text = value
156
157
  return e
157
158
  end
158
-
159
+
159
160
  def find_type(v)
160
161
 
161
162
  puts 'v: ' + v.inspect if @debug
162
-
163
+
163
164
  if v[/^\d+$/] and v.to_i.to_s.length == v.length then :number
164
165
  elsif v[/^\d+\.\d+$/] and v.to_f.to_s.length == v.length then :number
165
166
  elsif v.downcase[/^(?:true|false|on|off|yes|no)$/] then :boolean
data.tar.gz.sig CHANGED
Binary file
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.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,27 +10,32 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDXjCCAkagAwIBAgIBATANBgkqhkiG9w0BAQUFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTgwNTI2MTIyMzAwWhcN
15
- MTkwNTI2MTIyMzAwWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDhFT39
17
- uF7y3GY9mhi6PN731nHxrdjgOIb/AdD0xU+S14eEX/hupKoVcMTLQ74qBR0jpXhE
18
- TvWhMPHXmmxcBQJqeJR29uTbpVKmE2Q8+BBE/YwEYlZhfj9ZeKJsIwN37k5pge5i
19
- PErzU/f3qEqYUcSfM/5lLL/yj090qJDvBGKtviBfwe+I4dmwuy3QLeHLDjRozI5+
20
- rMPHcrFDzc2Hpk66nBDibcqwq4Oi0TcG7iY+B8vN/sCK1v61+bWuTS7Xfq03kMz1
21
- Z7adf2t3p8RAY90S7dvAH9flsU/bPjzxj6uJRykqlYhcQ2DsOOKRcjZ9qCfcTZC/
22
- axr33QAlXrqA8PXJAgMBAAGjgYowgYcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
23
- HQYDVR0OBBYEFDnvM9mcHPNkC+/NAwQlU1pIc1pHMCYGA1UdEQQfMB2BG2dlbW1h
24
- c3RlckBqYW1lc3JvYmVydHNvbi5ldTAmBgNVHRIEHzAdgRtnZW1tYXN0ZXJAamFt
25
- ZXNyb2JlcnRzb24uZXUwDQYJKoZIhvcNAQEFBQADggEBAIjS7dxsmC1Zkr/kNxbK
26
- U4k7p7v67ka3xktg6GQjGoVmrxVu/MRBMIQk9AP8lfBJwiDnc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h4pt5d31wDGRcgeZEiXwvL70EWf5/ZEYxVaOypeNSFid29sCAwEA
25
+ AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUowJRfw5D
26
+ klvChabJZhSMvL5PjF4wJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
27
+ c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
28
+ BgkqhkiG9w0BAQsFAAOCAYEAX/yzO2+tSE9ILK+33Wi3AlOjkiV5EyPmbt/zN3rq
29
+ ZvUT2HPhRbWbm51moUDhAnqTp3/3oSwbFwuzjHKn6D8S7zWEPwCOwChL0BsBM2fH
30
+ fr7kvGJ99Ox4ZGvuyVZd38udW0lZd8M//6179KFDMeYWPkAE9GNznGs0kQcJJouB
31
+ 1/o+gXSpf2IDjk5jNL6wy5eybwI6k+UU2nk8FhfO0S0qEvWyldhvMrJZPyBxAULl
32
+ g1o/wESBNM84moSIsI8ifCGGr587eAoi7ee8f7gX6jIx86dmEktJk45hb2P4HFLh
33
+ JQtv79dblSdtDmOkSPmDno62VyyZ2WFYiRBcL1iOqduY+HxMee4Y58N2v+60g15y
34
+ zl3twGqOmIgxT6PlWIUhLXchNfPD2Y1E0ruwYOLYF8WkVYNaARxpXp4kEs2SPGFT
35
+ /ArK0zi1UbowqPGV8bDI5U/tQBYydUuDyqAjSF2aZ5XSherLHoK7aBGAaJKn2gwy
36
+ Zkhg8x25XmgmwWK1wohJdFY4
32
37
  -----END CERTIFICATE-----
33
- date: 2018-10-14 00:00:00.000000000 Z
38
+ date: 2022-02-23 00:00:00.000000000 Z
34
39
  dependencies:
35
40
  - !ruby/object:Gem::Dependency
36
41
  name: xml-registry
@@ -38,42 +43,42 @@ dependencies:
38
43
  requirements:
39
44
  - - "~>"
40
45
  - !ruby/object:Gem::Version
41
- version: '0.6'
46
+ version: '0.8'
42
47
  - - ">="
43
48
  - !ruby/object:Gem::Version
44
- version: 0.6.0
49
+ version: 0.8.0
45
50
  type: :runtime
46
51
  prerelease: false
47
52
  version_requirements: !ruby/object:Gem::Requirement
48
53
  requirements:
49
54
  - - "~>"
50
55
  - !ruby/object:Gem::Version
51
- version: '0.6'
56
+ version: '0.8'
52
57
  - - ">="
53
58
  - !ruby/object:Gem::Version
54
- version: 0.6.0
59
+ version: 0.8.0
55
60
  - !ruby/object:Gem::Dependency
56
61
  name: requestor
57
62
  requirement: !ruby/object:Gem::Requirement
58
63
  requirements:
59
64
  - - "~>"
60
65
  - !ruby/object:Gem::Version
61
- version: '0.2'
66
+ version: '0.5'
62
67
  - - ">="
63
68
  - !ruby/object:Gem::Version
64
- version: 0.2.1
69
+ version: 0.5.0
65
70
  type: :runtime
66
71
  prerelease: false
67
72
  version_requirements: !ruby/object:Gem::Requirement
68
73
  requirements:
69
74
  - - "~>"
70
75
  - !ruby/object:Gem::Version
71
- version: '0.2'
76
+ version: '0.5'
72
77
  - - ">="
73
78
  - !ruby/object:Gem::Version
74
- version: 0.2.1
79
+ version: 0.5.0
75
80
  description:
76
- email: james@jamesrobertson.eu
81
+ email: digital.robertson@gmail.com
77
82
  executables: []
78
83
  extensions: []
79
84
  extra_rdoc_files: []
@@ -98,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
103
  - !ruby/object:Gem::Version
99
104
  version: '0'
100
105
  requirements: []
101
- rubyforge_project:
102
- rubygems_version: 2.7.6
106
+ rubygems_version: 3.2.22
103
107
  signing_key:
104
108
  specification_version: 4
105
109
  summary: An XML registry which stores the Ruby data type as well as the value
metadata.gz.sig CHANGED
Binary file