safrano 0.3.0 → 0.3.1

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: ffa3b9e1f282380dcdd32162bca490faa4749e05a1db11d65dc2b0c25c5ee76c
4
- data.tar.gz: eae063a3541b8eec09bea8d98adf04dc4ad6bed16bdfe6dc3c06fd2df7bb0baf
3
+ metadata.gz: '068df72ed0e610de674a7f8771f1ff4e5a8e1d4217c5755c08bab78e3c735588'
4
+ data.tar.gz: e45fc20c09b7717c1354e80c9e7afd6b4e71a0b27cc97c99b2fd51b99abcb083
5
5
  SHA512:
6
- metadata.gz: 0c910a0f9677d820f85ae00926b3e7f4f5b29126aa86f5386868d8681e3b9808d44d3f31a6adddac861d98ed1d6969a955691c75262c7a2f892110a4dc948797
7
- data.tar.gz: 54b66c00dc7456739457cc58d7a1a68aff8f9a35dccfda3f04b7b83ce12ac7a7e9525d95b7a620cb0e779467e67b26ae3342675477e5c7a49fdb8063bad12183
6
+ metadata.gz: 709fe03f7939265381c276192a1db812a26a55a14914de89ae220f37b99efe21ed057f05c0e071bb388eef21c01df9a8408557aca6bc19e30a2767752f7d39f4
7
+ data.tar.gz: b4fb2033ec0fd0568c23762cbf660f36e879574367c61617c022847fee64747762943139eb91849f8ae762182688c7e424db5545539e1f7896e10c3e6db62113
@@ -562,4 +562,3 @@ module MIME
562
562
  end
563
563
  end
564
564
  end
565
-
@@ -290,7 +290,8 @@ module OData
290
290
 
291
291
  def to_odata_links_json(service:)
292
292
  { 'd' => service.get_coll_odata_links_h(array: get_a,
293
- uribase: @uribase) }.to_json
293
+ uribase: @uribase,
294
+ icount: @inlinecount) }.to_json
294
295
  end
295
296
 
296
297
  def to_odata_json(service:)
@@ -75,7 +75,9 @@ module OData
75
75
 
76
76
  def apply_to_dataset(dtcx)
77
77
  @olist.each { |oarg|
78
- dtcx = dtcx.order(oarg)
78
+ # Warning, we need order_append, simply order(oarg) overwrites
79
+ # previous one !
80
+ dtcx = dtcx.order_append(oarg)
79
81
  }
80
82
  dtcx
81
83
  end
@@ -114,7 +114,7 @@ module OData
114
114
  (v + v.gmt_offset).utc.to_datetime
115
115
  else
116
116
  v
117
- end
117
+ end
118
118
  }
119
119
  end
120
120
 
@@ -45,6 +45,7 @@ module OData
45
45
 
46
46
  if @filt.nil?
47
47
  dtcx = @jh.dataset.select_all(@jh.start_model.table_name)
48
+
48
49
  @ordby.apply_to_dataset(dtcx)
49
50
  elsif @ordby.nil?
50
51
  @filt.apply_to_dataset(dtcx)
@@ -228,6 +228,7 @@ module Sequel
228
228
  jh
229
229
  end
230
230
  end
231
+
231
232
  module DatasetMethods
232
233
  attr_reader :join_helper
233
234
  def join_by_paths(*pathlist)
@@ -31,6 +31,21 @@ module OData
31
31
  yield k, rest_exp
32
32
  end
33
33
 
34
+ # default v2
35
+ # overriden in ServiceV1
36
+ def get_coll_odata_h(array:, expand: nil, uribase:, icount: nil)
37
+ res = array.map do |w|
38
+ get_entity_odata_h(entity: w,
39
+ expand: expand,
40
+ uribase: uribase)
41
+ end
42
+ if icount
43
+ { 'results' => res, '__count' => icount }
44
+ else
45
+ { 'results' => res }
46
+ end
47
+ end
48
+
34
49
  # handle a single expand
35
50
  def handle_entity_expand_one(entity:, exp_one:, nav_values_h:, nav_coll_h:,
36
51
  uribase:)
@@ -42,11 +57,10 @@ module OData
42
57
  uribase: uribase)
43
58
  elsif (encoll = entity.nav_coll[first])
44
59
  # nav attributes that are a collection (x..n)
45
- nav_coll_h[first.to_s] = encoll.map do |xe|
46
- if xe
47
- get_entity_odata_h(entity: xe, expand: rest_exp, uribase: uribase)
48
- end
49
- end
60
+ nav_coll_h[first.to_s] = get_coll_odata_h(array: encoll,
61
+ expand: rest_exp,
62
+ uribase: uribase)
63
+
50
64
  end
51
65
  end
52
66
  end
@@ -142,6 +156,9 @@ module OData
142
156
  include XMLNS
143
157
  # Base class for service. Subclass will be for V1, V2 etc...
144
158
  class ServiceBase
159
+ include Safrano
160
+ include ExpandHandler
161
+
145
162
  XML_PREAMBLE = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>' + \
146
163
  "\r\n".freeze
147
164
 
@@ -318,9 +335,6 @@ module OData
318
335
  @collections.map(&:entity_set_name).join('|')
319
336
  end
320
337
 
321
- include Safrano
322
- include ExpandHandler
323
-
324
338
  def service
325
339
  hres = {}
326
340
  hres['d'] = { 'EntitySets' => @collections.map(&:type_name) }
@@ -496,6 +510,12 @@ module OData
496
510
  @data_service_version = '1.0'
497
511
  end
498
512
 
513
+ def get_coll_odata_links_h(array:, uribase:, icount: nil)
514
+ array.map do |w|
515
+ get_entity_odata_link_h(entity: w, uribase: uribase)
516
+ end
517
+ end
518
+
499
519
  def get_coll_odata_h(array:, expand: nil, uribase:, icount: nil)
500
520
  array.map do |w|
501
521
  get_entity_odata_h(entity: w,
@@ -515,17 +535,9 @@ module OData
515
535
  @data_service_version = '2.0'
516
536
  end
517
537
 
518
- def get_coll_odata_links_h(array:, uribase:)
519
- array.map do |w|
520
- get_entity_odata_link_h(entity: w, uribase: uribase)
521
- end
522
- end
523
-
524
- def get_coll_odata_h(array:, expand: nil, uribase:, icount: nil)
538
+ def get_coll_odata_links_h(array:, uribase:, icount: nil)
525
539
  res = array.map do |w|
526
- get_entity_odata_h(entity: w,
527
- expand: expand,
528
- uribase: uribase)
540
+ get_entity_odata_link_h(entity: w, uribase: uribase)
529
541
  end
530
542
  if icount
531
543
  { 'results' => res, '__count' => icount }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safrano
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - D.M.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-23 00:00:00.000000000 Z
11
+ date: 2019-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack