riddl 0.99.250 → 0.99.251

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
  SHA1:
3
- metadata.gz: 52ad17085955e4db82cc7dd85550a6638ad05e04
4
- data.tar.gz: 91c83c80020f80e5becd37e610b655d8a0371388
3
+ metadata.gz: 2f31b4c6dbd6943a80f4fe56b1bac9bbae589b4c
4
+ data.tar.gz: cb4df6a929ec0980612e1959448abb1cfe301d34
5
5
  SHA512:
6
- metadata.gz: ba00c901896c793ffc941dd7ef13544f470434cfb81c08bd78e4a7a8df87a6484c33fe42f399432bb965c30a5dda99ca25420bf98e97147554cc5df710c32471
7
- data.tar.gz: d75cca4d75dfdd7c7c3b35ee3904fc583552acffe45049f36e01f5a89f409572e0963348492ce4817a6f132b24c86ddc638bd74638c356f0baebf7574a203654
6
+ metadata.gz: 3d9921cd7ce15254b8833e747fe1b8c1aa97fb8f31c5ffa05171f70c69927f045c5830e415210aa0b9d8f07dccaf5b9ede623660551aac8894f500d043f53807
7
+ data.tar.gz: 14f58ca1b5a2fe31f109bfe83126b87e981fe896adb7295f14256e51413241782444ac62dd4e0a1ab437208b15ed9a86d407d0b9f350f37bbaaf5994072fa21e
@@ -3,8 +3,8 @@ module Riddl
3
3
  module Notifications
4
4
 
5
5
  module Producer
6
-
7
- def self::implementation(backend,handler=nil,details=:production)
6
+
7
+ def self::implementation(backend,handler=nil,details=:production)
8
8
  unless handler.nil? || (handler.is_a? Riddl::Utils::Notifications::Producer::HandlerBase)
9
9
  raise "handler not a subclass of HandlerBase"
10
10
  end
@@ -26,10 +26,10 @@ module Riddl
26
26
  end
27
27
  end
28
28
  end
29
- end
29
+ end
30
30
  end
31
- end
32
-
31
+ end
32
+
33
33
  class HandlerBase #{{{
34
34
  def initialize(data)
35
35
  @data = data
@@ -58,7 +58,7 @@ module Riddl
58
58
  class Sub #{{{
59
59
  def initialize(name)
60
60
  @name = name
61
- end
61
+ end
62
62
  def modify(&block)
63
63
  XML::Smart.modify(@name,"<subscription xmlns='http://riddl.org/ns/common-patterns/notifications-producer/1.0'/>") do |doc|
64
64
  doc.register_namespace 'n', 'http://riddl.org/ns/common-patterns/notifications-producer/1.0'
@@ -75,7 +75,7 @@ module Riddl
75
75
  XML::Smart.open_unprotected(@name) do |doc|
76
76
  doc.register_namespace 'n', 'http://riddl.org/ns/common-patterns/notifications-producer/1.0'
77
77
  block.call doc
78
- end
78
+ end
79
79
  end
80
80
  end #}}}
81
81
 
@@ -88,7 +88,7 @@ module Riddl
88
88
  keys.each do |key|
89
89
  f = @target + '/' + key + '/subscription.xml'
90
90
  block.call Sub.new(f), key if File.exists? f
91
- end
91
+ end
92
92
  end
93
93
 
94
94
  def include?(key)
@@ -130,10 +130,15 @@ module Riddl
130
130
  end
131
131
  end #}}}
132
132
 
133
- def initialize(topics,target)
133
+ def initialize(topics,target,init=nil)
134
134
  @target = target.gsub(/^\/+/,'/')
135
135
 
136
- FileUtils::mkdir_p(@target) unless File.exists?(@target)
136
+
137
+ if init and not File.exists?(@target)
138
+ FileUtils::cp_r init, @target
139
+ else
140
+ FileUtils::mkdir_p(@target) unless File.exists?(@target)
141
+ end
137
142
 
138
143
  raise "topics file not found" unless File.exists?(topics)
139
144
  @topics = XML::Smart.open_unprotected(topics.gsub(/^\/+/,'/'))
@@ -146,7 +151,7 @@ module Riddl
146
151
  end
147
152
  end
148
153
  end
149
- end
154
+ end
150
155
 
151
156
  def subscriptions
152
157
  Subs.new(@target)
@@ -154,7 +159,7 @@ module Riddl
154
159
 
155
160
  end #}}}
156
161
 
157
- class Overview < Riddl::Implementation #{{{
162
+ class Overview < Riddl::Implementation #{{{
158
163
  def response
159
164
  Riddl::Parameter::Complex.new("overview","text/xml") do
160
165
  <<-END
@@ -167,7 +172,7 @@ module Riddl
167
172
 
168
173
  end
169
174
  end #}}}
170
-
175
+
171
176
  class Topics < Riddl::Implementation #{{{
172
177
  def response
173
178
  backend = @a[0]
@@ -176,7 +181,7 @@ module Riddl
176
181
  end
177
182
  end
178
183
  end #}}}
179
-
184
+
180
185
  class Subscriptions < Riddl::Implementation #{{{
