dws-registry 0.4.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ddb57e224865e3fb5607c57cf78f0de374d5bec1
4
- data.tar.gz: e853160f15ac6de49054841bec408cff55b9905d
2
+ SHA256:
3
+ metadata.gz: 0d341ebac9fd10a3216588c7651caa6e2b4e28619fc3decbb4d6764c95d7f1c0
4
+ data.tar.gz: 613d9fc137c636f77043f4ebb58e5d1412b4f08d38f1fbf3e192e9eea1f3db14
5
5
  SHA512:
6
- metadata.gz: c3a969f0e04a4a21dd2fae6ed4c496447fba9119139d3bb707d2a74016b05b24b45d668851290ea6772d4ea4b7c17271eb64ce9697ccdb16715c2175f881e6a5
7
- data.tar.gz: bbf4235e42346ee4c2811956c5678f0be6e40a433dcc5d2aec7a27b2028963e52d2788765f034f38b2fcb0afb3d2a8fba3ab10091fd9316344a5d8b0480d5776
6
+ metadata.gz: 666c0c408e1b783b2b2da18a0843ed59350038f4493af5bbc21dd4928bb37d058e3237d7386561f0a1fcf11ef76663db1544ad9cc4f15d355ad3b9f384a79c39
7
+ data.tar.gz: 629d903bdc1a4d4e8cf70e9fe66937853398a04c9d58e3e9667e68ad99e1c7a9c578322a1bfcceaae7aa744b2ff6688f7f27d08c0f7b52f52809ca1540b1abfd
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/dws-registry.rb CHANGED
@@ -6,47 +6,76 @@ require 'time'
6
6
  require 'xml-registry'
7
7
  require 'rscript'
8
8
  require 'json'
9
+ require 'requestor'
10
+ require 'rxfreader'
9
11
 
10
12
 
11
13
  class DWSRegistry < XMLRegistry
12
- include RXFHelperModule
13
-
14
- def initialize(filename='registry.xml', autosave: true)
15
-
16
- super()
17
-
18
- @autosave = autosave
19
-
14
+ include RXFRead
15
+
16
+ def initialize(filename='registry.xml', autosave: true, debug: false)
17
+
18
+ super(debug: debug)
19
+
20
+ @autosave = autosave
21
+
20
22
  if filename then
21
23
 
22
- @filename = filename
23
-
24
+ @filename = filename
25
+
24
26
  if FileX.exists? filename then
25
27
  load_xml(filename)
26
28
  else
27
29
  save()
28
- end
30
+ end
29
31
 
30
32
  end
31
33
  end
32
-
34
+
35
+ def gem_register(gemfile)
36
+
37
+ if gemfile =~ /^\w+\:\/\// then
38
+
39
+ code = Requestor.read(File.dirname(gemfile)) do |x|
40
+ x.require File.basename(gemfile)
41
+ end
42
+
43
+ eval code
44
+
45
+ else
46
+
47
+ require gemfile
48
+
49
+ end
50
+
51
+ if defined? RegGem::register then
52
+
53
+ self.import RegGem::register
54
+ true
55
+
56
+ else
57
+ nil
58
+ end
59
+
60
+ end
61
+
33
62
  def get_key(path, auto_detect_type: false)
34
63
 
35
64
  e = super path
36
65
 
37
66
  return e unless auto_detect_type
38
-
67
+
39
68
  raw_c = e.attributes[:type]
40
69
 
41
70
  c = raw_c if raw_c
42
71
  s = e.text
43
72
 
44
- return e if e.elements.length > 0 or s.nil?
73
+ return e if e.elements.length > 0 or s.nil?
45
74
  return s unless c
