solis 0.94.0 → 0.96.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.
@@ -109,6 +109,7 @@ class Solis::Query::Runner
109
109
  end
110
110
 
111
111
  def self.graph_name
112
+ raise Solis::Error::NotFoundError, 'No graph name found' if Solis::Options.instance.get.key?(:graphs).nil?
112
113
  Solis::Options.instance.get.key?(:graphs) ? Solis::Options.instance.get[:graphs].select{|s| s['type'].eql?(:main)}&.first['name'] : ''
113
114
  end
114
115
  end
data/lib/solis/query.rb CHANGED
@@ -11,8 +11,8 @@ module Solis
11
11
  include Enumerable
12
12
  include Solis::QueryFilter
13
13
 
14
- def self.run(entity, query)
15
- Solis::Query::Runner.run(entity, query)
14
+ def self.run(entity, query, options = {})
15
+ Solis::Query::Runner.run(entity, query, options)
16
16
  end
17
17
 
18
18
  def self.run_construct_with_file(filename, id_name, entity, ids, from_cache = '1')
@@ -194,7 +194,7 @@ order by ?s
194
194
 
195
195
  Solis::LOGGER.info(query) if ConfigFile[:debug]
196
196
 
197
- query_key = "#{@model.name}-#{Digest::MD5.hexdigest(query)}"
197
+ query_key = "#{@model.model_class_name}-#{Digest::MD5.hexdigest(query)}"
198
198
 
199
199
  result = nil
200
200
 
@@ -275,7 +275,7 @@ PREFIX #{@model.class.graph_prefix}: <#{@model.class.graph_name}>"
275
275
  attribute = statement.p.value.split('/').last.underscore
276
276
 
277
277
  unless solution_model.metadata[:attributes].key?(attribute)
278
- Solis::LOGGER.error "Attribute found in data that is not part of the model model #{solution_model.name}(#{record_uri.split('/').last}).#{attribute}"
278
+ Solis::LOGGER.error "Attribute found in data that is not part of the model model #{solution_model.model_class_name}(#{record_uri.split('/').last}).#{attribute}"
279
279
  next
280
280
  end
281
281
 
@@ -117,6 +117,7 @@ module Solis
117
117
  end
118
118
 
119
119
  entities.store(e['name'].to_sym, { description: e['description'],
120
+ order: e['order'],
120
121
  plural: e['nameplural'],
121
122
  label: e['name'].to_s.strip,
122
123
  sub_class_of: e['subclassof'].nil? || e['subclassof'].empty? ? [] : [e['subclassof']],
@@ -178,6 +179,7 @@ module Solis
178
179
  path: "#{graph_prefix}:#{property_name.to_s.classify}",
179
180
  cardinality: { min: min_max['min'], max: min_max['max'] },
180
181
  same_as: p['sameas'],
182
+ order: p['order'],
181
183
  description: p['description']
182
184
  }
183
185
 
@@ -308,7 +310,7 @@ hide empty members
308
310
  unless node.nil? || node.empty?
309
311
  "\n #{shacl_prefix}:node #{node} ;"
310
312
  end}
311
- #{shacl_prefix}:name "#{label}" ;
313
+ #{shacl_prefix}:name "#{label}" ;
312
314
  )
313
315
  metadata[:properties].each do |property, property_metadata|
314
316
  attribute = property.to_s.strip
@@ -319,28 +321,36 @@ hide empty members
319
321
  datatype = property_metadata[:datatype].strip
320
322
  min_count = property_metadata[:cardinality][:min].strip
321
323
  max_count = property_metadata[:cardinality][:max].strip
324
+ order = property_metadata.key?(:order) && property_metadata[:order] ? property_metadata[:order]&.strip : nil
322
325
 
323
326
  if datatype =~ /^#{graph_prefix}:/ || datatype =~ /^<#{graph_name}/
324
327
  out += %( #{shacl_prefix}:property [#{shacl_prefix}:path #{path} ;
325
328
  #{shacl_prefix}:name "#{attribute}" ;
326
- #{shacl_prefix}:description "#{description}" ;
329
+ #{shacl_prefix}:description "#{description}" ;#{order.nil? ? '' : "\n #{shacl_prefix}:order #{order} ;"}
327
330
  #{shacl_prefix}:nodeKind #{shacl_prefix}:IRI ;
328
331
  #{shacl_prefix}:class #{datatype} ;#{min_count =~ /\d+/ ? "\n #{shacl_prefix}:minCount #{min_count} ;" : ''}#{max_count =~ /\d+/ ? "\n #{shacl_prefix}:maxCount #{max_count} ;" : ''}
329
332
  ] ;
