odrl-ruby 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +56 -0
- data/examples/biohackathon-output.ttl +34 -18
- data/examples/build_profile.rb +3 -3
- data/lib/odrl/odrl/version.rb +1 -1
- data/lib/odrl/party.rb +15 -9
- data/lib/odrl/profile/builder.rb +4 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 285996251973718c4ba4bea385e1df95bc8b3f23d4e50fc1fa5dd0fc28cb63d4
|
4
|
+
data.tar.gz: dbceab1cb4e5003016dd5f8499ae659e382c8be8a4900ec2a58ae6983bdc0263
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3385c5e104219c97354693ea4dbb758d8aa69d3ac48a40600c92cf0f45d724517035664d7824349c1904f309d2f4b2294889fc202801c977e2822e4c3d9fe260
|
7
|
+
data.tar.gz: 595f681f2e46d8d506f706fbac63830e4b32b6c05af4c876001420a38662533ac78caee7c7a05b8750588c3120f4689fbfdcd08219eccd13879096cb8fffc76a
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -20,6 +20,10 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
+
# Two functionalities: Build ODRL Policies; Build ODRL Profiles to extend the core ODRL vocabulary
|
24
|
+
|
25
|
+
# Build Policy:
|
26
|
+
|
23
27
|
```
|
24
28
|
require 'odrl/ruby'
|
25
29
|
|
@@ -65,6 +69,58 @@ result = policy.serialize(format: 'turtle') # get the RDF string
|
|
65
69
|
puts result
|
66
70
|
```
|
67
71
|
|
72
|
+
# Build Profile:
|
73
|
+
|
74
|
+
```
|
75
|
+
require 'odrl/profile/builder'
|
76
|
+
|
77
|
+
p = ODRL::Profile::Builder.new(
|
78
|
+
uri: 'https://example.org/myprofiles/germplasm_odrl_profile.ttl',
|
79
|
+
title: "ODRL Profile for Germplasm resources",
|
80
|
+
description: "There are some properties and comparisons that only make sense in the Germplasm expert domain",
|
81
|
+
author: "Mark D Wilkinson",
|
82
|
+
profile_class: "https://example.org/myprofiles/ontology#SeedOffer"
|
83
|
+
)
|
84
|
+
|
85
|
+
p.asset_relations << ODRL::Profile::AssetRelation.new(
|
86
|
+
uri: "https://example.org/myprofiles/ontology#nagoya_permission",
|
87
|
+
label: "Permission under Nagoya protocol",
|
88
|
+
definition: "Permission is a special thing in the Nagoya protocol")
|
89
|
+
|
90
|
+
|
91
|
+
p.party_functional_roles << ODRL::Profile::AssetRelation.new(
|
92
|
+
uri: "https://example.org/myprofiles/ontology#nagoya_assigner",
|
93
|
+
label: "Assigner with Nagoya authority to assign",
|
94
|
+
definition: "Assigners have special responsibilities in the Nagoya protocol")
|
95
|
+
|
96
|
+
p.actions << ODRL::Profile::Rule.new(
|
97
|
+
uri: "https://example.org/myprofiles/ontology#nagoya_propogate",
|
98
|
+
label: "Plant and Harvest",
|
99
|
+
definition: "the action of planting and harvesting the seed",
|
100
|
+
included_in: ODRLV.use,
|
101
|
+
implies: ODRLV.distribute)
|
102
|
+
|
103
|
+
|
104
|
+
p.leftOperands << ODRL::Profile::LeftOperand.new(
|
105
|
+
uri: "https://example.org/myprofiles/ontology#at_risk_species",
|
106
|
+
label: "At Risk Species",
|
107
|
+
definition: "A species that has been flagged as at-risk of extinction")
|
108
|
+
|
109
|
+
p.rightOperands << ODRL::Profile::RightOperand.new(
|
110
|
+
uri: "https://example.org/myprofiles/ontology#on_watchlist",
|
111
|
+
label: "On Watchlist",
|
112
|
+
definition: "A species whose risk of extinction is on a watchlist")
|
113
|
+
|
114
|
+
p.rightOperands << ODRL::Profile::Relation.new(
|
115
|
+
uri: "https://example.org/myprofiles/ontology#within_risk_boundary",
|
116
|
+
label: "Within Bounds",
|
117
|
+
definition: "comparison of risk boundaries")
|
118
|
+
|
119
|
+
|
120
|
+
p.build()
|
121
|
+
puts p.serialize
|
122
|
+
```
|
123
|
+
|
68
124
|
|
69
125
|
## License
|
70
126
|
|
@@ -1,47 +1,63 @@
|
|
1
1
|
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
2
2
|
|
3
|
-
<http://example.org#
|
4
|
-
<http://purl.org/dc/terms/identifier> <http://example.org#
|
5
|
-
a <http://www.w3.org/ns/odrl/2/Action> .
|
6
|
-
|
7
|
-
<http://example.org#constraint_68785487525880>
|
8
|
-
<http://purl.org/dc/terms/identifier> <http://example.org#constraint_68785487525880> ;
|
3
|
+
<http://example.org#constraint_68811358965684>
|
4
|
+
<http://purl.org/dc/terms/identifier> <http://example.org#constraint_68811358965684> ;
|
9
5
|
<http://purl.org/dc/terms/title> "Only during the hackathon"@en ;
|
10
6
|
a <http://www.w3.org/ns/odrl/2/Constraint> ;
|
7
|
+
<http://www.w3.org/2000/01/rdf-schema#label> "Only during the hackathon"@en ;
|
11
8
|
<http://www.w3.org/ns/odrl/2/leftOperand> <http://www.w3.org/ns/odrl/2/event> ;
|
12
9
|
<http://www.w3.org/ns/odrl/2/operator> <http://www.w3.org/ns/odrl/2/eq> ;
|
13
|
-
<http://www.w3.org/ns/odrl/2/rightOperand> <https://2023.biohackathon.org>
|
10
|
+
<http://www.w3.org/ns/odrl/2/rightOperand> <https://2023.biohackathon.org> ;
|
11
|
+
<http://www.w3.org/ns/odrl/2/uid> <http://example.org#constraint_68811358965684> .
|
14
12
|
|
15
|
-
<http://example.org#
|
13
|
+
<http://example.org#policy_68811358965627>
|
16
14
|
<http://purl.org/dc/terms/creator> <https://orcid.org/0000-0001-6960-357X> ;
|
17
15
|
<http://purl.org/dc/terms/description> "An offer for Toshiaki-san to use the polyA data during the hackathon"@en ;
|
18
|
-
<http://purl.org/dc/terms/identifier> <http://example.org#
|
16
|
+
<http://purl.org/dc/terms/identifier> <http://example.org#policy_68811358965627> ;
|
19
17
|
<http://purl.org/dc/terms/subject> "collaboration"@en ;
|
20
18
|
<http://purl.org/dc/terms/title> "Offer to Toshiaki-san"@en ;
|
21
19
|
a <http://www.w3.org/ns/odrl/2/Offer> ;
|
22
|
-
<http://www.w3.org/
|
20
|
+
<http://www.w3.org/2000/01/rdf-schema#label> "Offer to Toshiaki-san"@en ;
|
21
|
+
<http://www.w3.org/ns/odrl/2/permission> <http://example.org#rule_68811358965667> ;
|
22
|
+
<http://www.w3.org/ns/odrl/2/uid> <http://example.org#policy_68811358965627> .
|
23
23
|
|
24
|
-
<http://example.org#
|
25
|
-
<http://purl.org/dc/terms/identifier> <http://example.org#
|
24
|
+
<http://example.org#rule_68811358965667>
|
25
|
+
<http://purl.org/dc/terms/identifier> <http://example.org#rule_68811358965667> ;
|
26
26
|
<http://purl.org/dc/terms/title> "Permission to use"@en ;
|
27
27
|
a <http://www.w3.org/ns/odrl/2/Permission> ;
|
28
|
-
<http://www.w3.org/
|
28
|
+
<http://www.w3.org/2000/01/rdf-schema#label> "Permission to use"@en ;
|
29
|
+
<http://www.w3.org/ns/odrl/2/action> <http://www.w3.org/ns/odrl/2/use> ;
|
29
30
|
<http://www.w3.org/ns/odrl/2/assignee> <https://orcid.org/0000-0001-6960-357X> ;
|
30
31
|
<http://www.w3.org/ns/odrl/2/assigner> <https://orcid.org/0000-0003-2391-0384> ;
|
31
|
-
<http://www.w3.org/ns/odrl/2/constraint> <http://example.org#
|
32
|
-
<http://www.w3.org/ns/odrl/2/target> <http://mark.wilkinson.org/data/polyA>
|
32
|
+
<http://www.w3.org/ns/odrl/2/constraint> <http://example.org#constraint_68811358965684> ;
|
33
|
+
<http://www.w3.org/ns/odrl/2/target> <http://mark.wilkinson.org/data/polyA> ;
|
34
|
+
<http://www.w3.org/ns/odrl/2/uid> <http://example.org#rule_68811358965667> .
|
33
35
|
|
34
36
|
<http://mark.wilkinson.org/data/polyA>
|
35
37
|
<http://purl.org/dc/terms/identifier> <http://mark.wilkinson.org/data/polyA> ;
|
36
38
|
<http://purl.org/dc/terms/title> "Mark's PolyA Database"@en ;
|
37
|
-
a <http://www.w3.org/ns/odrl/2/Asset>
|
39
|
+
a <http://www.w3.org/ns/odrl/2/Asset> ;
|
40
|
+
<http://www.w3.org/2000/01/rdf-schema#label> "Mark's PolyA Database"@en ;
|
41
|
+
<http://www.w3.org/ns/odrl/2/uid> <http://mark.wilkinson.org/data/polyA> .
|
42
|
+
|
43
|
+
<http://www.w3.org/ns/odrl/2/use>
|
44
|
+
<http://purl.org/dc/terms/identifier> <http://www.w3.org/ns/odrl/2/use> ;
|
45
|
+
a "type"@en ;
|
46
|
+
<http://www.w3.org/2000/01/rdf-schema#label> ""@en ;
|
47
|
+
<http://www.w3.org/ns/odrl/2/uid> <http://www.w3.org/ns/odrl/2/use> ;
|
48
|
+
<https://schema.org/name> ""@en .
|
38
49
|
|
39
50
|
<https://orcid.org/0000-0001-6960-357X>
|
40
51
|
<http://purl.org/dc/terms/identifier> <https://orcid.org/0000-0001-6960-357X> ;
|
41
52
|
<http://purl.org/dc/terms/title> "Mark D Wilkinson"@en ;
|
42
|
-
a <http://www.w3.org/ns/odrl/2/Party>
|
53
|
+
a <http://www.w3.org/ns/odrl/2/Party> ;
|
54
|
+
<http://www.w3.org/2000/01/rdf-schema#label> "Mark D Wilkinson"@en ;
|
55
|
+
<http://www.w3.org/ns/odrl/2/uid> <https://orcid.org/0000-0001-6960-357X> .
|
43
56
|
|
44
57
|
<https://orcid.org/0000-0003-2391-0384>
|
45
58
|
<http://purl.org/dc/terms/identifier> <https://orcid.org/0000-0003-2391-0384> ;
|
46
59
|
<http://purl.org/dc/terms/title> "Toshiaki Katayama"@en ;
|
47
|
-
a <http://www.w3.org/ns/odrl/2/Party>
|
60
|
+
a <http://www.w3.org/ns/odrl/2/Party> ;
|
61
|
+
<http://www.w3.org/2000/01/rdf-schema#label> "Toshiaki Katayama"@en ;
|
62
|
+
<http://www.w3.org/ns/odrl/2/uid> <https://orcid.org/0000-0003-2391-0384> .
|
63
|
+
|
data/examples/build_profile.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'odrl/profile/builder'
|
2
2
|
|
3
3
|
p = ODRL::Profile::Builder.new(
|
4
4
|
uri: 'https://example.org/myprofiles/germplasm_odrl_profile.ttl',
|
@@ -14,7 +14,7 @@ p.asset_relations << ODRL::Profile::AssetRelation.new(
|
|
14
14
|
definition: "Permission is a special thing in the Nagoya protocol")
|
15
15
|
|
16
16
|
|
17
|
-
p.party_functional_roles << ODRL::Profile::
|
17
|
+
p.party_functional_roles << ODRL::Profile::PartyFunction.new(
|
18
18
|
uri: "https://example.org/myprofiles/ontology#nagoya_assigner",
|
19
19
|
label: "Assigner with Nagoya authority to assign",
|
20
20
|
definition: "Assigners have special responsibilities in the Nagoya protocol")
|
@@ -37,7 +37,7 @@ p.rightOperands << ODRL::Profile::RightOperand.new(
|
|
37
37
|
label: "On Watchlist",
|
38
38
|
definition: "A species whose risk of extinction is on a watchlist")
|
39
39
|
|
40
|
-
p.
|
40
|
+
p.operators << ODRL::Profile::Operator.new(
|
41
41
|
uri: "https://example.org/myprofiles/ontology#within_risk_boundary",
|
42
42
|
label: "Within Bounds",
|
43
43
|
definition: "comparison of risk boundaries")
|
data/lib/odrl/odrl/version.rb
CHANGED
data/lib/odrl/party.rb
CHANGED
@@ -18,8 +18,8 @@ module ODRL
|
|
18
18
|
super(uid: @uid, type: type, **args)
|
19
19
|
|
20
20
|
@refinements = {}
|
21
|
-
@partOf =
|
22
|
-
@predicate = predicate
|
21
|
+
@partOf = {}
|
22
|
+
@predicate = predicate.to_s
|
23
23
|
|
24
24
|
if @predicate&.match(/https?:/)
|
25
25
|
# do nothing! It's their choice to send a full predicate!
|
@@ -42,10 +42,17 @@ module ODRL
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
|
45
|
+
partOf = [partOf] unless partOf.is_a? Array
|
46
|
+
unless partOf.first.nil?
|
47
|
+
partOf.each do |p|
|
48
|
+
p.addPart(part: self)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
unless @partOf and !(@partOf.is_a? PartyCollection) # if it exists and is the wrong type
|
53
|
+
raise "The parent collection of a Party must be of type ODRL::PaertyCollection."
|
54
|
+
end
|
46
55
|
|
47
|
-
raise "The parent collection of a Party must be of type ODRL::PaertyCollection."
|
48
|
-
# @partOf = nil
|
49
56
|
end
|
50
57
|
|
51
58
|
def addRefinement(refinement: args)
|
@@ -55,16 +62,15 @@ module ODRL
|
|
55
62
|
end
|
56
63
|
|
57
64
|
def addPart(part: args)
|
58
|
-
raise "Party cannot be added as part of something that is not an PartyCollection" unless is_a?(PartyCollection)
|
59
|
-
raise "Only Parties can be added as part of PartyCollections" unless part.is_a?(Asset)
|
60
|
-
|
65
|
+
raise "Party cannot be added as part of something that is not an PartyCollection" unless self.is_a?(PartyCollection)
|
61
66
|
part.partOf[uid] = [PPARTOF, self]
|
62
67
|
end
|
63
68
|
|
64
69
|
def load_graph
|
65
70
|
super
|
66
71
|
# TODO: This is bad DRY!! Put the bulk of this method into the base object
|
67
|
-
|
72
|
+
# TODO: Currently we don't support partOf
|
73
|
+
%i[refinements].each do |connected_object_type|
|
68
74
|
next unless send(connected_object_type)
|
69
75
|
|
70
76
|
send(connected_object_type).each do |_uid, typedconnection|
|
data/lib/odrl/profile/builder.rb
CHANGED
@@ -16,7 +16,7 @@ module ODRL
|
|
16
16
|
module Profile
|
17
17
|
class Builder
|
18
18
|
attr_accessor :uri, :profile_class, :repository, :title, :description, :author
|
19
|
-
attr_accessor :asset_relations, :party_functional_roles, :actions, :leftOperands, :rightOperands
|
19
|
+
attr_accessor :asset_relations, :party_functional_roles, :actions, :leftOperands, :rightOperands, :operators
|
20
20
|
|
21
21
|
# attr_accessor :logicalConstraints, :conflict_strategies, :rules
|
22
22
|
def initialize(uri:, profile_class:, title:, description:, author:)
|
@@ -31,6 +31,7 @@ module ODRL
|
|
31
31
|
@actions = []
|
32
32
|
@leftOperands = []
|
33
33
|
@rightOperands = []
|
34
|
+
@operators = []
|
34
35
|
@asset_relations = []
|
35
36
|
|
36
37
|
# Required declarations of disjointedness
|
@@ -49,7 +50,7 @@ module ODRL
|
|
49
50
|
description and ODRL::Profile::Builder.triplify(uri, DCT.title, description, repo)
|
50
51
|
author and ODRL::Profile::Builder.triplify(uri, DC.creator, author, repo)
|
51
52
|
|
52
|
-
[asset_relations, party_functional_roles, actions, leftOperands, rightOperands,
|
53
|
+
[asset_relations, party_functional_roles, actions, leftOperands, rightOperands, operators].flatten.each do |elem|
|
53
54
|
elem.build(repo: repo)
|
54
55
|
end
|
55
56
|
end
|
@@ -173,7 +174,7 @@ module ODRL
|
|
173
174
|
end
|
174
175
|
end
|
175
176
|
|
176
|
-
class
|
177
|
+
class Operator < ProfileElement
|
177
178
|
# ex:myOperator a odrl:Operator .
|
178
179
|
def build(repo:)
|
179
180
|
ODRL::Profile::Builder.triplify(uri, RDF.type, ODRLV.Operator, repo)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: odrl-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Wilkinson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A builder for ODRL files. Does basic validation against core ODRL vocabularies.
|
14
14
|
Has a Builder that allows you to create ODRL Profiles to extend the core vocabulary. DOES
|