safrano 0.4.1 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/core_ext/Dir/iter.rb +18 -0
- data/lib/core_ext/Hash/transform.rb +21 -0
- data/lib/core_ext/Integer/edm.rb +13 -0
- data/lib/core_ext/REXML/Document/output.rb +16 -0
- data/lib/core_ext/String/convert.rb +25 -0
- data/lib/core_ext/String/edm.rb +13 -0
- data/lib/core_ext/dir.rb +3 -0
- data/lib/core_ext/hash.rb +3 -0
- data/lib/core_ext/integer.rb +3 -0
- data/lib/core_ext/rexml.rb +3 -0
- data/lib/core_ext/string.rb +5 -0
- data/lib/odata/attribute.rb +15 -10
- data/lib/odata/batch.rb +15 -13
- data/lib/odata/collection.rb +144 -535
- data/lib/odata/collection_filter.rb +47 -40
- data/lib/odata/collection_media.rb +155 -99
- data/lib/odata/collection_order.rb +50 -37
- data/lib/odata/common_logger.rb +36 -34
- data/lib/odata/complex_type.rb +152 -0
- data/lib/odata/edm/primitive_types.rb +184 -0
- data/lib/odata/entity.rb +183 -216
- data/lib/odata/error.rb +195 -31
- data/lib/odata/expand.rb +126 -0
- data/lib/odata/filter/base.rb +74 -0
- data/lib/odata/filter/error.rb +49 -6
- data/lib/odata/filter/parse.rb +44 -36
- data/lib/odata/filter/sequel.rb +136 -67
- data/lib/odata/filter/sequel_function_adapter.rb +148 -0
- data/lib/odata/filter/token.rb +26 -19
- data/lib/odata/filter/tree.rb +113 -63
- data/lib/odata/function_import.rb +168 -0
- data/lib/odata/model_ext.rb +639 -0
- data/lib/odata/navigation_attribute.rb +44 -61
- data/lib/odata/relations.rb +5 -5
- data/lib/odata/select.rb +54 -0
- data/lib/odata/transition.rb +71 -0
- data/lib/odata/url_parameters.rb +128 -37
- data/lib/odata/walker.rb +20 -10
- data/lib/safrano.rb +17 -37
- data/lib/safrano/contract.rb +143 -0
- data/lib/safrano/core.rb +29 -104
- data/lib/safrano/core_ext.rb +13 -0
- data/lib/safrano/deprecation.rb +73 -0
- data/lib/safrano/multipart.rb +39 -43
- data/lib/safrano/rack_app.rb +68 -67
- data/lib/safrano/{odata_rack_builder.rb → rack_builder.rb} +18 -2
- data/lib/safrano/request.rb +102 -51
- data/lib/safrano/response.rb +5 -3
- data/lib/safrano/sequel_join_by_paths.rb +2 -2
- data/lib/safrano/service.rb +274 -219
- data/lib/safrano/version.rb +3 -1
- data/lib/sequel/plugins/join_by_paths.rb +17 -29
- metadata +34 -11
data/lib/safrano/version.rb
CHANGED
@@ -1,31 +1,14 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'set'
|
4
4
|
require 'sequel'
|
5
5
|
|
6
|
-
|
7
|
-
class String
|
8
|
-
# thanks https://stackoverflow.com/questions/1448670/ruby-stringto-class
|
9
|
-
def constantize
|
10
|
-
names = split('::')
|
11
|
-
names.shift if names.empty? || names.first.empty?
|
12
|
-
|
13
|
-
const = Object
|
14
|
-
names.each do |name|
|
15
|
-
const = if const.const_defined?(name)
|
16
|
-
const.const_get(name)
|
17
|
-
else
|
18
|
-
const.const_missing(name)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
const
|
22
|
-
end
|
23
|
-
end
|
6
|
+
require 'safrano/core_ext'
|
24
7
|
|
25
8
|
class PathNode < String
|
26
|
-
attr_reader :table_name
|
27
9
|
attr_accessor :model_class
|
28
10
|
attr_accessor :path_str
|
11
|
+
|
29
12
|
def initialize(str, start_model)
|
30
13
|
super(str)
|
31
14
|
@start_model = start_model
|
@@ -80,14 +63,14 @@ class QPath
|
|
80
63
|
path_nodes = []
|
81
64
|
start_node.path_str = path_str
|
82
65
|
nodes = [start_node]
|
83
|
-
nodes.concat
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
66
|
+
nodes.concat(@qpath.split('/').map { |nstr| @start_model.create_path_node(nstr) })
|
67
|
+
return unless nodes.size > 1
|
68
|
+
|
69
|
+
nodes[0...-1].each_with_index do |node, i|
|
70
|
+
nodes[i + 1].set_model_class_by_parent_model(node.model_class)
|
71
|
+
path_nodes << nodes[i + 1]
|
72
|
+
nodes[i + 1].path_str = path_nodes.join('/')
|
73
|
+
@segments << [node, nodes[i + 1]]
|
91
74
|
end
|
92
75
|
end
|
93
76
|
end
|
@@ -96,13 +79,15 @@ class JoinByPathsHelper < Set
|
|
96
79
|
attr_reader :result
|
97
80
|
attr_reader :start_model
|
98
81
|
|
82
|
+
EMPTY_ARRAY = [].freeze
|
83
|
+
|
99
84
|
def initialize(smodel)
|
100
85
|
super()
|
101
86
|
@start_model = smodel
|
102
87
|
end
|
103
88
|
|
104
89
|
def build_unique_join_segments
|
105
|
-
return (@result =
|
90
|
+
return (@result = EMPTY_ARRAY) if empty?
|
106
91
|
|
107
92
|
maxlen = map(&:size).max
|
108
93
|
iset = nil
|
@@ -118,6 +103,7 @@ class JoinByPathsHelper < Set
|
|
118
103
|
jseg.map do |seg|
|
119
104
|
leftm = seg.first.model_class
|
120
105
|
assoc = leftm.association_reflection(seg.last.to_sym)
|
106
|
+
|
121
107
|
rightm = seg.last.model_class
|
122
108
|
# cf. documentation in sequel/model/associations.rb
|
123
109
|
case assoc[:type]
|
@@ -205,6 +191,7 @@ module Sequel
|
|
205
191
|
module ClassMethods
|
206
192
|
attr_reader :aliases_sym
|
207
193
|
attr_reader :alias_cnt
|
194
|
+
|
208
195
|
Plugins.inherited_instance_variables(self,
|
209
196
|
:@aliases_sym => :dup,
|
210
197
|
:@alias_cnt => :dup)
|
@@ -231,6 +218,7 @@ module Sequel
|
|
231
218
|
|
232
219
|
module DatasetMethods
|
233
220
|
attr_reader :join_helper
|
221
|
+
|
234
222
|
def join_by_paths(*pathlist)
|
235
223
|
model.join_by_paths_helper(*pathlist).dataset
|
236
224
|
end
|
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.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- oz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: rfc2047
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '0.3'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
68
|
+
version: '0.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,12 +108,23 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0.51'
|
111
|
-
description: Safrano is an OData server library based on Ruby
|
111
|
+
description: Safrano is an OData server library based on Ruby Sequel and Rack.
|
112
112
|
email: dev@aithscel.eu
|
113
113
|
executables: []
|
114
114
|
extensions: []
|
115
115
|
extra_rdoc_files: []
|
116
116
|
files:
|
117
|
+
- lib/core_ext/Dir/iter.rb
|
118
|
+
- lib/core_ext/Hash/transform.rb
|
119
|
+
- lib/core_ext/Integer/edm.rb
|
120
|
+
- lib/core_ext/REXML/Document/output.rb
|
121
|
+
- lib/core_ext/String/convert.rb
|
122
|
+
- lib/core_ext/String/edm.rb
|
123
|
+
- lib/core_ext/dir.rb
|
124
|
+
- lib/core_ext/hash.rb
|
125
|
+
- lib/core_ext/integer.rb
|
126
|
+
- lib/core_ext/rexml.rb
|
127
|
+
- lib/core_ext/string.rb
|
117
128
|
- lib/odata/attribute.rb
|
118
129
|
- lib/odata/batch.rb
|
119
130
|
- lib/odata/collection.rb
|
@@ -121,22 +132,34 @@ files:
|
|
121
132
|
- lib/odata/collection_media.rb
|
122
133
|
- lib/odata/collection_order.rb
|
123
134
|
- lib/odata/common_logger.rb
|
135
|
+
- lib/odata/complex_type.rb
|
136
|
+
- lib/odata/edm/primitive_types.rb
|
124
137
|
- lib/odata/entity.rb
|
125
138
|
- lib/odata/error.rb
|
139
|
+
- lib/odata/expand.rb
|
140
|
+
- lib/odata/filter/base.rb
|
126
141
|
- lib/odata/filter/error.rb
|
127
142
|
- lib/odata/filter/parse.rb
|
128
143
|
- lib/odata/filter/sequel.rb
|
144
|
+
- lib/odata/filter/sequel_function_adapter.rb
|
129
145
|
- lib/odata/filter/token.rb
|
130
146
|
- lib/odata/filter/tree.rb
|
147
|
+
- lib/odata/function_import.rb
|
148
|
+
- lib/odata/model_ext.rb
|
131
149
|
- lib/odata/navigation_attribute.rb
|
132
150
|
- lib/odata/relations.rb
|
151
|
+
- lib/odata/select.rb
|
152
|
+
- lib/odata/transition.rb
|
133
153
|
- lib/odata/url_parameters.rb
|
134
154
|
- lib/odata/walker.rb
|
135
155
|
- lib/safrano.rb
|
156
|
+
- lib/safrano/contract.rb
|
136
157
|
- lib/safrano/core.rb
|
158
|
+
- lib/safrano/core_ext.rb
|
159
|
+
- lib/safrano/deprecation.rb
|
137
160
|
- lib/safrano/multipart.rb
|
138
|
-
- lib/safrano/odata_rack_builder.rb
|
139
161
|
- lib/safrano/rack_app.rb
|
162
|
+
- lib/safrano/rack_builder.rb
|
140
163
|
- lib/safrano/request.rb
|
141
164
|
- lib/safrano/response.rb
|
142
165
|
- lib/safrano/sequel_join_by_paths.rb
|
@@ -166,8 +189,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
189
|
- !ruby/object:Gem::Version
|
167
190
|
version: '0'
|
168
191
|
requirements: []
|
169
|
-
rubygems_version: 3.
|
192
|
+
rubygems_version: 3.2.5
|
170
193
|
signing_key:
|
171
194
|
specification_version: 4
|
172
|
-
summary: Safrano is
|
195
|
+
summary: Safrano is an OData server library based on Ruby Sequel and Rack
|
173
196
|
test_files: []
|