330
333
  )
331
334
  else
332
- if datatype.eql?('rdf:langString')
335
+ if datatype.eql?('rdf:langString') && max_count.eql?('1')
333
336
  out += %( #{shacl_prefix}:property [#{shacl_prefix}:path #{path} ;
334
337
  #{shacl_prefix}:name "#{attribute}";
335
- #{shacl_prefix}:description "#{description}" ;
338
+ #{shacl_prefix}:description "#{description}" ;#{order.nil? ? '' : "\n #{shacl_prefix}:order #{order} ;"}
336
339
  #{shacl_prefix}:uniqueLang true ;
337
340
  #{shacl_prefix}:datatype #{datatype} ;#{min_count =~ /\d+/ ? "\n #{shacl_prefix}:minCount #{min_count} ;" : ''}
338
341
  ] ;
342
+ )
343
+ elsif datatype.eql?('rdf:langString')
344
+ out += %( #{shacl_prefix}:property [#{shacl_prefix}:path #{path} ;
345
+ #{shacl_prefix}:name "#{attribute}";
346
+ #{shacl_prefix}:description "#{description}" ;#{order.nil? ? '' : "\n #{shacl_prefix}:order #{order} ;"}
347
+ #{shacl_prefix}:datatype #{datatype} ;#{min_count =~ /\d+/ ? "\n #{shacl_prefix}:minCount #{min_count} ;" : ''}#{max_count =~ /\d+/ ? "\n #{shacl_prefix}:maxCount #{max_count} ;" : ''}
348
+ ] ;
339
349
  )
340
350
  else
341
351
  out += %( #{shacl_prefix}:property [#{shacl_prefix}:path #{path} ;
342
352
  #{shacl_prefix}:name "#{attribute}";
343
- #{shacl_prefix}:description "#{description}" ;
353
+ #{shacl_prefix}:description "#{description}" ;#{order.nil? ? '' : "\n #{shacl_prefix}:order #{order} ;"}
344
354
  #{shacl_prefix}:datatype #{datatype} ;#{min_count =~ /\d+/ ? "\n #{shacl_prefix}:minCount #{min_count} ;" : ''}#{max_count =~ /\d+/ ? "\n #{shacl_prefix}:maxCount #{max_count} ;" : ''}
345
355
  ] ;
346
356
  )
data/lib/solis/shape.rb CHANGED
@@ -100,6 +100,10 @@ module Solis
100
100
  attribute_node = solution.attributeNode if solution.bound?(:attributeNode)
101
101
  attribute_class = solution.attributeClass if solution.bound?(:attributeClass)
102
102
  attribute_comment = solution.attributeComment if solution.bound?(:attributeComment)
103
+ attribute_order = solution.attributeOrder if solution.bound?(:attributeOrder)
104
+
105
+ attribute_max_count = 1 if solution.bound?(:attributeUniqueLang) && solution.attributeUniqueLang.value.eql?('true')
106
+
103
107
  # if solution.bound?(:attributeOr)
104
108
  # pp solution
105
109
  # end
@@ -117,6 +121,7 @@ module Solis
117
121
  datatype: lookup_datatype(attribute_datatype_rdf, attribute_node),
118
122
  mincount: attribute_min_count,
119
123
  maxcount: attribute_max_count,
124
+ order: attribute_order,
120
125
  node: attribute_node,
121
126
  node_kind: attribute_node_kind,
122
127
  class: attribute_class,
@@ -134,7 +139,7 @@ PREFIX rdfv: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
134
139
 
135
140
  SELECT ?targetClass ?targetNode ?comment ?className ?attributePath ?attributeName ?attributeDatatype
136
141
  ?attributeMinCount ?attributeMaxCount ?attributeOr ?attributeClass
137
- ?attributeNode ?attributeNodeKind ?attributeComment ?o
142
+ ?attributeNode ?attributeNodeKind ?attributeComment ?attributeOrder ?attributeUniqueLang ?o
138
143
  WHERE {
139
144
 
140
145
  ?s a sh:NodeShape;
@@ -153,6 +158,8 @@ WHERE {
153
158
  OPTIONAL{ ?attributes sh:nodeKind ?attributeNodeKind } .
154
159
  OPTIONAL{ ?attributes sh:node ?attributeNode } .
155
160
  OPTIONAL{ ?attributes sh:description ?attributeComment } .
161
+ OPTIONAL{ ?attributes sh:order ?attributeOrder } .
162
+ OPTIONAL{ ?attributes sh:uniqueLang ?attributeUniqueLang } .
156
163
  }.
157
164
  }