181
186
  def response
182
187
  backend = @a[0]
@@ -189,7 +194,7 @@ module Riddl
189
194
  sub.read do |doc|
190
195
  if doc.root.attributes['url']
191
196
  ret.root.add('subscription', :id => key, :url => doc.root.attributes['url'])
192
- else
197
+ else
193
198
  ret.root.add('subscription', :id => key)
194
199
  end
195
200
  end
@@ -198,7 +203,7 @@ module Riddl
198
203
  end
199
204
  end
200
205
  end #}}}
201
-
206
+
202
207
  class Subscription < Riddl::Implementation #{{{
203
208
  def response
204
209
  backend = @a[0]
@@ -211,7 +216,7 @@ module Riddl
211
216
  end
212
217
  end
213
218
  end #}}}
214
-
219
+
215
220
  class CreateSubscription < Riddl::Implementation #{{{
216
221
  def response
217
222
  backend = @a[0]
@@ -237,14 +242,14 @@ module Riddl
237
242
  t.add(type[0..-2], i)
238
243
  end
239
244
  end
240
- end
245
+ end
241
246
 
242
247
  handler.key(key).topics(topics).create unless handler.nil?
243
248
  [
244
249
  Riddl::Parameter::Simple.new('key',key),
245
250
  Riddl::Parameter::Simple.new('producer-secret',producer_secret),
246
251
  Riddl::Parameter::Simple.new('consumer-secret',consumer_secret)
247
- ]
252
+ ]
248
253
  end
249
254
  end #}}}
250
255
 
@@ -259,7 +264,7 @@ module Riddl
259
264
  return
260
265
  end
261
266
  end #}}}
262
-
267
+
263
268
  class UpdateSubscription < Riddl::Implementation #{{{
264
269
  def response
265
270
  backend = @a[0]
@@ -297,13 +302,13 @@ module Riddl
297
302
  t.add(type[0..-2], i)
298
303
  end
299
304
  end
300
- end
305
+ end
301
306
 
302
307
  handler.key(key).topics(topics).update unless handler.nil?
303
308
  nil
304
309
  end
305
310
  end #}}}
306
-
311
+
307
312
  class WS < Riddl::WebSocketImplementation #{{{
308
313
  def onopen
309
314
  @backend = @a[0]
@@ -320,8 +325,8 @@ module Riddl
320
325
  @handler.key(@key).ws_close() unless @handler.nil?
321
326
  end
322
327
  end #}}}
323
-
324
- end
328
+
329
+ end
325
330
 
326
331
  end
327
332
  end
@@ -17,7 +17,7 @@ module Riddl
17
17
  run Riddl::Utils::Properties::Schema, backend if get
18
18
  on resource 'rng' do
19
19
  run Riddl::Utils::Properties::RngSchema, backend if get
20
- end
20
+ end
21
21
  end
22
22
  on resource 'values' do
23
23
  run Riddl::Utils::Properties::Properties, backend, handler if get
@@ -37,9 +37,9 @@ module Riddl
37
37
  end
38
38
  end
39
39
  end
40
- end
40
+ end
41
41
  end
42
- end
42
+ end
43
43
 
44
44
  # Overloadable and Backends
45
45
  class HandlerBase #{{{
@@ -50,7 +50,7 @@ module Riddl
50
50
  def property(p)
51
51
  @property = p
52
52
  self
53
- end
53
+ end
54
54
  def create; end
55
55
  def read; end
56
56
  def update; end
@@ -58,7 +58,7 @@ module Riddl
58
58
  end #}}}
59
59
 
60
60
  class Backend #{{{
61
- attr_reader :schema, :data, :rng
61
+ attr_reader :schema, :data, :rng
62
62
 
63
63
  def initialize(schema,target,init=nil)
64
64
  @target = target.gsub(/^\/+/,'/')
@@ -67,7 +67,7 @@ module Riddl
67
67
 
68
68
  if schema.is_a? Hash
69
69
  schema.each { |k,v| add_schema k, v }
70
- elsif schema.is_a? String
70
+ elsif schema.is_a? String
71
71
  add_schema 'default', schema
72
72
  end
73
73
  raise "no schemas provided" if @schemas.length == 0
@@ -99,7 +99,7 @@ module Riddl
99
99
  @schemas[key].register_namespace 'p', 'http://riddl.org/ns/common-patterns/properties/1.0'
100
100
  if !File::exists?(Riddl::Utils::Properties::PROPERTIES_SCHEMA_XSL_RNG)
101
101
  raise "properties schema transformation file not found"
102
- end
102
+ end
103
103
  @rngs[key] = @schemas[key].transform_with(XML::Smart.open_unprotected(Riddl::Utils::Properties::PROPERTIES_SCHEMA_XSL_RNG))
104
104
  end
105
105
  private :add_schema
@@ -133,7 +133,7 @@ module Riddl
133
133
  else
134
134
  false
135
135
  end
136
- end
136
+ end
137
137
  end
138
138
  end #}}}
139
139
 
@@ -159,7 +159,7 @@ module Riddl
159
159
  end