46
-
75
+
47
76
  h = {
48
77
  string: ->(x) {x},
49
- boolean: ->(x){
78
+ boolean: ->(x){
50
79
  case x
51
80
  when 'true' then true
52
81
  when 'false' then false
@@ -59,38 +88,45 @@ class DWSRegistry < XMLRegistry
59
88
  time: ->(x) {Time.parse x},
60
89
  json: ->(x) {JSON.parse x}
61
90
  }
62
-
63
- h[c.to_sym].call s
64
-
91
+
92
+ h[c.to_sym].call s
93
+
65
94
  end
66
95
 
67
96
  def set_key(path, value)
68
-
97
+
98
+ if @debug then
99
+ puts 'inside set_key path: ' + path.inspect
100
+ puts ' value: ' + value.inspect
101
+ puts ' value.class : ' + value.class.inspect
102
+ end
103
+
69
104
  value, type = case value.class.to_s.downcase.to_sym
70
105
  when :string then value
71
106
  when :time then ["#%s#" % value.to_s, :time]
72
107
  when :fixnum then [value.to_s, :number]
73
108
  when :integer then [value.to_s, :number]
74
- when :float then [value.to_s, :number]
109
+ when :float then [value.to_s, :number]
75
110
  when :falseclass then [value.to_s, :boolean]
76
111
  when :trueclass then [value.to_s, :boolean]
77
112
  when :array then ["%s" % value.to_json, :json]
113
+ else value
78
114
  end
79
-
80
- e = super(path, value)
81
-
115
+
116
+ e = super(path, value)
117
+
82
118
  type = find_type value unless type
83
119
  e.attributes[:type] = type.to_s if type
84
120
  e.parent.attributes[:last_modified] = Time.now.to_s
85
-
121
+
86
122
  save() if @autosave
87
123
 
88
124
  onchange = e.attributes[:onchange]
89
-
125
+
90
126
  if onchange then
91
127
  RScript.new.run onchange.sub('$value', value).split
92
128
  end
93
-
129
+
94
130
  e
95
131
  end
96
132
 
@@ -104,25 +140,27 @@ class DWSRegistry < XMLRegistry
104
140
  super(@filename)
105
141
  end
106
142
 
107
- def import(s)
143
+ def import(s)
108
144
  super(s)
109
145
  save() if @autosave
110
146
  end
111
-
147
+
112
148
  def refresh()
113
- load_xml(@filename)
149
+ load_xml(@filename)
114
150
  end
115
-
151
+
116
152
  private
117
-
153
+
118
154
  def add_value(key, value)
119
155
  e = @doc.root.element(key)
120
156
  e.text = value
121
157
  return e
122
158
  end
123
-
159
+
124
160
  def find_type(v)
125
161
 
162
+ puts 'v: ' + v.inspect if @debug
163
+
126
164
  if v[/^\d+$/] and v.to_i.to_s.length == v.length then :number
127
165
  elsif v[/^\d+\.\d+$/] and v.to_f.to_s.length == v.length then :number
128
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.4.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,30 +10,55 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDXjCCAkagAwIBAgIBATANBgkqhkiG9w0BAQUFADAsMSowKAYDV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zcm9iZXJ0
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-05-26 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
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.8'
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 0.8.0
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '0.8'
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 0.8.0
60
+ - !ruby/object:Gem::Dependency
61
+ name: requestor
37
62
  requirement: !ruby/object:Gem::Requirement
38
63
  requirements:
39
64
  - - "~>"
@@ -41,7 +66,7 @@ dependencies:
41
66
  version: '0.5'
42
67
  - - ">="
43
68
  - !ruby/object:Gem::Version
44
- version: 0.5.5
69
+ version: 0.5.0
45
70
  type: :runtime
46
71
  prerelease: false
47
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -51,9 +76,9 @@ dependencies:
51
76
  version: '0.5'
52
77
  - - ">="
53
78
  - !ruby/object:Gem::Version
54
- version: 0.5.5
79
+ version: 0.5.0
55
80
  description:
56
- email: james@jamesrobertson.eu
81
+ email: digital.robertson@gmail.com
57
82
  executables: []
58
83
  extensions: []
59
84
  extra_rdoc_files: []
@@ -78,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
103
  - !ruby/object:Gem::Version
79
104
  version: '0'
80
105
  requirements: []
81
- rubyforge_project:
82
- rubygems_version: 2.6.13
106
+ rubygems_version: 3.2.22
83
107
  signing_key:
84
108
  specification_version: 4
85
109
  summary: An XML registry which stores the Ruby data type as well as the value
metadata.gz.sig CHANGED
Binary file