158
165
  )
@@ -171,6 +178,7 @@ WHERE {
171
178
  "datatype": "string",
172
179
  "mincount": 1,
173
180
  "maxcount": 1,
181
+ "order": nil,
174
182
  "node": nil,
175
183
  "node_kind": nil,
176
184
  "class": nil,
data/lib/solis/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Solis
2
- VERSION = "0.94.0"
2
+ VERSION = "0.96.0"
3
3
  end
data/solis.gemspec CHANGED
@@ -40,9 +40,9 @@ Gem::Specification.new do |spec|
40
40
  spec.add_runtime_dependency 'uuidtools', '~> 2.2.0'
41
41
  spec.add_runtime_dependency 'dry-struct', '~> 1.6'
42
42
  spec.add_runtime_dependency 'psych', '~> 5.1'
43
- spec.add_runtime_dependency 'csv'
44
- spec.add_runtime_dependency 'mutex_m'
45
- spec.add_runtime_dependency 'ostruct'
43
+ spec.add_runtime_dependency 'csv', '~> 3.2'
44
+ spec.add_runtime_dependency 'mutex_m', '~> 0.1'
45
+ spec.add_runtime_dependency 'ostruct', '~> 0.5'
46
46
  # spec.add_runtime_dependency 'rdf-edtf', '~> 1.1.2'
47
47
 
48
48
  spec.add_development_dependency 'rake', '~> 13.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.94.0
4
+ version: 0.96.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mehmet Celik
@@ -195,44 +195,44 @@ dependencies:
195
195
  name: csv
196
196
  requirement: !ruby/object:Gem::Requirement
197
197
  requirements:
198
- - - ">="
198
+ - - "~>"
199
199
  - !ruby/object:Gem::Version
200
- version: '0'
200
+ version: '3.2'
201
201
  type: :runtime
202
202
  prerelease: false
203
203
  version_requirements: !ruby/object:Gem::Requirement
204
204
  requirements:
205
- - - ">="
205
+ - - "~>"
206
206
  - !ruby/object:Gem::Version
207
- version: '0'
207
+ version: '3.2'
208
208
  - !ruby/object:Gem::Dependency
209
209
  name: mutex_m
210
210
  requirement: !ruby/object:Gem::Requirement
211
211
  requirements:
212
- - - ">="
212
+ - - "~>"
213
213
  - !ruby/object:Gem::Version
214
- version: '0'
214
+ version: '0.1'
215
215
  type: :runtime
216
216
  prerelease: false
217
217
  version_requirements: !ruby/object:Gem::Requirement
218
218
  requirements:
219
- - - ">="
219
+ - - "~>"
220
220
  - !ruby/object:Gem::Version
221
- version: '0'
221
+ version: '0.1'
222
222
  - !ruby/object:Gem::Dependency
223
223
  name: ostruct
224
224
  requirement: !ruby/object:Gem::Requirement
225
225
  requirements:
226
- - - ">="
226
+ - - "~>"
227
227
  - !ruby/object:Gem::Version
228
- version: '0'
228
+ version: '0.5'
229
229
  type: :runtime
230
230
  prerelease: false
231
231
  version_requirements: !ruby/object:Gem::Requirement
232
232
  requirements:
233
- - - ">="
233
+ - - "~>"
234
234
  - !ruby/object:Gem::Version
235
- version: '0'
235
+ version: '0.5'
236
236
  - !ruby/object:Gem::Dependency
237
237
  name: rake
238
238
  requirement: !ruby/object:Gem::Requirement
@@ -294,6 +294,7 @@ files:
294
294
  - lib/solis/error/query_error.rb
295
295
  - lib/solis/graph.rb
296
296
  - lib/solis/model.rb
297
+ - lib/solis/model.rb.ok
297
298
  - lib/solis/options.rb
298
299
  - lib/solis/query.rb
299
300
  - lib/solis/query/construct.rb
@@ -335,7 +336,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
335
336
  - !ruby/object:Gem::Version
336
337
  version: '0'
337
338
  requirements: []
338
- rubygems_version: 3.7.1
339
+ rubygems_version: 3.7.2
339
340
  specification_version: 4
340
341
  summary: Turn any SHACL file into an API, ORM, documentation, ...
341
342
  test_files: []