160
160
  return Riddl::Parameter::Complex.new("keys","text/xml",ret.to_s)
161
161
  end
162
- end #}}}
162
+ end #}}}
163
163
 
164
164
  class Query < Riddl::Implementation #{{{
165
165
  def response
@@ -215,7 +215,7 @@ module Riddl
215
215
  @status = 404
216
216
  end
217
217
  end
218
-
218
+
219
219
  def extract_values(backend,property,minor=nil)
220
220
  case backend.property_type(property)
221
221
  when :complex
@@ -224,9 +224,9 @@ module Riddl
224
224
  prop = XML::Smart::string("<value xmlns=\"http://riddl.org/ns/common-patterns/properties/1.0\"/>")
225
225
  if res.length == 1
226
226
  prop.root.add(res.first.children)
227
- else
227
+ else
228
228
  prop.root.add(res)
229
- end
229
+ end
230
230
  return Riddl::Parameter::Complex.new("value","text/xml",prop.to_s)
231
231
  else
232
232
  prop = XML::Smart::string("<not-existing xmlns=\"http://riddl.org/ns/common-patterns/properties/1.0\"/>")
@@ -253,7 +253,7 @@ module Riddl
253
253
  private :extract_values
254
254
 
255
255
  end #}}}
256
-
256
+
257
257
  # Modifiable
258
258
  class AddProperty < Riddl::Implementation #{{{
259
259
  def response
@@ -282,7 +282,7 @@ module Riddl
282
282
  @status = 404
283
283
  return # not a valid state from here on
284
284
  end
285
- end
285
+ end
286
286
 
287
287
  newstuff = value.nil? ? XML::Smart.string(content).root.children : value
288
288
  backend.modify do |doc|
@@ -291,17 +291,17 @@ module Riddl
291
291
  ele.add newstuff
292
292
  else
293
293
  ele.text = newstuff
294
- end
294
+ end
295
295
  end || begin
296
296
  @status = 400
297
297
  return # bad request
298
298
  end
299
-
299
+
300
300
  EM.defer{handler.property(property).create} unless handler.nil?
301
301
  return
302
302
  end
303
303
  end #}}}
304
-
304
+
305
305
  class AddProperties < Riddl::Implementation #{{{
306
306
  def response
307
307
  backend = @a[0]
@@ -330,24 +330,24 @@ module Riddl
330
330
  @status = 404
331
331
  return # not a valid state from here on
332
332
  end
333
- end
333
+ end
334
334
 
335
335
  newstuff = value.nil? ? XML::Smart.string(content).root.children : value
336
336
  backend.modify do |doc|
337
337
  nodes = doc.find(path)
338
338
  nods = nodes.map{|ele| ele.children.delete_all!; ele}
339
- nods.each do |ele|
339
+ nods.each do |ele|
340
340
  if value.nil?
341
341
  ele.add newstuff
342
342
  else
343
343
  ele.text = newstuff
344
- end
345
- end
344
+ end
345
+ end
346
346
  end || begin
347
347
  @status = 400
348
348
  return # bad request
349
349
  end
350
-
350
+
351
351
  end
352
352
  EM.defer do
353
353
  0.upto(@p.length/2-1) do |i|
@@ -377,7 +377,7 @@ module Riddl
377
377
  if node.empty?
378
378
  @status = 404
379
379
  return # this property does not exist
380
- end
380
+ end
381
381
 
382
382
  newstuff = XML::Smart.string(value)
383
383
  backend.modify do |doc|
@@ -422,7 +422,7 @@ module Riddl
422
422
  EM.defer{handler.property(property).delete} unless handler.nil?
423
423
  return
424
424
  end
425
- end #}}}
425
+ end #}}}
426
426
 
427
427
  class UpdContent < Riddl::Implementation #{{{
428
428
  def response
@@ -451,24 +451,24 @@ module Riddl
451
451
  @status = 404
452
452
  return # not a valid state from here on
453
453
  end
454
- end
454
+ end
455
455
 
456
456
  newstuff = value.nil? ? XML::Smart.string(content).root.children : value
457
457
  backend.modify do |doc|
458
458
  nodes = doc.root.find(path)
459
459
  nods = nodes.map{|ele| ele.children.delete_all!; ele}
460
- nods.each do |ele|
460
+ nods.each do |ele|
461
461
  if value.nil?
462
462
  ele.add newstuff
463
463
  else
464
464
  ele.text = newstuff
465
465
  end
466
- end
466
+ end
467
467
  end || begin
468
468
  @status = 400
469
469
  return # bad request
470
470
  end
471
-
471
+
472
472
  EM.defer{handler.property(property).update} unless handler.nil?
473
473
  return
474
474
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "riddl"
3
- s.version = "0.99.250"
3
+ s.version = "0.99.251"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0"
6
6
  s.summary = "restful interface description and declaration language: tools and client/server libs"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riddl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.99.250
4
+ version: 0.99.251
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen 'eTM' Mangler
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: tools
12
12
  cert_chain: []
13
- date: 2016-09-13 00:00:00.000000000 Z
13
+ date: 2016-11-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: xml-smart