triple_easy 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3e69744d7c775236eef6219ea1b86441e679ef7401416d0cb30f2bd582dc6f8d
4
+ data.tar.gz: 194b96646a8cd9a4dab7741e69e245bdc184ce5843a30742c1adc9df0916e314
5
+ SHA512:
6
+ metadata.gz: 1a5afe35a7df1b6c383ce10eac0d72eeeec72654cb1d874c8636e6a7a005a2ecdaa6f751f5f0abdf6ada8a4ac76b9fc096c4ec4336c47feb25a9793308584449
7
+ data.tar.gz: 2864a99a69d1fa5648b38ee3f98eeaf37189312bd8de3c84e43065f2beb43db4b9076f8d9432866a84a8fbdc97026e8bf3abd7d82a00e4f08355cb14f85657de
data/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+ - Initial implementation of the `triplify` helper function.
12
+ - Automatic conversion of strings to `RDF::URI` or `RDF::Literal`.
13
+ - Smart datatype detection for `xsd:date`, `xsd:dateTime`, `xsd:float`, `xsd:integer`.
14
+ - Support for language-tagged literals (default: "en").
15
+ - Support for named graphs (quads) via the `context` parameter.
16
+ - Top-level `triplify` method and `TripleEasy.triplify` module method.
17
+
18
+ ### Changed
19
+ - Improved object type detection logic.
20
+
21
+ ## [0.1.0] - 2026-03-27
22
+
23
+ ### Added
24
+ - First public release of the gem.
data/Gemfile ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in apples-tests.gemspec
6
+ gemspec
7
+ ruby '~> 3.2'
8
+ gem 'linkeddata', '~> 3.2.0'
9
+ gem 'rake', '~> 13.0'
10
+ gem 'rdf-raptor', '~> 3.1.0'
11
+ gem 'require_all', '~> 3.0.0'
12
+ gem 'securerandom'
13
+ gem 'rdf-vocab', '~> 3.3'
14
+ gem 'erb_lint', '~> 0.9.0'
15
+ gem 'json-ld', '~> 3.3'
16
+ gem 'dotenv', '~> 3.1'
17
+ gem 'uri', '~> 1.0'
18
+
19
+
20
+
21
+ group :development, :test do
22
+ gem 'pry', '~> 0.15.2'
23
+ gem 'rubocop', '~> 1.72'
24
+ gem 'ruby-debug-ide'
25
+ gem 'rack-test', '~> 2.1'
26
+ gem 'rspec', '~> 3.13'
27
+ gem 'rspec-core', '~> 3.13'
28
+ gem 'rspec-openapi', '~> 0.18.4'
29
+ gem 'simplecov', '~> 0.22', require: false
30
+ gem 'vcr', '~> 6.3'
31
+ gem 'webmock', '~> 3.23'
32
+ end
33
+
data/Gemfile.lock ADDED
@@ -0,0 +1,556 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ triple_easy (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionpack (8.1.3)
10
+ actionview (= 8.1.3)
11
+ activesupport (= 8.1.3)
12
+ nokogiri (>= 1.8.5)
13
+ rack (>= 2.2.4)
14
+ rack-session (>= 1.0.1)
15
+ rack-test (>= 0.6.3)
16
+ rails-dom-testing (~> 2.2)
17
+ rails-html-sanitizer (~> 1.6)
18
+ useragent (~> 0.16)
19
+ actionview (8.1.3)
20
+ activesupport (= 8.1.3)
21
+ builder (~> 3.1)
22
+ erubi (~> 1.11)
23
+ rails-dom-testing (~> 2.2)
24
+ rails-html-sanitizer (~> 1.6)
25
+ activesupport (8.1.3)
26
+ base64
27
+ bigdecimal
28
+ concurrent-ruby (~> 1.0, >= 1.3.1)
29
+ connection_pool (>= 2.2.5)
30
+ drb
31
+ i18n (>= 1.6, < 2)
32
+ json
33
+ logger (>= 1.4.2)
34
+ minitest (>= 5.1)
35
+ securerandom (>= 0.3)
36
+ tzinfo (~> 2.0, >= 2.0.5)
37
+ uri (>= 0.13.1)
38
+ addressable (2.8.9)
39
+ public_suffix (>= 2.0.2, < 8.0)
40
+ ast (2.4.3)
41
+ base64 (0.3.0)
42
+ bcp47_spec (0.2.1)
43
+ better_html (2.2.0)
44
+ actionview (>= 7.0)
45
+ activesupport (>= 7.0)
46
+ ast (~> 2.0)
47
+ erubi (~> 1.4)
48
+ parser (>= 2.4)
49
+ smart_properties
50
+ bigdecimal (3.3.1)
51
+ builder (3.3.0)
52
+ coderay (1.1.3)
53
+ concurrent-ruby (1.3.6)
54
+ connection_pool (3.0.2)
55
+ crack (1.0.1)
56
+ bigdecimal
57
+ rexml
58
+ crass (1.0.6)
59
+ date (3.5.1)
60
+ diff-lcs (1.6.2)
61
+ docile (1.4.1)
62
+ dotenv (3.2.0)
63
+ drb (2.2.3)
64
+ ebnf (2.6.0)
65
+ base64 (~> 0.2)
66
+ htmlentities (~> 4.3)
67
+ rdf (~> 3.3)
68
+ scanf (~> 1.0)
69
+ sxp (~> 2.0)
70
+ unicode-types (~> 1.8)
71
+ erb_lint (0.9.0)
72
+ activesupport
73
+ better_html (>= 2.0.1)
74
+ parser (>= 2.7.1.4)
75
+ rainbow
76
+ rubocop (>= 1)
77
+ smart_properties
78
+ erubi (1.13.1)
79
+ ffi (1.17.4-aarch64-linux-gnu)
80
+ ffi (1.17.4-aarch64-linux-musl)
81
+ ffi (1.17.4-arm-linux-gnu)
82
+ ffi (1.17.4-arm-linux-musl)
83
+ ffi (1.17.4-arm64-darwin)
84
+ ffi (1.17.4-x86_64-darwin)
85
+ ffi (1.17.4-x86_64-linux-gnu)
86
+ ffi (1.17.4-x86_64-linux-musl)
87
+ haml (6.4.0)
88
+ temple (>= 0.8.2)
89
+ thor
90
+ tilt
91
+ hamster (3.0.0)
92
+ concurrent-ruby (~> 1.0)
93
+ hashdiff (1.2.1)
94
+ htmlentities (4.4.2)
95
+ i18n (1.14.8)
96
+ concurrent-ruby (~> 1.0)
97
+ io-console (0.8.2)
98
+ json (2.19.3)
99
+ json-canonicalization (1.0.0)
100
+ json-ld (3.3.2)
101
+ htmlentities (~> 4.3)
102
+ json-canonicalization (~> 1.0)
103
+ link_header (~> 0.0, >= 0.0.8)
104
+ multi_json (~> 1.15)
105
+ rack (>= 2.2, < 4)
106
+ rdf (~> 3.3)
107
+ rexml (~> 3.2)
108
+ json-ld-preloaded (3.3.2)
109
+ json-ld (~> 3.3)
110
+ rdf (~> 3.3)
111
+ language_server-protocol (3.17.0.5)
112
+ ld-patch (3.3.1)
113
+ ebnf (~> 2.6)
114
+ rdf (~> 3.3)
115
+ rdf-xsd (~> 3.3)
116
+ sparql (~> 3.3)
117
+ sxp (~> 2.0)
118
+ link_header (0.0.8)
119
+ linkeddata (3.2.2)
120
+ json-ld (~> 3.2, >= 3.2.5)
121
+ json-ld-preloaded (~> 3.2, >= 3.2.2)
122
+ ld-patch (~> 3.2, >= 3.2.2)
123
+ nokogiri (~> 1.13, >= 1.13.8)
124
+ rdf (~> 3.2, >= 3.2.1)
125
+ rdf-aggregate-repo (~> 3.2, >= 3.2.1)
126
+ rdf-hamster-repo (~> 3.2, >= 3.2.1)
127
+ rdf-isomorphic (~> 3.2, >= 3.2.1)
128
+ rdf-json (~> 3.2)
129
+ rdf-microdata (~> 3.2, >= 3.2.1)
130
+ rdf-n3 (~> 3.2, >= 3.2.1)
131
+ rdf-normalize (~> 0.6, >= 0.6.1)
132
+ rdf-ordered-repo (~> 3.2, >= 3.2.1)
133
+ rdf-rdfa (~> 3.2, >= 3.2.3)
134
+ rdf-rdfxml (~> 3.2, >= 3.2.2)
135
+ rdf-reasoner (~> 0.8)
136
+ rdf-tabular (~> 3.2, >= 3.2.1)
137
+ rdf-trig (~> 3.2)
138
+ rdf-trix (~> 3.2)
139
+ rdf-turtle (~> 3.2, >= 3.2.1)
140
+ rdf-vocab (~> 3.2, >= 3.2.7)
141
+ rdf-xsd (~> 3.2, >= 3.2.1)
142
+ shacl (~> 0.3)
143
+ shex (~> 0.7, >= 0.7.1)
144
+ sparql (~> 3.2, >= 3.2.6)
145
+ sparql-client (~> 3.2, >= 3.2.2)
146
+ yaml-ld (~> 0.0)
147
+ lint_roller (1.1.0)
148
+ logger (1.7.0)
149
+ loofah (2.25.1)
150
+ crass (~> 1.0.2)
151
+ nokogiri (>= 1.12.0)
152
+ matrix (0.4.3)
153
+ method_source (1.1.0)
154
+ minitest (6.0.2)
155
+ drb (~> 2.0)
156
+ prism (~> 1.5)
157
+ multi_json (1.19.1)
158
+ net-http-persistent (4.0.8)
159
+ connection_pool (>= 2.2.4, < 4)
160
+ nokogiri (1.19.2-aarch64-linux-gnu)
161
+ racc (~> 1.4)
162
+ nokogiri (1.19.2-aarch64-linux-musl)
163
+ racc (~> 1.4)
164
+ nokogiri (1.19.2-arm-linux-gnu)
165
+ racc (~> 1.4)
166
+ nokogiri (1.19.2-arm-linux-musl)
167
+ racc (~> 1.4)
168
+ nokogiri (1.19.2-arm64-darwin)
169
+ racc (~> 1.4)
170
+ nokogiri (1.19.2-x86_64-darwin)
171
+ racc (~> 1.4)
172
+ nokogiri (1.19.2-x86_64-linux-gnu)
173
+ racc (~> 1.4)
174
+ nokogiri (1.19.2-x86_64-linux-musl)
175
+ racc (~> 1.4)
176
+ ostruct (0.6.3)
177
+ parallel (1.27.0)
178
+ parser (3.3.11.1)
179
+ ast (~> 2.4.1)
180
+ racc
181
+ prism (1.9.0)
182
+ pry (0.15.2)
183
+ coderay (~> 1.1)
184
+ method_source (~> 1.0)
185
+ psych (5.3.1)
186
+ date
187
+ stringio
188
+ public_suffix (7.0.5)
189
+ racc (1.8.1)
190
+ rack (3.2.5)
191
+ rack-session (2.1.1)
192
+ base64 (>= 0.1.0)
193
+ rack (>= 3.0.0)
194
+ rack-test (2.2.0)
195
+ rack (>= 1.3)
196
+ rails-dom-testing (2.3.0)
197
+ activesupport (>= 5.0.0)
198
+ minitest
199
+ nokogiri (>= 1.6)
200
+ rails-html-sanitizer (1.7.0)
201
+ loofah (~> 2.25)
202
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
203
+ rainbow (3.1.1)
204
+ rake (13.3.1)
205
+ rdf (3.3.4)
206
+ bcp47_spec (~> 0.2)
207
+ bigdecimal (~> 3.1, >= 3.1.5)
208
+ link_header (~> 0.0, >= 0.0.8)
209
+ logger (~> 1.5)
210
+ ostruct (~> 0.6)
211
+ readline (~> 0.0)
212
+ rdf-aggregate-repo (3.3.0)
213
+ rdf (~> 3.3)
214
+ rdf-hamster-repo (3.3.0)
215
+ hamster (~> 3.0)
216
+ rdf (~> 3.3)
217
+ rdf-isomorphic (3.3.0)
218
+ rdf (~> 3.3)
219
+ rdf-json (3.3.0)
220
+ rdf (~> 3.3)
221
+ rdf-microdata (3.3.0)
222
+ htmlentities (~> 4.3)
223
+ nokogiri (~> 1.15, >= 1.15.4)
224
+ rdf (~> 3.3)
225
+ rdf-rdfa (~> 3.3)
226
+ rdf-xsd (~> 3.3)
227
+ rdf-n3 (3.3.1)
228
+ ebnf (~> 2.5)
229
+ rdf (~> 3.3)
230
+ sparql (~> 3.3)
231
+ sxp (~> 2.0)
232
+ rdf-normalize (0.7.0)
233
+ rdf (~> 3.3)
234
+ rdf-ordered-repo (3.3.0)
235
+ rdf (~> 3.3)
236
+ rdf-raptor (3.1.0)
237
+ ffi (~> 1.11)
238
+ rdf (~> 3.1)
239
+ rdf-rdfa (3.3.0)
240
+ haml (~> 6.1)
241
+ htmlentities (~> 4.3)
242
+ rdf (~> 3.3)
243
+ rdf-aggregate-repo (~> 3.3)
244
+ rdf-vocab (~> 3.3)
245
+ rdf-xsd (~> 3.3)
246
+ rdf-rdfxml (3.3.0)
247
+ builder (~> 3.2, >= 3.2.4)
248
+ htmlentities (~> 4.3)
249
+ rdf (~> 3.3)
250
+ rdf-xsd (~> 3.3)
251
+ rdf-reasoner (0.9.0)
252
+ rdf (~> 3.3)
253
+ rdf-xsd (~> 3.3)
254
+ rdf-tabular (3.3.0)
255
+ addressable (~> 2.8)
256
+ bcp47_spec (~> 0.2)
257
+ json-ld (~> 3.3)
258
+ rdf (~> 3.3)
259
+ rdf-vocab (~> 3.3)
260
+ rdf-xsd (~> 3.3)
261
+ rdf-trig (3.3.0)
262
+ ebnf (~> 2.4)
263
+ rdf (~> 3.3)
264
+ rdf-turtle (~> 3.3)
265
+ rdf-trix (3.3.0)
266
+ rdf (~> 3.3)
267
+ rdf-xsd (~> 3.3)
268
+ rdf-turtle (3.3.1)
269
+ base64 (~> 0.2)
270
+ bigdecimal (~> 3.1, >= 3.1.5)
271
+ ebnf (~> 2.5)
272
+ rdf (~> 3.3)
273
+ rdf-vocab (3.3.3)
274
+ rdf (~> 3.3)
275
+ rdf-xsd (3.3.0)
276
+ rdf (~> 3.3)
277
+ rexml (~> 3.2)
278
+ readline (0.0.4)
279
+ reline
280
+ regexp_parser (2.11.3)
281
+ reline (0.6.3)
282
+ io-console (~> 0.5)
283
+ require_all (3.0.0)
284
+ rexml (3.4.4)
285
+ rspec (3.13.2)
286
+ rspec-core (~> 3.13.0)
287
+ rspec-expectations (~> 3.13.0)
288
+ rspec-mocks (~> 3.13.0)
289
+ rspec-core (3.13.6)
290
+ rspec-support (~> 3.13.0)
291
+ rspec-expectations (3.13.5)
292
+ diff-lcs (>= 1.2.0, < 2.0)
293
+ rspec-support (~> 3.13.0)
294
+ rspec-mocks (3.13.8)
295
+ diff-lcs (>= 1.2.0, < 2.0)
296
+ rspec-support (~> 3.13.0)
297
+ rspec-openapi (0.18.4)
298
+ actionpack (>= 5.2.0)
299
+ rails-dom-testing
300
+ rspec-core
301
+ rspec-support (3.13.7)
302
+ rubocop (1.86.0)
303
+ json (~> 2.3)
304
+ language_server-protocol (~> 3.17.0.2)
305
+ lint_roller (~> 1.1.0)
306
+ parallel (~> 1.10)
307
+ parser (>= 3.3.0.2)
308
+ rainbow (>= 2.2.2, < 4.0)
309
+ regexp_parser (>= 2.9.3, < 3.0)
310
+ rubocop-ast (>= 1.49.0, < 2.0)
311
+ ruby-progressbar (~> 1.7)
312
+ unicode-display_width (>= 2.4.0, < 4.0)
313
+ rubocop-ast (1.49.1)
314
+ parser (>= 3.3.7.2)
315
+ prism (~> 1.7)
316
+ ruby-debug-ide (0.7.5)
317
+ rake (>= 0.8.1)
318
+ ruby-progressbar (1.13.0)
319
+ scanf (1.0.0)
320
+ securerandom (0.4.1)
321
+ shacl (0.4.3)
322
+ json-ld (~> 3.3)
323
+ rdf (~> 3.3)
324
+ sparql (~> 3.3)
325
+ sxp (~> 2.0)
326
+ shex (0.8.1)
327
+ ebnf (~> 2.5)
328
+ htmlentities (~> 4.3)
329
+ json-ld (~> 3.3)
330
+ json-ld-preloaded (~> 3.3)
331
+ rdf (~> 3.3)
332
+ rdf-xsd (~> 3.3)
333
+ sparql (~> 3.3)
334
+ sxp (~> 2.0)
335
+ simplecov (0.22.0)
336
+ docile (~> 1.1)
337
+ simplecov-html (~> 0.11)
338
+ simplecov_json_formatter (~> 0.1)
339
+ simplecov-html (0.13.2)
340
+ simplecov_json_formatter (0.1.4)
341
+ smart_properties (1.17.0)
342
+ sparql (3.3.2)
343
+ builder (~> 3.2, >= 3.2.4)
344
+ ebnf (~> 2.5)
345
+ logger (~> 1.5)
346
+ rdf (~> 3.3)
347
+ rdf-aggregate-repo (~> 3.3)
348
+ rdf-xsd (~> 3.3)
349
+ readline (~> 0.0)
350
+ sparql-client (~> 3.3)
351
+ sxp (~> 2.0)
352
+ sparql-client (3.3.0)
353
+ net-http-persistent (~> 4.0, >= 4.0.2)
354
+ rdf (~> 3.3)
355
+ stringio (3.2.0)
356
+ sxp (2.0.0)
357
+ matrix (~> 0.4)
358
+ rdf (~> 3.3)
359
+ temple (0.10.4)
360
+ thor (1.5.0)
361
+ tilt (2.7.0)
362
+ tzinfo (2.0.6)
363
+ concurrent-ruby (~> 1.0)
364
+ unicode-display_width (3.2.0)
365
+ unicode-emoji (~> 4.1)
366
+ unicode-emoji (4.2.0)
367
+ unicode-types (1.11.0)
368
+ uri (1.1.1)
369
+ useragent (0.16.11)
370
+ vcr (6.4.0)
371
+ webmock (3.26.2)
372
+ addressable (>= 2.8.0)
373
+ crack (>= 0.3.2)
374
+ hashdiff (>= 0.4.0, < 2.0.0)
375
+ yaml-ld (0.0.3)
376
+ json-ld (~> 3.3)
377
+ psych (>= 3.3)
378
+ rdf (~> 3.3)
379
+ rdf-xsd (~> 3.3)
380
+
381
+ PLATFORMS
382
+ aarch64-linux-gnu
383
+ aarch64-linux-musl
384
+ arm-linux-gnu
385
+ arm-linux-musl
386
+ arm64-darwin
387
+ x86_64-darwin
388
+ x86_64-linux-gnu
389
+ x86_64-linux-musl
390
+
391
+ DEPENDENCIES
392
+ dotenv (~> 3.1)
393
+ erb_lint (~> 0.9.0)
394
+ json-ld (~> 3.3)
395
+ linkeddata (~> 3.2.0)
396
+ pry (~> 0.15.2)
397
+ rack-test (~> 2.1)
398
+ rake (~> 13.0)
399
+ rdf (~> 3.0)
400
+ rdf-raptor (~> 3.1.0)
401
+ rdf-vocab (~> 3.3)
402
+ require_all (~> 3.0.0)
403
+ rspec (~> 3.13)
404
+ rspec-core (~> 3.13)
405
+ rspec-openapi (~> 0.18.4)
406
+ rubocop (~> 1.72)
407
+ ruby-debug-ide
408
+ securerandom
409
+ simplecov (~> 0.22)
410
+ triple_easy!
411
+ uri (~> 1.0)
412
+ vcr (~> 6.3)
413
+ webmock (~> 3.23)
414
+
415
+ CHECKSUMS
416
+ actionpack (8.1.3) sha256=af998cae4d47c5d581a2cc363b5c77eb718b7c4b45748d81b1887b25621c29a3
417
+ actionview (8.1.3) sha256=1347c88c7f3edb38100c5ce0e9fb5e62d7755f3edc1b61cce2eb0b2c6ea2fd5d
418
+ activesupport (8.1.3) sha256=21a5e0dfbd4c3ddd9e1317ec6a4d782fa226e7867dc70b0743acda81a1dca20e
419
+ addressable (2.8.9) sha256=cc154fcbe689711808a43601dee7b980238ce54368d23e127421753e46895485
420
+ ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
421
+ base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
422
+ bcp47_spec (0.2.1) sha256=3fd62edf96c126bd9624e4319ac74082a966081859d1ee0ef3c3041640a37810
423
+ better_html (2.2.0) sha256=e68ab66ab09696b708333bbf35e8aa3c107500ba7892f528e2111624bdd8cf76
424
+ bigdecimal (3.3.1) sha256=eaa01e228be54c4f9f53bf3cc34fe3d5e845c31963e7fcc5bedb05a4e7d52218
425
+ builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f
426
+ coderay (1.1.3) sha256=dc530018a4684512f8f38143cd2a096c9f02a1fc2459edcfe534787a7fc77d4b
427
+ concurrent-ruby (1.3.6) sha256=6b56837e1e7e5292f9864f34b69c5a2cbc75c0cf5338f1ce9903d10fa762d5ab
428
+ connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
429
+ crack (1.0.1) sha256=ff4a10390cd31d66440b7524eb1841874db86201d5b70032028553130b6d4c7e
430
+ crass (1.0.6) sha256=dc516022a56e7b3b156099abc81b6d2b08ea1ed12676ac7a5657617f012bd45d
431
+ date (3.5.1) sha256=750d06384d7b9c15d562c76291407d89e368dda4d4fff957eb94962d325a0dc0
432
+ diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
433
+ docile (1.4.1) sha256=96159be799bfa73cdb721b840e9802126e4e03dfc26863db73647204c727f21e
434
+ dotenv (3.2.0) sha256=e375b83121ea7ca4ce20f214740076129ab8514cd81378161f11c03853fe619d
435
+ drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
436
+ ebnf (2.6.0) sha256=e746a316caa885cc45e243dc33efc194943956760bc9bc13948de1732fbcf63e
437
+ erb_lint (0.9.0) sha256=dfb5e40ad839e8d1f0d56ca85ec9a7ac4c9cd966ec281138282f35b323ca7c31
438
+ erubi (1.13.1) sha256=a082103b0885dbc5ecf1172fede897f9ebdb745a4b97a5e8dc63953db1ee4ad9
439
+ ffi (1.17.4-aarch64-linux-gnu) sha256=b208f06f91ffd8f5e1193da3cae3d2ccfc27fc36fba577baf698d26d91c080df
440
+ ffi (1.17.4-aarch64-linux-musl) sha256=9286b7a615f2676245283aef0a0a3b475ae3aae2bb5448baace630bb77b91f39
441
+ ffi (1.17.4-arm-linux-gnu) sha256=d6dbddf7cb77bf955411af5f187a65b8cd378cb003c15c05697f5feee1cb1564
442
+ ffi (1.17.4-arm-linux-musl) sha256=9d4838ded0465bef6e2426935f6bcc93134b6616785a84ffd2a3d82bc3cf6f95
443
+ ffi (1.17.4-arm64-darwin) sha256=19071aaf1419251b0a46852abf960e77330a3b334d13a4ab51d58b31a937001b
444
+ ffi (1.17.4-x86_64-darwin) sha256=aa70390523cf3235096cf64962b709b4cfbd5c082a2cb2ae714eb0fe2ccda496
445
+ ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d
446
+ ffi (1.17.4-x86_64-linux-musl) sha256=3fdf9888483de005f8ef8d1cf2d3b20d86626af206cbf780f6a6a12439a9c49e
447
+ haml (6.4.0) sha256=b2e20652be52ac9a3be328e8ff411ad007e82fc4e78e1a5cdefad537a697cf6a
448
+ hamster (3.0.0) sha256=5951e3a3ffd15ba854a976ac36ebae9469966f726034ffed0dccdb6d12d434d8
449
+ hashdiff (1.2.1) sha256=9c079dbc513dfc8833ab59c0c2d8f230fa28499cc5efb4b8dd276cf931457cd1
450
+ htmlentities (4.4.2) sha256=bbafbdf69f2eca9262be4efef7e43e6a1de54c95eb600f26984f71d2fe96c5c3
451
+ i18n (1.14.8) sha256=285778639134865c5e0f6269e0b818256017e8cde89993fdfcbfb64d088824a5
452
+ io-console (0.8.2) sha256=d6e3ae7a7cc7574f4b8893b4fca2162e57a825b223a177b7afa236c5ef9814cc
453
+ json (2.19.3) sha256=289b0bb53052a1fa8c34ab33cc750b659ba14a5c45f3fcf4b18762dc67c78646
454
+ json-canonicalization (1.0.0) sha256=d4848a8cca7534455c6721f2d9fc9e5e9adca49486864a898810024f67d59446
455
+ json-ld (3.3.2) sha256=b9531893bf5bdc01db428e96953845a23adb1097125ce918ae0f97c4a6e1ab27
456
+ json-ld-preloaded (3.3.2) sha256=46294327eaf3bf95d48877222a70dd79740917adff94d5f0d380a4c492131ee1
457
+ language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
458
+ ld-patch (3.3.1) sha256=e663fca96ef2b7cbe25d2b5fe257d17984d28b64cb475d50943eebbb5c05dc51
459
+ link_header (0.0.8) sha256=15c65ce43b29f739b30d05e5f25c22c23797e89cf6f905dbb595fb4c70cb55f9
460
+ linkeddata (3.2.2) sha256=c5e02d6fd08c59dbe035705087a7cba757841df0e093b036d797a49202401bd1
461
+ lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
462
+ logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
463
+ loofah (2.25.1) sha256=d436c73dbd0c1147b16c4a41db097942d217303e1f7728704b37e4df9f6d2e04
464
+ matrix (0.4.3) sha256=a0d5ab7ddcc1973ff690ab361b67f359acbb16958d1dc072b8b956a286564c5b
465
+ method_source (1.1.0) sha256=181301c9c45b731b4769bc81e8860e72f9161ad7d66dd99103c9ab84f560f5c5
466
+ minitest (6.0.2) sha256=db6e57956f6ecc6134683b4c87467d6dd792323c7f0eea7b93f66bd284adbc3d
467
+ multi_json (1.19.1) sha256=7aefeff8f2c854bf739931a238e4aea64592845e0c0395c8a7d2eea7fdd631b7
468
+ net-http-persistent (4.0.8) sha256=ef3de8319d691537b329053fae3a33195f8b070bbbfae8bf1a58c796081960e6
469
+ nokogiri (1.19.2-aarch64-linux-gnu) sha256=c34d5c8208025587554608e98fd88ab125b29c80f9352b821964e9a5d5cfbd19
470
+ nokogiri (1.19.2-aarch64-linux-musl) sha256=7f6b4b0202d507326841a4f790294bf75098aef50c7173443812e3ac5cb06515
471
+ nokogiri (1.19.2-arm-linux-gnu) sha256=b7fa1139016f3dc850bda1260988f0d749934a939d04ef2da13bec060d7d5081
472
+ nokogiri (1.19.2-arm-linux-musl) sha256=61114d44f6742ff72194a1b3020967201e2eb982814778d130f6471c11f9828c
473
+ nokogiri (1.19.2-arm64-darwin) sha256=58d8ea2e31a967b843b70487a44c14c8ba1866daa1b9da9be9dbdf1b43dee205
474
+ nokogiri (1.19.2-x86_64-darwin) sha256=7d9af11fda72dfaa2961d8c4d5380ca0b51bc389dc5f8d4b859b9644f195e7a4
475
+ nokogiri (1.19.2-x86_64-linux-gnu) sha256=fa8feca882b73e871a9845f3817a72e9734c8e974bdc4fbad6e4bc6e8076b94f
476
+ nokogiri (1.19.2-x86_64-linux-musl) sha256=93128448e61a9383a30baef041bf1f5817e22f297a1d400521e90294445069a8
477
+ ostruct (0.6.3) sha256=95a2ed4a4bd1d190784e666b47b2d3f078e4a9efda2fccf18f84ddc6538ed912
478
+ parallel (1.27.0) sha256=4ac151e1806b755fb4e2dc2332cbf0e54f2e24ba821ff2d3dcf86bf6dc4ae130
479
+ parser (3.3.11.1) sha256=d17ace7aabe3e72c3cc94043714be27cc6f852f104d81aa284c2281aecc65d54
480
+ prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
481
+ pry (0.15.2) sha256=12d54b8640d3fa29c9211dd4ffb08f3fd8bf7a4fd9b5a73ce5b59c8709385b6b
482
+ psych (5.3.1) sha256=eb7a57cef10c9d70173ff74e739d843ac3b2c019a003de48447b2963d81b1974
483
+ public_suffix (7.0.5) sha256=1a8bb08f1bbea19228d3bed6e5ed908d1cb4f7c2726d18bd9cadf60bc676f623
484
+ racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
485
+ rack (3.2.5) sha256=4cbd0974c0b79f7a139b4812004a62e4c60b145cba76422e288ee670601ed6d3
486
+ rack-session (2.1.1) sha256=0b6dc07dea7e4b583f58a48e8b806d4c9f1c6c9214ebc202ec94562cbea2e4e9
487
+ rack-test (2.2.0) sha256=005a36692c306ac0b4a9350355ee080fd09ddef1148a5f8b2ac636c720f5c463
488
+ rails-dom-testing (2.3.0) sha256=8acc7953a7b911ca44588bf08737bc16719f431a1cc3091a292bca7317925c1d
489
+ rails-html-sanitizer (1.7.0) sha256=28b145cceaf9cc214a9874feaa183c3acba036c9592b19886e0e45efc62b1e89
490
+ rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
491
+ rake (13.3.1) sha256=8c9e89d09f66a26a01264e7e3480ec0607f0c497a861ef16063604b1b08eb19c
492
+ rdf (3.3.4) sha256=a77fa0821e5b4e2bea9fdbb7c9d980564c89d27e81979690ce5c9e6bc80859c1
493
+ rdf-aggregate-repo (3.3.0) sha256=5693ccabf4dbbec7113c95e9aab028311f19d6022764fdebc6327f9d55a9efdc
494
+ rdf-hamster-repo (3.3.0) sha256=8a57d321d0c8bfb1eac7c47fd5b569e9c5fb7bb92bf9b78c102d58125dd1099a
495
+ rdf-isomorphic (3.3.0) sha256=1247bbd372f4d10d4fa13a40a23a44867bcb0fa4f7a01927191ea3cadad0af2c
496
+ rdf-json (3.3.0) sha256=80050bb97ec06108fc53d7ada777bceec06196ca7f0642ceeaf38b20a9b0addd
497
+ rdf-microdata (3.3.0) sha256=daaaf3f947ecce1c3e94aa5fed5f5c38ebea4070670d4e9600c156c631c25c3e
498
+ rdf-n3 (3.3.1) sha256=3030d185823422ee3249a826aa5b8c96281b4728a36f2061fb8b4f070c738f73
499
+ rdf-normalize (0.7.0) sha256=92374497dddb61c2910b50bfc12bb0ace33dcf23c8edbd0e0f78fd4acf839ebe
500
+ rdf-ordered-repo (3.3.0) sha256=551b7f22f258e807f329f0071625ed1c22fc3b29080078a1f678be6c2749f93a
501
+ rdf-raptor (3.1.0) sha256=938fa97b5d44b8c7189d1a035b7cbe77399f381481ee9bff88288737dd6f956e
502
+ rdf-rdfa (3.3.0) sha256=5770deb6da628b04b22a097269919897a0092c44250bbf5f22be4fabdc5ef71b
503
+ rdf-rdfxml (3.3.0) sha256=11647f6111b97b6a9b82413bd9810d4bb5524aa7dd06b3c1330bf58ec3aa6a9a
504
+ rdf-reasoner (0.9.0) sha256=227cca0008ed2e99b0a27e05f919af14b2516dfcac5544f159e10cacc69c1a2b
505
+ rdf-tabular (3.3.0) sha256=560fe8248687a6142267f437f1c98df8fb427e47f91c9a7cd430ab5f461b4d23
506
+ rdf-trig (3.3.0) sha256=3a22bc433f1042ff655c7dbbf95a69a4d85fbc3df386d7e7e52d834a18166c3f
507
+ rdf-trix (3.3.0) sha256=9817b4165bcb8d6ebb5acd9f3c495e93fdd455ab488071d50bbce5c7a61f8f4b
508
+ rdf-turtle (3.3.1) sha256=baf3be89977a2e7abb4f9a088f24918ca6223dcfa1483979991ab7996da73647
509
+ rdf-vocab (3.3.3) sha256=d3b642edb37be7b37b73cafa9e01d55762f99292838e7b0868a3575bd297bf8b
510
+ rdf-xsd (3.3.0) sha256=fab51d27b20344237d9b622ef32e83e4c44940840bfc76a245ce6b6abba44772
511
+ readline (0.0.4) sha256=6138eef17be2b98298b672c3ea63bf9cb5158d401324f26e1e84f235879c1d6a
512
+ regexp_parser (2.11.3) sha256=ca13f381a173b7a93450e53459075c9b76a10433caadcb2f1180f2c741fc55a4
513
+ reline (0.6.3) sha256=1198b04973565b36ec0f11542ab3f5cfeeec34823f4e54cebde90968092b1835
514
+ require_all (3.0.0) sha256=937853faa2833388eab551107bf7bf87c6bba6b4800bac5ce469eda7b6a9fed0
515
+ rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142
516
+ rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
517
+ rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
518
+ rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
519
+ rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47
520
+ rspec-openapi (0.18.4) sha256=4c6107f8bc16d4ed656bb35b5ec7994f5df5b8fccc78248bee6611eb90702ee6
521
+ rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
522
+ rubocop (1.86.0) sha256=4ff1186fe16ebe9baff5e7aad66bb0ad4cabf5cdcd419f773146dbba2565d186
523
+ rubocop-ast (1.49.1) sha256=4412f3ee70f6fe4546cc489548e0f6fcf76cafcfa80fa03af67098ffed755035
524
+ ruby-debug-ide (0.7.5) sha256=5ec9b2d78e9aa106d23e29e4fdfeb9dc687a279bd25de060c6343aa135314488
525
+ ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
526
+ scanf (1.0.0) sha256=533db7f7e5acafea1a145d6c5329cef667a58fbcb7d64379a808ff1199ee1b00
527
+ securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
528
+ shacl (0.4.3) sha256=5e907d384d9883edf96264866de788e3340976579944bc8e01e61b76189a7fb8
529
+ shex (0.8.1) sha256=d07c0043302f9eed5f9f5af81e9786be74dde5e3065ea7932790f33253bfced6
530
+ simplecov (0.22.0) sha256=fe2622c7834ff23b98066bb0a854284b2729a569ac659f82621fc22ef36213a5
531
+ simplecov-html (0.13.2) sha256=bd0b8e54e7c2d7685927e8d6286466359b6f16b18cb0df47b508e8d73c777246
532
+ simplecov_json_formatter (0.1.4) sha256=529418fbe8de1713ac2b2d612aa3daa56d316975d307244399fa4838c601b428
533
+ smart_properties (1.17.0) sha256=f9323f8122e932341756ddec8e0ac9ec6e238408a7661508be99439ca6d6384b
534
+ sparql (3.3.2) sha256=20d73a62801fd6d03c834ca5012c11aaf6594ef536f554e92fd94bf9b3ed64dc
535
+ sparql-client (3.3.0) sha256=71225eefad48dc2baab6b7008df8a9bcfffa833e5f25387dbe87ff52a5cad64e
536
+ stringio (3.2.0) sha256=c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1
537
+ sxp (2.0.0) sha256=79971bbab54a82fe4a861332475eb8c1f33142d70f2b7e830dacbd9082824721
538
+ temple (0.10.4) sha256=b7a1e94b6f09038ab0b6e4fe0126996055da2c38bec53a8a336f075748fff72c
539
+ thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73
540
+ tilt (2.7.0) sha256=0d5b9ba69f6a36490c64b0eee9f6e9aad517e20dcc848800a06eb116f08c6ab3
541
+ triple_easy (0.1.0)
542
+ tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
543
+ unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
544
+ unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f
545
+ unicode-types (1.11.0) sha256=81d1201273260fa89b85471e7eebb93a51bb4e5f078a525508dcae7835d176f9
546
+ uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6
547
+ useragent (0.16.11) sha256=700e6413ad4bb954bb63547fa098dddf7b0ebe75b40cc6f93b8d54255b173844
548
+ vcr (6.4.0) sha256=077ac92cc16efc5904eb90492a18153b5e6ca5398046d8a249a7c96a9ea24ae6
549
+ webmock (3.26.2) sha256=774556f2ea6371846cca68c01769b2eac0d134492d21f6d0ab5dd643965a4c90
550
+ yaml-ld (0.0.3) sha256=2934e06ef651337bf4c5d78e6a22007e0c46f1215c19dc024816c1fa82b971d1
551
+
552
+ RUBY VERSION
553
+ ruby 3.2.4
554
+
555
+ BUNDLED WITH
556
+ 4.0.9
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mark Wilkinson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # TripleEasy
2
+
3
+ **Make RDF triples (and quads) easily.**
4
+
5
+ `triple_easy` is a lightweight Ruby gem that provides a single convenient top-level function `triplify` to insert RDF statements into any `RDF::Repository` (or other mutable RDF store). It automatically converts plain strings into proper `RDF::URI` or `RDF::Literal` objects with sensible datatype guessing.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'triple_easy'
13
+ ```
14
+
15
+ ## why "easy"?
16
+
17
+ - You can pass URI strings or RDF::Resource objects as S/P/O and it does the most obvious thing.
18
+ - In the Object position, for non-URI strings, it does some regexp matching to guess what Literal datatype it should be, and auto-creates that RDF Literal
19
+ - If you, for example, explicitly want "http://example.org" in the Object position to be a Literal (string), then you can override the auto-detect (this is useful when facing a dct:identifier property, where the range is a string, even if the string is a URI!)
20
+
21
+ ## Examples of usage:
22
+
23
+ ```
24
+ require 'triple_easy'
25
+
26
+ repo = RDF::Repository.new
27
+
28
+ # Basic triple
29
+ triplify("http://example.org/alice",
30
+ "http://xmlns.com/foaf/0.1/name",
31
+ "Alice Smith", # string will default to language "en"
32
+ repo)
33
+
34
+ # With language tag (non-English)
35
+ triplify("http://example.org/bob",
36
+ "http://xmlns.com/foaf/0.1/name",
37
+ "Bob Schmidt",
38
+ repo,
39
+ language: "de")
40
+
41
+ # With explicit datatype
42
+ triplify("http://example.org/charlie",
43
+ "http://schema.org/age",
44
+ "42",
45
+ repo,
46
+ datatype: RDF::XSD.integer)
47
+
48
+ # Date and DateTime auto-detection
49
+ triplify("http://example.org/diana",
50
+ "http://schema.org/birthDate",
51
+ "1995-06-15", # → xsd:date
52
+ repo)
53
+
54
+ triplify("http://example.org/diana",
55
+ "http://schema.org/lastSeen",
56
+ "2025-03-27T14:30:00", # → xsd:dateTime
57
+ repo)
58
+
59
+ # Quad (with named graph / context)
60
+ triplify("http://example.org/eve",
61
+ "http://xmlns.com/foaf/0.1/knows",
62
+ "http://example.org/alice",
63
+ repo,
64
+ context: "http://example.org/my-graph")
65
+
66
+ ```
67
+
68
+ ## Features
69
+
70
+ - Automatic URI detection for subjects, predicates, and objects
71
+ - Smart literal detection:
72
+ - xsd:date and xsd:dateTime
73
+ - xsd:float and xsd:integer
74
+ - Language-tagged strings (default: English)
75
+ - Optional explicit datatype (takes precedence)
76
+ - Support for named graphs (context)
77
+ - Returns true on success, false if any required argument is empty
78
+ - Raises helpful errors for invalid URIs
79
+
80
+ Full API documentation is available on rubydoc.info.
81
+
82
+ ## Development
83
+ After checking out the repo, run bin/setup to install dependencies. Then, run bundle exec rspec to run the tests.
84
+
85
+ ## Contributing
86
+ Bug reports and pull requests are welcome on GitHub at https://github.com/markwilkinson/triple-easy.
87
+
88
+ ## License
89
+ The gem is available as open source under the terms of the MIT License.
@@ -0,0 +1,3 @@
1
+ module TripleEasy
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,135 @@
1
+ require 'triple_easy/version'
2
+
3
+ module TripleEasy
4
+ # Easy way to add RDF triples (or quads) to an RDF repository.
5
+ #
6
+ # This helper automatically converts strings into proper {RDF::URI} or
7
+ # {RDF::Literal} objects with sensible datatype guessing (including
8
+ # xsd:date and xsd:dateTime). It also supports language-tagged strings.
9
+ #
10
+ # NOTE: you are responsible for sending the right kind of graphy-like object!
11
+ # If you send a RDF::Graph, this is fine, but you CANNOT send context nodes.
12
+ # If you want to use named graphs, you must send an RDF::Repository.
13
+ # The code does not control for this, so... you have been warned!
14
+ #
15
+ # @example Basic usage (top-level)
16
+ # require 'triple_easy'
17
+ #
18
+ # repo = RDF::Repository.new
19
+ #
20
+ # triplify("http://example.org/alice",
21
+ # "http://xmlns.com/foaf/0.1/name",
22
+ # "Alice Smith",
23
+ # repo)
24
+ #
25
+ # @example With datatype, language, and named graph (quad)
26
+ # triplify("http://example.org/bob",
27
+ # "http://xmlns.com/foaf/0.1/name",
28
+ # "Bob Schmidt",
29
+ # repo,
30
+ # language: "de") # German label
31
+ #
32
+ # triplify("http://example.org/bob",
33
+ # "http://schema.org/birthDate",
34
+ # "1990-05-15",
35
+ # repo) # auto-detects xsd:date
36
+ #
37
+ # triplify("http://example.org/bob",
38
+ # "http://schema.org/lastLogin",
39
+ # "2025-03-27T09:15:00",
40
+ # repo) # auto-detects xsd:dateTime
41
+ #
42
+ # @param s [String, RDF::URI, RDF::Node] Subject – usually a URI
43
+ # @param p [String, RDF::URI] Predicate – must be a URI
44
+ # @param o [String, RDF::URI, RDF::Literal, Numeric] Object – literal or URI
45
+ # @param repo [RDF::Repository, RDF::Mutable] Repository to insert the statement into
46
+ # @param datatype [RDF::URI, nil] Explicit datatype for the object (overrides auto-detection)
47
+ # @param context [String, RDF::URI, nil] Optional named graph (turns the statement into a quad)
48
+ # @param language [String, Symbol, nil] Language tag for string literals (default: "en")
49
+ #
50
+ # @return [Boolean] +true+ if the statement was inserted, +false+ if any
51
+ # required argument (s, p, o, repo) was empty
52
+ #
53
+ # @raise [SystemExit] (via +abort+) if subject, predicate or context
54
+ # cannot be converted to a valid URI
55
+ #
56
+ # @note When +datatype+ is supplied it takes precedence. Otherwise the
57
+ # method tries to auto-detect URI, xsd:date, xsd:dateTime, numeric
58
+ # types, and falls back to a language-tagged literal using the
59
+ # +language+ parameter (default: English).
60
+ #
61
+ # @see RDF::Statement
62
+ # @see RDF::Literal
63
+ # @see RDF::URI
64
+ def triplify(s, p, o, repo, datatype: nil, context: nil, language: 'en')
65
+ # warn "context #{context}"
66
+ s = s.strip if s.instance_of?(String)
67
+ p = p.strip if p.instance_of?(String)
68
+ o = o.strip if o.instance_of?(String)
69
+
70
+ return false if s.to_s.empty? || p.to_s.empty? || o.to_s.empty? || repo.to_s.empty?
71
+
72
+ # Convert subject to URI if needed
73
+ unless s.respond_to?(:uri)
74
+ if s.to_s =~ %r{^\w+:/?/?[^\s]+}
75
+ s = RDF::URI.new(s.to_s)
76
+ else
77
+ abort "Subject #{s} must be a URI-compatible thingy"
78
+ end
79
+ end
80
+
81
+ # Convert predicate to URI if needed
82
+ unless p.respond_to?(:uri)
83
+ if p.to_s =~ %r{^\w+:/?/?[^\s]+}
84
+ p = RDF::URI.new(p.to_s)
85
+ else
86
+ abort "Predicate #{p} must be a URI-compatible thingy"
87
+ end
88
+ end
89
+
90
+ # Convert object with smart literal detection
91
+ unless o.respond_to?(:uri?)
92
+ o = if datatype
93
+ RDF::Literal.new(o.to_s, datatype: datatype)
94
+ elsif o.to_s =~ %r{\A\w+:/?/?\w[^\s]+}
95
+ RDF::URI.new(o.to_s)
96
+ # Detect xsd:dateTime (contains T + time)
97
+ elsif o.to_s =~ /^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d/
98
+ RDF::Literal.new(o.to_s, datatype: RDF::XSD.dateTime)
99
+ # Detect xsd:date (YYYY-MM-DD, but NOT followed by T)
100
+ elsif o.to_s =~ /^\d{4}-[01]\d-[0-3]\d(?!T)/
101
+ RDF::Literal.new(o.to_s, datatype: RDF::XSD.date)
102
+ # Numeric types
103
+ elsif o.to_s =~ /^[+-]?\d+\.\d+/ && o.to_s !~ /[^+\-\d.]/
104
+ RDF::Literal.new(o.to_s, datatype: RDF::XSD.float)
105
+ elsif o.to_s =~ /^[+-]?[0-9]+$/ && o.to_s !~ /[^+\-\d.]/
106
+ RDF::Literal.new(o.to_s, datatype: RDF::XSD.integer)
107
+ else
108
+ RDF::Literal.new(o.to_s, language: language)
109
+ end
110
+ end
111
+
112
+ # Build statement (triple or quad)
113
+ if context
114
+ unless context.respond_to?(:uri)
115
+ if context.to_s =~ %r{^\w+:/?/?[^\s]+}
116
+ context = RDF::URI.new(context.to_s)
117
+ else
118
+ abort "Context #{context} must be a URI-compatible thingy"
119
+ end
120
+ end
121
+
122
+ triple = RDF::Statement.new(s, p, o, graph_name: context)
123
+ else
124
+ triple = RDF::Statement.new(s, p, o)
125
+ end
126
+
127
+ repo.insert(triple)
128
+ true
129
+ end
130
+
131
+ module_function :triplify # Allows TripleEasy.triplify(...) as well
132
+ end
133
+
134
+ # Expose triplify at the top level (RuboCop-friendly)
135
+ Object.extend TripleEasy
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: triple_easy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mark Wilkinson
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rdf
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '3.0'
19
+ type: :development
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '3.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '3.13'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.13'
40
+ description: A lightweight helper that makes inserting RDF triples (and quads) very
41
+ convenient. It automatically converts strings into proper RDF::URI or RDF::Literal
42
+ objects with sensible datatype guessing (including xsd:date and xsd:dateTime) and
43
+ supports language tags.
44
+ email:
45
+ - markw@illuminae.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files:
49
+ - CHANGELOG.md
50
+ - LICENSE
51
+ - README.md
52
+ files:
53
+ - CHANGELOG.md
54
+ - Gemfile
55
+ - Gemfile.lock
56
+ - LICENSE
57
+ - README.md
58
+ - lib/triple_easy.rb
59
+ - lib/triple_easy/version.rb
60
+ homepage: https://github.com/markwilkinson/triple-easy
61
+ licenses:
62
+ - MIT
63
+ metadata:
64
+ homepage_uri: https://github.com/markwilkinson/triple-easy
65
+ source_code_uri: https://github.com/markwilkinson/triple-easy
66
+ documentation_uri: https://rubydoc.info/gems/triple_easy
67
+ changelog_uri: https://github.com/markwilkinson/triple-easy/blob/main/CHANGELOG.md
68
+ bug_tracker_uri: https://github.com/markwilkinson/triple-easy/issues
69
+ rubygems_mfa_required: 'true'
70
+ allowed_push_host: https://rubygems.org
71
+ rdoc_options:
72
+ - "--title"
73
+ - TripleEasy - Easy RDF Triplification
74
+ - "--main"
75
+ - README.md
76
+ - "--line-numbers"
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 3.2.0
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubygems_version: 4.0.9
91
+ specification_version: 4
92
+ summary: Make RDF triples easily with automatic URI and literal conversion
93
+ test_files: []