odrl-ruby 0.2.3 → 0.2.4
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 +4 -4
- data/.rubocop.yml +16 -16
- data/CHANGELOG.md +5 -5
- data/Gemfile +12 -12
- data/Gemfile.lock +249 -249
- data/LICENSE.txt +21 -21
- data/README.md +128 -127
- data/Rakefile +8 -8
- data/bin/console +15 -15
- data/bin/setup +8 -8
- data/examples/biohackathon-output.ttl +63 -63
- data/examples/build_profile.rb +48 -47
- data/examples/create-biohackathon-offer.rb +44 -44
- data/examples/create-nagoya-es-offer.rb +54 -54
- data/examples/nagoya-output.ttl +66 -66
- data/launch.json +10 -10
- data/lib/odrl/action.rb +106 -106
- data/lib/odrl/asset.rb +77 -77
- data/lib/odrl/base.rb +230 -230
- data/lib/odrl/constraint.rb +110 -110
- data/lib/odrl/odrl/version.rb +7 -7
- data/lib/odrl/party.rb +97 -97
- data/lib/odrl/policy.rb +97 -97
- data/lib/odrl/profile/builder.rb +348 -186
- data/lib/odrl/ruby.rb +26 -26
- data/lib/odrl/rule.rb +116 -116
- metadata +8 -6
data/lib/odrl/rule.rb
CHANGED
@@ -1,116 +1,116 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "odrl/version"
|
4
|
-
# require "ODRL::Asset"
|
5
|
-
# require "ODRL::Constraint"
|
6
|
-
|
7
|
-
module ODRL
|
8
|
-
class Rule < Base
|
9
|
-
attr_accessor :uid, :constraints, :assets, :predicate, :type, :action, :assigner, :assignee
|
10
|
-
|
11
|
-
def initialize(
|
12
|
-
uid: nil,
|
13
|
-
constraints: nil,
|
14
|
-
assets: nil,
|
15
|
-
predicate: nil,
|
16
|
-
action: nil,
|
17
|
-
assigner: nil,
|
18
|
-
assignee: nil,
|
19
|
-
type: CRULE,
|
20
|
-
**args
|
21
|
-
)
|
22
|
-
@uid = uid
|
23
|
-
|
24
|
-
@uid ||= Base.baseURI + "#rule_" + Base.getuuid
|
25
|
-
super(uid: @uid, type: type, **args)
|
26
|
-
|
27
|
-
@constraints = {}
|
28
|
-
@assets = {}
|
29
|
-
@assigner = {}
|
30
|
-
@assignee = {}
|
31
|
-
@action = {}
|
32
|
-
|
33
|
-
assets = [assets] unless assets.is_a? Array
|
34
|
-
unless assets.first.nil?
|
35
|
-
assets.each do |c|
|
36
|
-
addAsset(asset: c)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
constraints = [constraints] unless constraints.is_a? Array
|
40
|
-
return if constraints.first.nil?
|
41
|
-
|
42
|
-
constraints.each do |c|
|
43
|
-
addConstraint(constraint: c)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def addAsset(asset:)
|
48
|
-
raise "Asset is not an ODRL Asset" unless asset.is_a?(Asset)
|
49
|
-
|
50
|
-
uid = asset.uid
|
51
|
-
assets[uid] = [PASSET, asset]
|
52
|
-
end
|
53
|
-
|
54
|
-
def addConstraint(constraint:)
|
55
|
-
raise "Constraint is not an ODRL Constraint" unless constraint.is_a?(Constraint)
|
56
|
-
|
57
|
-
constraints[constraint.uid] = [PCONSTRAINT, constraint]
|
58
|
-
end
|
59
|
-
|
60
|
-
def addAction(action:)
|
61
|
-
raise "Action is not an ODRL Action" unless action.is_a?(Action)
|
62
|
-
|
63
|
-
self.action[action.uid] = [PACTION, action]
|
64
|
-
end
|
65
|
-
|
66
|
-
def addAssigner(party:)
|
67
|
-
raise "Assigner is not an ODRL Party" unless party.is_a?(Party)
|
68
|
-
|
69
|
-
assigner[party.uid] = [PASSIGNER, party]
|
70
|
-
end
|
71
|
-
|
72
|
-
def addAssignee(party:)
|
73
|
-
raise "Asigner is not an ODRL Party" unless party.is_a?(Party)
|
74
|
-
|
75
|
-
assignee[party.uid] = [PASSIGNEE, party]
|
76
|
-
end
|
77
|
-
|
78
|
-
def load_graph
|
79
|
-
super
|
80
|
-
%i[constraints assets action assigner assignee].each do |connected_object_type|
|
81
|
-
next unless send(connected_object_type)
|
82
|
-
|
83
|
-
send(connected_object_type).each do |_uid, typedconnection|
|
84
|
-
predicate, odrlobject = typedconnection # e.g. "action", ActionObject
|
85
|
-
object = odrlobject.uid
|
86
|
-
subject = uid
|
87
|
-
repo = repository
|
88
|
-
triplify(subject, predicate, object, repo)
|
89
|
-
odrlobject.load_graph # start the cascade
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def serialize(format:)
|
95
|
-
super
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
class Permission < Rule
|
100
|
-
def initialize(predicate: PPERMISSION, type: CPERMISSION, **args)
|
101
|
-
super(predicate: predicate, type: type, **args)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
class Duty < Rule
|
106
|
-
def initialize(predicate: PDUTY, type: CDUTY, **args)
|
107
|
-
super(predicate: predicate, type: type, **args)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
class Prohibition < Rule
|
112
|
-
def initialize(predicate: PPROHIBITION, type: CPROHIBITION, **args)
|
113
|
-
super(predicate: predicate, type: type, **args)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "odrl/version"
|
4
|
+
# require "ODRL::Asset"
|
5
|
+
# require "ODRL::Constraint"
|
6
|
+
|
7
|
+
module ODRL
|
8
|
+
class Rule < Base
|
9
|
+
attr_accessor :uid, :constraints, :assets, :predicate, :type, :action, :assigner, :assignee
|
10
|
+
|
11
|
+
def initialize(
|
12
|
+
uid: nil,
|
13
|
+
constraints: nil,
|
14
|
+
assets: nil,
|
15
|
+
predicate: nil,
|
16
|
+
action: nil,
|
17
|
+
assigner: nil,
|
18
|
+
assignee: nil,
|
19
|
+
type: CRULE,
|
20
|
+
**args
|
21
|
+
)
|
22
|
+
@uid = uid
|
23
|
+
|
24
|
+
@uid ||= Base.baseURI + "#rule_" + Base.getuuid
|
25
|
+
super(uid: @uid, type: type, **args)
|
26
|
+
|
27
|
+
@constraints = {}
|
28
|
+
@assets = {}
|
29
|
+
@assigner = {}
|
30
|
+
@assignee = {}
|
31
|
+
@action = {}
|
32
|
+
|
33
|
+
assets = [assets] unless assets.is_a? Array
|
34
|
+
unless assets.first.nil?
|
35
|
+
assets.each do |c|
|
36
|
+
addAsset(asset: c)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
constraints = [constraints] unless constraints.is_a? Array
|
40
|
+
return if constraints.first.nil?
|
41
|
+
|
42
|
+
constraints.each do |c|
|
43
|
+
addConstraint(constraint: c)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def addAsset(asset:)
|
48
|
+
raise "Asset is not an ODRL Asset" unless asset.is_a?(Asset)
|
49
|
+
|
50
|
+
uid = asset.uid
|
51
|
+
assets[uid] = [PASSET, asset]
|
52
|
+
end
|
53
|
+
|
54
|
+
def addConstraint(constraint:)
|
55
|
+
raise "Constraint is not an ODRL Constraint" unless constraint.is_a?(Constraint)
|
56
|
+
|
57
|
+
constraints[constraint.uid] = [PCONSTRAINT, constraint]
|
58
|
+
end
|
59
|
+
|
60
|
+
def addAction(action:)
|
61
|
+
raise "Action is not an ODRL Action" unless action.is_a?(Action)
|
62
|
+
|
63
|
+
self.action[action.uid] = [PACTION, action]
|
64
|
+
end
|
65
|
+
|
66
|
+
def addAssigner(party:)
|
67
|
+
raise "Assigner is not an ODRL Party" unless party.is_a?(Party)
|
68
|
+
|
69
|
+
assigner[party.uid] = [PASSIGNER, party]
|
70
|
+
end
|
71
|
+
|
72
|
+
def addAssignee(party:)
|
73
|
+
raise "Asigner is not an ODRL Party" unless party.is_a?(Party)
|
74
|
+
|
75
|
+
assignee[party.uid] = [PASSIGNEE, party]
|
76
|
+
end
|
77
|
+
|
78
|
+
def load_graph
|
79
|
+
super
|
80
|
+
%i[constraints assets action assigner assignee].each do |connected_object_type|
|
81
|
+
next unless send(connected_object_type)
|
82
|
+
|
83
|
+
send(connected_object_type).each do |_uid, typedconnection|
|
84
|
+
predicate, odrlobject = typedconnection # e.g. "action", ActionObject
|
85
|
+
object = odrlobject.uid
|
86
|
+
subject = uid
|
87
|
+
repo = repository
|
88
|
+
triplify(subject, predicate, object, repo)
|
89
|
+
odrlobject.load_graph # start the cascade
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def serialize(format:)
|
95
|
+
super
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
class Permission < Rule
|
100
|
+
def initialize(predicate: PPERMISSION, type: CPERMISSION, **args)
|
101
|
+
super(predicate: predicate, type: type, **args)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
class Duty < Rule
|
106
|
+
def initialize(predicate: PDUTY, type: CDUTY, **args)
|
107
|
+
super(predicate: predicate, type: type, **args)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
class Prohibition < Rule
|
112
|
+
def initialize(predicate: PPROHIBITION, type: CPROHIBITION, **args)
|
113
|
+
super(predicate: predicate, type: type, **args)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Wilkinson
|
8
|
-
|
8
|
+
- Oussama Benhamed
|
9
|
+
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2024-06-13 00:00:00.000000000 Z
|
12
13
|
dependencies: []
|
13
14
|
description: A builder for ODRL files. Does basic validation against core ODRL vocabularies.
|
14
15
|
Has a Builder that allows you to create ODRL Profiles to extend the core vocabulary. DOES
|
@@ -16,6 +17,7 @@ description: A builder for ODRL files. Does basic validation against core ODRL v
|
|
16
17
|
the bits that I needed!
|
17
18
|
email:
|
18
19
|
- markw@illuminae.com
|
20
|
+
- benhamedoussamamed@gmail.com
|
19
21
|
executables: []
|
20
22
|
extensions: []
|
21
23
|
extra_rdoc_files: []
|
@@ -54,7 +56,7 @@ metadata:
|
|
54
56
|
source_code_uri: https://github.com/markwilkinson/ODRL-RUBY
|
55
57
|
changelog_uri: https://github.com/markwilkinson/ODRL-RUBY/blob/master/CHANGELOG.md
|
56
58
|
documentation_uri: https://www.rubydoc.info/gems/odrl-ruby/
|
57
|
-
post_install_message:
|
59
|
+
post_install_message:
|
58
60
|
rdoc_options: []
|
59
61
|
require_paths:
|
60
62
|
- lib
|
@@ -69,8 +71,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
71
|
- !ruby/object:Gem::Version
|
70
72
|
version: '0'
|
71
73
|
requirements: []
|
72
|
-
rubygems_version: 3.
|
73
|
-
signing_key:
|
74
|
+
rubygems_version: 3.4.19
|
75
|
+
signing_key:
|
74
76
|
specification_version: 4
|
75
77
|
summary: builds ODRL files.
|
76
78
|
test_files: []
|