odrl-ruby 0.1.2 → 0.1.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 +1 -1
- data/Gemfile.lock +1 -1
- data/lib/odrl/action.rb +20 -23
- data/lib/odrl/asset.rb +11 -13
- data/lib/odrl/base.rb +77 -59
- data/lib/odrl/constraint.rb +21 -12
- data/lib/odrl/odrl/version.rb +1 -1
- data/lib/odrl/party.rb +18 -13
- data/lib/odrl/policy.rb +17 -11
- data/lib/odrl/rule.rb +24 -27
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 920e72e3d22ebf2895fa79bb43bd0a5e5b7d257ffad35bc3a8920a9b2d140649
|
4
|
+
data.tar.gz: 663462477a5b32043293afa56148d2fde102a88bcfe285672d7fa157277ec48d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c787e947589f888aab1e31f0a429713de6311600e3f5503d8638c1ed73fcd1e585f0b715dccda80cd625a96820b5a226533f83cf48f95581a2fb646b85aaf8aa
|
7
|
+
data.tar.gz: c9f4028606c82de1216c58865131c67060f647b09942ff31ad9b2432b2ccaacf3a32114e67cd9324280055ef7b3ad78ff0fe5eb18200b345389969f96e076395
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/lib/odrl/action.rb
CHANGED
@@ -2,28 +2,28 @@
|
|
2
2
|
|
3
3
|
module ODRL
|
4
4
|
|
5
|
-
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# @
|
10
|
-
# @attr [
|
11
|
-
# @attr [
|
12
|
-
# @attr [
|
13
|
-
# @attr [string]
|
14
|
-
|
5
|
+
# ODRL::Action
|
6
|
+
# Describes an action like "use"
|
7
|
+
#
|
8
|
+
# @author Mark D Wilkinson
|
9
|
+
# @attr [URI] (optional) uid the URI of the Action node
|
10
|
+
# @attr [[ODRL::Refinement]] (optional) ODRL Refinement objects
|
11
|
+
# @attr [URI] predicate (optional) the predicate you wish to use with this action
|
12
|
+
# @attr [string] value (required) a string like "use"
|
13
|
+
# @attr [string] vallabel (optional) a string like "use"
|
14
|
+
class Action < Base
|
15
15
|
|
16
16
|
attr_accessor :uid, :refinements, :predicate, :type, :value, :vallabel
|
17
17
|
|
18
18
|
|
19
19
|
# constructor
|
20
20
|
# @param [Hash] opts the options to create a message with.
|
21
|
-
# @option :value the string value of rthe action, like "use"
|
22
|
-
# @option :vallabel the string for the label, like "use"
|
21
|
+
# @option opts [String] :value the string value of rthe action, like "use"
|
22
|
+
# @option opts [String] :vallabel the string for the label, like "use"
|
23
23
|
#
|
24
|
-
def initialize(args)
|
25
|
-
@value =
|
26
|
-
@vallabel =
|
24
|
+
def initialize(value:, vallabel: "", type: CACTION, **args)
|
25
|
+
@value = value
|
26
|
+
@vallabel = vallabel || @value
|
27
27
|
raise "Actions must haves a value such as 'use' - I'm dead!" unless @value
|
28
28
|
@value = "http://www.w3.org/ns/odrl/2/#{@value}" unless @value =~ /http:\/\// # if it is already a URI, then let it go
|
29
29
|
|
@@ -31,9 +31,8 @@ module ODRL
|
|
31
31
|
# unless @uid
|
32
32
|
# self.uid = Base.baseURI + "#action_" + Base.getuuid
|
33
33
|
# end
|
34
|
-
super(
|
34
|
+
super(uid: @uid, type: type, **args)
|
35
35
|
|
36
|
-
self.type="http://www.w3.org/ns/odrl/2/Action"
|
37
36
|
|
38
37
|
@refinements = Hash.new
|
39
38
|
|
@@ -102,15 +101,13 @@ module ODRL
|
|
102
101
|
|
103
102
|
|
104
103
|
class Use < Action
|
105
|
-
def initialize(args)
|
106
|
-
super(args)
|
107
|
-
self.type = "http://www.w3.org/ns/odrl/2/Action" unless self.type
|
104
|
+
def initialize(type: CACTION, **args)
|
105
|
+
super(type: :type, **args)
|
108
106
|
end
|
109
107
|
end
|
110
108
|
class Transfer < Action
|
111
|
-
def initialize(args)
|
112
|
-
super(args)
|
113
|
-
self.type = "http://www.w3.org/ns/odrl/2/Action" unless self.type
|
109
|
+
def initialize(type: CACTION, **args)
|
110
|
+
super(type: :type, **args)
|
114
111
|
end
|
115
112
|
end
|
116
113
|
|
data/lib/odrl/asset.rb
CHANGED
@@ -10,17 +10,15 @@ module ODRL
|
|
10
10
|
class Asset < Base
|
11
11
|
attr_accessor :uid, :hasPolicy, :refinements, :partOf
|
12
12
|
|
13
|
-
def initialize(args)
|
14
|
-
@uid =
|
13
|
+
def initialize(type: CASSET, hasPolicy: nil, refinements: nil, partOf: nil, **args)
|
14
|
+
@uid = uid
|
15
15
|
unless @uid
|
16
16
|
self.uid = Base.baseURI + "#asset_" + Base.getuuid
|
17
17
|
end
|
18
|
-
super(
|
19
|
-
self.type="http://www.w3.org/ns/odrl/2/Asset"
|
18
|
+
super(type: type, uid: @uid, **args)
|
20
19
|
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@hasPolicy = args[:hasPolicy]
|
20
|
+
@partOf = partOf
|
21
|
+
@hasPolicy = hasPolicy
|
24
22
|
|
25
23
|
if @hasPolicy and !(@hasPolicy.is_a? Policy) # if it exists and is the wrong type
|
26
24
|
raise "The policy of an Asset must be of type ODRL::Policy. The provided value will be discarded"
|
@@ -31,9 +29,10 @@ module ODRL
|
|
31
29
|
@partOf = nil
|
32
30
|
end
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
@refinements = Hash.new
|
33
|
+
refinements = [refinements] unless refinements.is_a? Array
|
34
|
+
if !(refinements.first.nil?)
|
35
|
+
refinements.each do |c|
|
37
36
|
self.addRefinement(refinement: c)
|
38
37
|
end
|
39
38
|
end
|
@@ -82,9 +81,8 @@ module ODRL
|
|
82
81
|
|
83
82
|
class AssetCollection < Asset
|
84
83
|
|
85
|
-
def initialize(args)
|
86
|
-
super(args)
|
87
|
-
self.type="http://www.w3.org/ns/odrl/2/AssetCollection"
|
84
|
+
def initialize(type: CASSETCOLLECTION, **args)
|
85
|
+
super(type: type, **args)
|
88
86
|
end
|
89
87
|
end
|
90
88
|
|
data/lib/odrl/base.rb
CHANGED
@@ -2,47 +2,52 @@
|
|
2
2
|
|
3
3
|
require_relative "odrl/version"
|
4
4
|
|
5
|
-
# one day move these all to ODRLV.xxxx
|
6
|
-
CPOLICY= "http://www.w3.org/ns/odrl/2/Policy"
|
7
5
|
|
8
|
-
|
9
|
-
COFFER= "http://www.w3.org/ns/odrl/2/Offer"
|
10
|
-
CREQUEST= "http://www.w3.org/ns/odrl/2/Request"
|
11
|
-
CAGREEMENT= "http://www.w3.org/ns/odrl/2/Agreement"
|
6
|
+
CPOLICY= ODRLV.Policy.to_s
|
12
7
|
|
13
|
-
|
14
|
-
|
8
|
+
CSET= ODRLV.Set.to_s
|
9
|
+
COFFER= ODRLV.Offer.to_s
|
10
|
+
CREQUEST= ODRLV.Request.to_s
|
11
|
+
CAGREEMENT= ODRLV.Agreement.to_s
|
12
|
+
CPRIVACY= ODRLV.Privacy.to_s
|
13
|
+
PASSET = ODRLV.target.to_s
|
14
|
+
CASSET= ODRLV.Asset.to_s
|
15
|
+
CASSETCOLLECTION= ODRLV.Asset.to_s
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
CRULE= ODRLV.Rule.to_s
|
18
|
+
CPERMISSION= ODRLV.Permission.to_s
|
19
|
+
PPERMISSION = ODRLV.permission.to_s
|
20
|
+
CPROHIBITION= ODRLV.Prohibition.to_s
|
21
|
+
PPROHIBITION = ODRLV.prohibition.to_s
|
22
|
+
PDUTY= ODRLV.obligation.to_s
|
23
|
+
CDUTY = ODRLV.Duty.to_s
|
22
24
|
|
23
|
-
PRULE =
|
25
|
+
PRULE = ODRLV.Rule.to_s
|
24
26
|
|
25
27
|
|
26
|
-
PACTION =
|
27
|
-
|
28
|
+
PACTION = ODRLV.action.to_s
|
29
|
+
VUSE = ODRLV.use.to_s # this is goofy ODRL stuff...
|
30
|
+
VTRANSFER = ODRLV.transfer.to_s # this is goofy ODRL stuff...
|
31
|
+
CACTION= ODRLV.Action.to_s
|
28
32
|
|
29
|
-
PREFINEMENT =
|
33
|
+
PREFINEMENT = ODRLV.refinement.to_s
|
30
34
|
|
31
|
-
PASSIGNER =
|
32
|
-
PASSIGNEE =
|
33
|
-
CPARTY=
|
35
|
+
PASSIGNER = ODRLV.assigner.to_s
|
36
|
+
PASSIGNEE = ODRLV.assignee.to_s
|
37
|
+
CPARTY= ODRLV.Party.to_s
|
38
|
+
CPARTYCOLLECTION= ODRLV.Party.to_s
|
34
39
|
|
35
|
-
PCONSTRAINT =
|
36
|
-
CCONSTRAINT =
|
37
|
-
PLEFT =
|
38
|
-
PRIGHT =
|
39
|
-
POPERATOR =
|
40
|
-
POPERANDREFERENCE =
|
41
|
-
PDATATYPE =
|
42
|
-
PUNIT =
|
43
|
-
PSTATUS =
|
40
|
+
PCONSTRAINT = ODRLV.constraint.to_s
|
41
|
+
CCONSTRAINT = ODRLV.Constraint.to_s
|
42
|
+
PLEFT = ODRLV.leftOperand.to_s
|
43
|
+
PRIGHT = ODRLV.rightOperand.to_s
|
44
|
+
POPERATOR = ODRLV.operator.to_s
|
45
|
+
POPERANDREFERENCE = ODRLV.rightOperandReference.to_s
|
46
|
+
PDATATYPE = ODRLV.dataType.to_s
|
47
|
+
PUNIT = ODRLV.unit.to_s
|
48
|
+
PSTATUS = ODRLV.status.to_s
|
44
49
|
|
45
|
-
PPARTOF =
|
50
|
+
PPARTOF = ODRLV.partOf.to_s
|
46
51
|
|
47
52
|
|
48
53
|
PROPERTIES = {
|
@@ -79,21 +84,31 @@ module ODRL
|
|
79
84
|
return true
|
80
85
|
end
|
81
86
|
|
82
|
-
def initialize(
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
87
|
+
def initialize(
|
88
|
+
title: nil,
|
89
|
+
creator: nil,
|
90
|
+
description: nil,
|
91
|
+
subject: nil,
|
92
|
+
baseURI: "http://example.org",
|
93
|
+
uid:,
|
94
|
+
id: nil,
|
95
|
+
type:,
|
96
|
+
label: nil,
|
97
|
+
**_)
|
98
|
+
|
99
|
+
@title = title
|
100
|
+
@creator = creator
|
101
|
+
@description = description
|
102
|
+
@subject = subject
|
103
|
+
@baseURI = baseURI || ODRL::Base.baseURI
|
104
|
+
@uid = uid
|
105
|
+
@type = type
|
106
|
+
@label = label || @title
|
107
|
+
@id = @uid
|
95
108
|
|
96
109
|
raise "Every object must have a uid - attempt to create #{@type}" unless @uid
|
110
|
+
raise "Every object must have a type - " unless @type
|
111
|
+
|
97
112
|
|
98
113
|
$g = RDF::Graph.new()
|
99
114
|
if ENV["TRIPLES_FORMAT"]
|
@@ -101,23 +116,25 @@ module ODRL
|
|
101
116
|
else
|
102
117
|
$format = :jsonld
|
103
118
|
end
|
104
|
-
$writer = get_writer(type: $format) # set it by default
|
105
119
|
|
106
120
|
end
|
107
121
|
|
108
122
|
def get_writer(type:)
|
109
|
-
|
110
|
-
w.prefix(:foaf, RDF::URI.new("http://xmlns.com/foaf/0.1/"))
|
111
|
-
w.prefix(:dc, RDF::URI.new("http://purl.org/dc/terms/"))
|
112
|
-
w.prefix(:rdf, RDF::URI.new("http://www.w3.org/1999/02/22-rdf-syntax-ns#"))
|
113
|
-
w.prefix(:rdfs, RDF::URI.new("http://www.w3.org/2000/01/rdf-schema#"))
|
114
|
-
w.prefix(:vcard, RDF::URI.new("http://www.w3.org/2006/vcard/ns#"))
|
115
|
-
w.prefix(:odrl, RDF::URI.new("http://www.w3.org/ns/odrl/2/"))
|
116
|
-
w.prefix(:this, RDF::URI.new("http://w3id.org/FAIR_Training_LDP/DAV/home/LDP/DUC-CCE/IPGB#"))
|
117
|
-
w.prefix(:obo, RDF::URI.new("http://purl.obolibrary.org/obo/"))
|
118
|
-
w.prefix(:xsd, RDF::URI.new("http://www.w3.org/2001/XMLSchema#"))
|
119
|
-
|
120
|
-
|
123
|
+
w = RDF::Writer.for(type)
|
124
|
+
# w.prefix(:foaf, RDF::URI.new("http://xmlns.com/foaf/0.1/"))
|
125
|
+
# w.prefix(:dc, RDF::URI.new("http://purl.org/dc/terms/"))
|
126
|
+
# w.prefix(:rdf, RDF::URI.new("http://www.w3.org/1999/02/22-rdf-syntax-ns#"))
|
127
|
+
# w.prefix(:rdfs, RDF::URI.new("http://www.w3.org/2000/01/rdf-schema#"))
|
128
|
+
# w.prefix(:vcard, RDF::URI.new("http://www.w3.org/2006/vcard/ns#"))
|
129
|
+
# w.prefix(:odrl, RDF::URI.new("http://www.w3.org/ns/odrl/2/"))
|
130
|
+
# w.prefix(:this, RDF::URI.new("http://w3id.org/FAIR_Training_LDP/DAV/home/LDP/DUC-CCE/IPGB#"))
|
131
|
+
# w.prefix(:obo, RDF::URI.new("http://purl.obolibrary.org/obo/"))
|
132
|
+
# w.prefix(:xsd, RDF::URI.new("http://www.w3.org/2001/XMLSchema#"))
|
133
|
+
# w.prefix(:orcid, RDF::URI.new("https://orcid.org/"))
|
134
|
+
# warn "W"
|
135
|
+
# warn w.prefixes.inspect
|
136
|
+
|
137
|
+
return w
|
121
138
|
end
|
122
139
|
|
123
140
|
def triplify(s, p, o, repo)
|
@@ -174,7 +191,7 @@ module ODRL
|
|
174
191
|
end
|
175
192
|
|
176
193
|
def load_graph
|
177
|
-
[:title, :label, :creator, :description, :subject, :uid, :type].each do |method|
|
194
|
+
[:title, :label, :creator, :description, :subject, :uid, :id, :type].each do |method|
|
178
195
|
next unless self.send(method)
|
179
196
|
next if self.send(method).empty?
|
180
197
|
subject = self.uid
|
@@ -188,7 +205,8 @@ module ODRL
|
|
188
205
|
|
189
206
|
def serialize(format: $format)
|
190
207
|
format = format.to_sym
|
191
|
-
|
208
|
+
w = get_writer(type: format)
|
209
|
+
return w.dump(self.repository)
|
192
210
|
end
|
193
211
|
|
194
212
|
private
|
data/lib/odrl/constraint.rb
CHANGED
@@ -5,31 +5,40 @@ module ODRL
|
|
5
5
|
class Constraint < Base
|
6
6
|
|
7
7
|
attr_accessor :uid, :rightOperand, :leftOperand, :operator, :rightOperandReference, :dataType, :unit, :status
|
8
|
-
def initialize(
|
9
|
-
|
8
|
+
def initialize(
|
9
|
+
uid: nil,
|
10
|
+
rightOperand:,
|
11
|
+
operator:,
|
12
|
+
leftOperand:,
|
13
|
+
rightOPerandReference: nil,
|
14
|
+
dataType: nil,
|
15
|
+
unit: nil,
|
16
|
+
status: nil,
|
17
|
+
type: CCONSTRAINT,
|
18
|
+
**args)
|
19
|
+
|
20
|
+
@uid = uid
|
10
21
|
unless @uid
|
11
22
|
@uid = Base.baseURI + "#constraint_" + Base.getuuid
|
12
23
|
end
|
13
|
-
super(
|
14
|
-
|
15
|
-
self.type = "http://www.w3.org/ns/odrl/2/Constraint"
|
24
|
+
super(uid: @uid, type: type, **args)
|
16
25
|
|
17
|
-
@rightOperand =
|
26
|
+
@rightOperand = rightOperand
|
18
27
|
raise "Constraints must haves a Right operand such as 'event' - I'm dead!" unless @rightOperand
|
19
28
|
@rightOperand = "http://www.w3.org/ns/odrl/2/#{@rightOperand}" unless @rightOperand =~ /https?:\/\// # if it is already a URI, then let it go
|
20
29
|
|
21
|
-
@leftOperand =
|
30
|
+
@leftOperand = leftOperand
|
22
31
|
raise "Constraints must haves a Left Operand such as 'http://some.event.org/on-now' - I'm dead!" unless @leftOperand
|
23
32
|
@leftOperand = "http://www.w3.org/ns/odrl/2/#{@leftOperand}" unless @leftOperand =~ /https?:\/\// # if it is already a URI, then let it go
|
24
33
|
|
25
|
-
@operator =
|
34
|
+
@operator = operator
|
26
35
|
raise "Constraints must haves an operator such as 'eq' - I'm dead!" unless @operator
|
27
36
|
@operator = "http://www.w3.org/ns/odrl/2/#{@operator}" unless @operator =~ /https?:\/\// # if it is already a URI, then let it go
|
28
37
|
|
29
|
-
@rightOperandReference =
|
30
|
-
@dataType =
|
31
|
-
@unit =
|
32
|
-
@status =
|
38
|
+
@rightOperandReference = rightOperandReference
|
39
|
+
@dataType = dataType
|
40
|
+
@unit = unit
|
41
|
+
@status = status
|
33
42
|
end
|
34
43
|
|
35
44
|
def load_graph
|
data/lib/odrl/odrl/version.rb
CHANGED
data/lib/odrl/party.rb
CHANGED
@@ -4,19 +4,25 @@ module ODRL
|
|
4
4
|
|
5
5
|
class Party < Base
|
6
6
|
attr_accessor :uid, :refinements, :partOf, :predicate, :type
|
7
|
-
def initialize(
|
8
|
-
|
7
|
+
def initialize(
|
8
|
+
uid: nil,
|
9
|
+
refinements: nil,
|
10
|
+
partOf: nil,
|
11
|
+
predicate: nil,
|
12
|
+
type: CPARTY,
|
13
|
+
**args
|
14
|
+
)
|
15
|
+
|
16
|
+
@uid = uid
|
9
17
|
unless @uid
|
10
18
|
@uid = Base.baseURI + "#party_" + Base.getuuid
|
11
19
|
end
|
12
|
-
super(
|
13
|
-
self.type="http://www.w3.org/ns/odrl/2/Party"
|
20
|
+
super(uid: @uid, type: type, **args)
|
14
21
|
|
15
22
|
|
16
23
|
@refinements = Hash.new
|
17
|
-
@partOf =
|
18
|
-
@predicate =
|
19
|
-
@type = CPARTY
|
24
|
+
@partOf = partOf
|
25
|
+
@predicate = predicate
|
20
26
|
|
21
27
|
unless @predicate
|
22
28
|
raise "If you don't indicate a predicate (assigner/assignee) we will default to assigner. This may not be what you want!"
|
@@ -30,9 +36,9 @@ module ODRL
|
|
30
36
|
|
31
37
|
|
32
38
|
|
33
|
-
|
34
|
-
if !(
|
35
|
-
|
39
|
+
refinements = [refinements] unless refinements.is_a? Array
|
40
|
+
if !(refinements.first.nil?)
|
41
|
+
refinements.each do |c|
|
36
42
|
self.addRefinement(refinement: c)
|
37
43
|
end
|
38
44
|
end
|
@@ -85,9 +91,8 @@ module ODRL
|
|
85
91
|
end
|
86
92
|
class PartyCollection < Party
|
87
93
|
|
88
|
-
def initialize(args)
|
89
|
-
super(args)
|
90
|
-
self.type = "http://www.w3.org/ns/odrl/2/PartyCollection"
|
94
|
+
def initialize(type: CPARTYCOLLECTION, **args)
|
95
|
+
super(type: type, **args)
|
91
96
|
end
|
92
97
|
end
|
93
98
|
|
data/lib/odrl/policy.rb
CHANGED
@@ -9,12 +9,12 @@ module ODRL
|
|
9
9
|
class Policy < Base
|
10
10
|
attr_accessor :rules
|
11
11
|
|
12
|
-
def initialize(args)
|
13
|
-
@uid =
|
12
|
+
def initialize(uid: nil, type: CPOLICY, **args)
|
13
|
+
@uid = uid
|
14
14
|
unless @uid
|
15
15
|
self.uid = Base.baseURI + "#policy_" + Base.getuuid
|
16
16
|
end
|
17
|
-
super(
|
17
|
+
super(uid: @uid, type: type, **args)
|
18
18
|
|
19
19
|
@rules = Hash.new
|
20
20
|
end
|
@@ -53,24 +53,30 @@ module ODRL
|
|
53
53
|
end
|
54
54
|
|
55
55
|
class Set < Policy
|
56
|
-
def initialize(args)
|
57
|
-
super(
|
56
|
+
def initialize(type: CSET, **args)
|
57
|
+
super(type: type, **args)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
class Offer < Set
|
62
|
-
def initialize(args)
|
63
|
-
super(
|
62
|
+
def initialize(type: COFFER, **args)
|
63
|
+
super(type: type, **args)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
class Agreement < Set
|
67
|
-
def initialize(args)
|
68
|
-
super(
|
67
|
+
def initialize(type: CAGREEMENT, **args)
|
68
|
+
super(type: type, **args)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
class Request < Set
|
72
|
-
def initialize(args)
|
73
|
-
super(
|
72
|
+
def initialize(type: CREQUEST, **args)
|
73
|
+
super(type: type, **args)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class Privacy < Set
|
78
|
+
def initialize(type: CPRIVACY, **args)
|
79
|
+
super(type: type, **args)
|
74
80
|
end
|
75
81
|
end
|
76
82
|
# ====================================================
|
data/lib/odrl/rule.rb
CHANGED
@@ -7,13 +7,22 @@ require_relative "odrl/version"
|
|
7
7
|
module ODRL
|
8
8
|
class Rule < Base
|
9
9
|
attr_accessor :uid, :constraints, :assets, :predicate, :type, :action, :assigner, :assignee
|
10
|
-
def initialize(
|
11
|
-
|
10
|
+
def initialize(
|
11
|
+
uid: nil,
|
12
|
+
constraints: nil,
|
13
|
+
assets: nil,
|
14
|
+
predicate: nil,
|
15
|
+
action: nil,
|
16
|
+
assigner: nil,
|
17
|
+
assignee: nil,
|
18
|
+
type: CRULE,
|
19
|
+
**args)
|
20
|
+
@uid = uid
|
12
21
|
|
13
22
|
unless @uid
|
14
23
|
@uid = Base.baseURI + "#rule_" + Base.getuuid
|
15
24
|
end
|
16
|
-
super(
|
25
|
+
super(uid: @uid, type: type, **args)
|
17
26
|
|
18
27
|
@constraints = Hash.new
|
19
28
|
@assets = Hash.new
|
@@ -21,15 +30,15 @@ module ODRL
|
|
21
30
|
@assignee = Hash.new
|
22
31
|
@action = Hash.new
|
23
32
|
|
24
|
-
|
25
|
-
if !
|
26
|
-
|
33
|
+
assets = [assets] unless assets.is_a? Array
|
34
|
+
if !assets.first.nil?
|
35
|
+
assets.each do |c|
|
27
36
|
self.addAsset(asset: c)
|
28
37
|
end
|
29
38
|
end
|
30
|
-
|
31
|
-
if !
|
32
|
-
|
39
|
+
constraints = [constraints] unless constraints.is_a? Array
|
40
|
+
if !constraints.first.nil?
|
41
|
+
constraints.each do |c|
|
33
42
|
self.addConstraint(constraint: c)
|
34
43
|
end
|
35
44
|
end
|
@@ -99,32 +108,20 @@ module ODRL
|
|
99
108
|
|
100
109
|
|
101
110
|
class Permission < Rule
|
102
|
-
def initialize(args)
|
103
|
-
super(args)
|
104
|
-
self.predicate = PPERMISSION
|
105
|
-
self.type = CPERMISSION
|
106
|
-
|
107
|
-
|
111
|
+
def initialize(predicate: PPERMISSION, type: CPERMISSION, **args)
|
112
|
+
super(predicate: predicate, type: type, **args)
|
108
113
|
end
|
109
114
|
end
|
110
115
|
|
111
116
|
class Duty < Rule
|
112
|
-
def initialize(args)
|
113
|
-
super(args)
|
114
|
-
self.predicate = PDUTY
|
115
|
-
self.type = CDUTY
|
116
|
-
|
117
|
-
|
117
|
+
def initialize(predicate: PDUTY, type: CDUTY, **args)
|
118
|
+
super(predicate: predicate, type: type, **args)
|
118
119
|
end
|
119
120
|
end
|
120
121
|
|
121
122
|
class Prohibition < Rule
|
122
|
-
def initialize(args)
|
123
|
-
super(args)
|
124
|
-
self.predicate = PPROHIBITION
|
125
|
-
self.type = CPROHIBITION
|
126
|
-
|
127
|
-
|
123
|
+
def initialize(predicate: PPROHIBITION, type: CPROHIBITION, **args)
|
124
|
+
super(predicate: predicate, type: type, **args)
|
128
125
|
end
|
129
126
|
end
|
130
127
|
|
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.1.
|
4
|
+
version: 0.1.4
|
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-06-
|
11
|
+
date: 2023-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: builds ODRL files nicely.
|
14
14
|
email:
|
@@ -47,6 +47,7 @@ metadata:
|
|
47
47
|
homepage_uri: https://example.org
|
48
48
|
source_code_uri: https://github.com/markwilkinson/ODRL-RUBY
|
49
49
|
changelog_uri: https://github.com/markwilkinson/ODRL-RUBY/blob/master/CHANGELOG.md
|
50
|
+
documentation_uri: https://www.rubydoc.info/gems/odrl-ruby/
|
50
51
|
post_install_message:
|
51
52
|
rdoc_options: []
|
52
53
|
require_paths:
|