odrl-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cb0c189a2525a3571135dcf826b1564c4fe2b7cba12cb1da11070b14b02b8d7f
4
+ data.tar.gz: 8fd96e53f85538edaf482bb8a3a70fc2f41963e1e33815ce86dc07385d8c6ad8
5
+ SHA512:
6
+ metadata.gz: 73442b39ecdfa15aa2a1e5901916bc6302bc3af4b29b445f452982fa395cc10b272ed360b50262e350eaf3f5f748e7492b3a8293841baf82035ededb1abb986f
7
+ data.tar.gz: 2dd24c86e07382a59f47cfc50a1c047a948328c47e19ca499c68afc988ce74d3141d8d8522ce368adc5af3439cbe3bb871dbed3d0e357d1cff9117b387adf551
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-03-15
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in odrl-ruby.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+ gem "linkeddata", "~> 3.2.0"
10
+ gem "rubocop", "~> 1.21"
11
+ gem "rspec", "~> 3.11.0"
12
+ gem "rdf-raptor", "~> 3.2.0"
13
+ # gem "ruby-debug-ide"
data/Gemfile.lock ADDED
@@ -0,0 +1,235 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ odrl-ruby (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ addressable (2.8.0)
10
+ public_suffix (>= 2.0.2, < 5.0)
11
+ amazing_print (1.4.0)
12
+ ast (2.4.2)
13
+ bcp47 (0.3.3)
14
+ i18n
15
+ builder (3.2.4)
16
+ concurrent-ruby (1.1.9)
17
+ connection_pool (2.2.5)
18
+ diff-lcs (1.5.0)
19
+ ebnf (2.3.1)
20
+ amazing_print (~> 1.4)
21
+ htmlentities (~> 4.3)
22
+ rdf (~> 3.2)
23
+ scanf (~> 1.0)
24
+ sxp (~> 1.2)
25
+ unicode-types (~> 1.7)
26
+ ffi (1.15.5)
27
+ haml (5.2.2)
28
+ temple (>= 0.8.0)
29
+ tilt
30
+ hamster (3.0.0)
31
+ concurrent-ruby (~> 1.0)
32
+ htmlentities (4.3.4)
33
+ i18n (1.10.0)
34
+ concurrent-ruby (~> 1.0)
35
+ json-canonicalization (0.3.0)
36
+ json-ld (3.2.0)
37
+ htmlentities (~> 4.3)
38
+ json-canonicalization (~> 0.3)
39
+ link_header (~> 0.0, >= 0.0.8)
40
+ multi_json (~> 1.15)
41
+ rack (~> 2.2)
42
+ rdf (~> 3.2)
43
+ json-ld-preloaded (3.2.0)
44
+ json-ld (~> 3.2)
45
+ rdf (~> 3.2)
46
+ ld-patch (3.2.0)
47
+ ebnf (~> 2.2)
48
+ rdf (~> 3.2)
49
+ rdf-xsd (~> 3.2)
50
+ sparql (~> 3.2)
51
+ sxp (~> 1.2)
52
+ link_header (0.0.8)
53
+ linkeddata (3.2.0)
54
+ json-ld (~> 3.2)
55
+ json-ld-preloaded (~> 3.2)
56
+ ld-patch (~> 3.2)
57
+ nokogiri (~> 1.12, >= 1.12.5)
58
+ rdf (~> 3.2)
59
+ rdf-aggregate-repo (~> 3.2)
60
+ rdf-hamster-repo (~> 3.2)
61
+ rdf-isomorphic (~> 3.2)
62
+ rdf-json (~> 3.2)
63
+ rdf-microdata (~> 3.2)
64
+ rdf-n3 (~> 3.2)
65
+ rdf-normalize (~> 0.5)
66
+ rdf-ordered-repo (~> 3.2)
67
+ rdf-rdfa (~> 3.2)
68
+ rdf-rdfxml (~> 3.2)
69
+ rdf-reasoner (~> 0.8)
70
+ rdf-tabular (~> 3.2)
71
+ rdf-trig (~> 3.2)
72
+ rdf-trix (~> 3.2)
73
+ rdf-turtle (~> 3.2)
74
+ rdf-vocab (~> 3.2)
75
+ rdf-xsd (~> 3.2)
76
+ shacl (~> 0.2)
77
+ shex (~> 0.7)
78
+ sparql (~> 3.2)
79
+ sparql-client (~> 3.2)
80
+ logger (1.5.0)
81
+ matrix (0.4.2)
82
+ multi_json (1.15.0)
83
+ net-http-persistent (4.0.1)
84
+ connection_pool (~> 2.2)
85
+ nokogiri (1.13.3-x86_64-linux)
86
+ racc (~> 1.4)
87
+ parallel (1.21.0)
88
+ parser (3.1.1.0)
89
+ ast (~> 2.4.1)
90
+ public_suffix (4.0.6)
91
+ racc (1.6.0)
92
+ rack (2.2.3)
93
+ rainbow (3.1.1)
94
+ rake (13.0.6)
95
+ rdf (3.2.6)
96
+ link_header (~> 0.0, >= 0.0.8)
97
+ rdf-aggregate-repo (3.2.0)
98
+ rdf (~> 3.2)
99
+ rdf-hamster-repo (3.2.1)
100
+ hamster (~> 3.0)
101
+ rdf (~> 3.2, >= 3.2.1)
102
+ rdf-isomorphic (3.2.1)
103
+ rdf (~> 3.2)
104
+ rdf-json (3.2.0)
105
+ rdf (~> 3.2)
106
+ rdf-microdata (3.2.1)
107
+ htmlentities (~> 4.3)
108
+ nokogiri (~> 1.13)
109
+ rdf (~> 3.2)
110
+ rdf-rdfa (~> 3.2)
111
+ rdf-xsd (~> 3.2)
112
+ rdf-n3 (3.2.1)
113
+ ebnf (~> 2.2)
114
+ rdf (~> 3.2)
115
+ sparql (~> 3.2)
116
+ sxp (~> 1.2)
117
+ rdf-normalize (0.5.0)
118
+ rdf (~> 3.2)
119
+ rdf-ordered-repo (3.2.1)
120
+ rdf (~> 3.2, >= 3.2.1)
121
+ rdf-raptor (3.2.0)
122
+ ffi (~> 1.15)
123
+ rdf (~> 3.2)
124
+ rdf-rdfa (3.2.0)
125
+ haml (~> 5.2)
126
+ htmlentities (~> 4.3)
127
+ rdf (~> 3.2)
128
+ rdf-aggregate-repo (~> 3.2)
129
+ rdf-vocab (~> 3.2)
130
+ rdf-xsd (~> 3.2)
131
+ rdf-rdfxml (3.2.0)
132
+ htmlentities (~> 4.3)
133
+ rdf (~> 3.2)
134
+ rdf-rdfa (~> 3.2)
135
+ rdf-xsd (~> 3.2)
136
+ rdf-reasoner (0.8.0)
137
+ rdf (~> 3.2)
138
+ rdf-xsd (~> 3.2)
139
+ rdf-tabular (3.2.0)
140
+ addressable (~> 2.8)
141
+ bcp47 (~> 0.3, >= 0.3.3)
142
+ json-ld (~> 3.2)
143
+ rdf (~> 3.2)
144
+ rdf-vocab (~> 3.2)
145
+ rdf-xsd (~> 3.2)
146
+ rdf-trig (3.2.0)
147
+ ebnf (~> 2.2)
148
+ rdf (~> 3.2)
149
+ rdf-turtle (~> 3.2)
150
+ rdf-trix (3.2.0)
151
+ rdf (~> 3.2)
152
+ rdf-xsd (~> 3.2)
153
+ rdf-turtle (3.2.0)
154
+ ebnf (~> 2.3)
155
+ rdf (~> 3.2)
156
+ rdf-vocab (3.2.1)
157
+ rdf (~> 3.2, >= 3.2.4)
158
+ rdf-xsd (3.2.1)
159
+ rdf (~> 3.2)
160
+ rexml (~> 3.2)
161
+ regexp_parser (2.2.1)
162
+ rexml (3.2.5)
163
+ rspec (3.11.0)
164
+ rspec-core (~> 3.11.0)
165
+ rspec-expectations (~> 3.11.0)
166
+ rspec-mocks (~> 3.11.0)
167
+ rspec-core (3.11.0)
168
+ rspec-support (~> 3.11.0)
169
+ rspec-expectations (3.11.0)
170
+ diff-lcs (>= 1.2.0, < 2.0)
171
+ rspec-support (~> 3.11.0)
172
+ rspec-mocks (3.11.0)
173
+ diff-lcs (>= 1.2.0, < 2.0)
174
+ rspec-support (~> 3.11.0)
175
+ rspec-support (3.11.0)
176
+ rubocop (1.26.0)
177
+ parallel (~> 1.10)
178
+ parser (>= 3.1.0.0)
179
+ rainbow (>= 2.2.2, < 4.0)
180
+ regexp_parser (>= 1.8, < 3.0)
181
+ rexml
182
+ rubocop-ast (>= 1.16.0, < 2.0)
183
+ ruby-progressbar (~> 1.7)
184
+ unicode-display_width (>= 1.4.0, < 3.0)
185
+ rubocop-ast (1.16.0)
186
+ parser (>= 3.1.1.0)
187
+ ruby-progressbar (1.11.0)
188
+ scanf (1.0.0)
189
+ shacl (0.2.1)
190
+ json-ld (~> 3.2)
191
+ rdf (~> 3.2)
192
+ sparql (~> 3.2)
193
+ sxp (~> 1.2)
194
+ shex (0.7.1)
195
+ ebnf (~> 2.2)
196
+ htmlentities (~> 4.3)
197
+ json-ld (~> 3.2)
198
+ json-ld-preloaded (~> 3.2)
199
+ rdf (~> 3.2)
200
+ rdf-xsd (~> 3.2)
201
+ sparql (~> 3.2)
202
+ sxp (~> 1.2)
203
+ sparql (3.2.1)
204
+ builder (~> 3.2)
205
+ ebnf (~> 2.2)
206
+ logger (~> 1.4)
207
+ rdf (~> 3.2, >= 3.2.3)
208
+ rdf-aggregate-repo (~> 3.2)
209
+ rdf-xsd (~> 3.2)
210
+ sparql-client (~> 3.2)
211
+ sxp (~> 1.2, >= 1.2.1)
212
+ sparql-client (3.2.0)
213
+ net-http-persistent (~> 4.0, >= 4.0.1)
214
+ rdf (~> 3.2)
215
+ sxp (1.2.2)
216
+ matrix
217
+ rdf (~> 3.2)
218
+ temple (0.8.2)
219
+ tilt (2.0.10)
220
+ unicode-display_width (2.1.0)
221
+ unicode-types (1.7.0)
222
+
223
+ PLATFORMS
224
+ x86_64-linux
225
+
226
+ DEPENDENCIES
227
+ linkeddata (~> 3.2.0)
228
+ odrl-ruby!
229
+ rake (~> 13.0)
230
+ rdf-raptor (~> 3.2.0)
231
+ rspec (~> 3.11.0)
232
+ rubocop (~> 1.21)
233
+
234
+ BUNDLED WITH
235
+ 2.2.31
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # THIS IS NOT READY FOR USE! ...SO DON'T! :-)
2
+
3
+ # ODRL::Ruby
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/odrl/ruby`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ TODO: Delete this and the text above, and describe your gem
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'odrl-ruby'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle install
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install odrl-ruby
24
+
25
+ ## Usage
26
+
27
+ TODO: Write usage instructions here
28
+
29
+ ## Development
30
+
31
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
32
+
33
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/odrl-ruby.
38
+
39
+ ## License
40
+
41
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rubocop/rake_task"
5
+
6
+ RuboCop::RakeTask.new
7
+
8
+ task default: :rubocop
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "odrl/ruby"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,44 @@
1
+ require 'odrl/ruby'
2
+
3
+
4
+ # an offer to toshiaki from mark to use the polyA resource during the biohackathon
5
+
6
+ # core annotatons are: :title, :creator, :description, :subject :baseURI, :uid, :type
7
+ policy = ODRL::Offer.new(
8
+ title: "Offer to Toshiaki-san",
9
+ creator: "https://orcid.org/0000-0001-6960-357X",
10
+ description: "An offer for Toshiaki-san to use the polyA data during the hackathon",
11
+ subject: "collaboration", # this is the CCE category
12
+ )
13
+
14
+ asset = ODRL::Asset.new(uid: "http://mark.wilkinson.org/data/polyA", title: "Mark's PolyA Database")
15
+
16
+ # you indicate the type of party by assigning the predicate (either assigner or assignee)
17
+ # ODRLV is the RDF::Vocabulary for ODRL, exported to this namespace
18
+ mark = ODRL::Party.new(uid: "https://orcid.org/0000-0001-6960-357X", predicate: ODRLV.assigner, title: "Mark D Wilkinson" )
19
+ toshiaki = ODRL::Party.new(uid: "https://orcid.org/0000-0003-2391-0384", predicate: ODRLV.assignee, title: "Toshiaki Katayama")
20
+
21
+ # Rules
22
+ permission = ODRL::Permission.new(title: "Permission to use")
23
+
24
+ use = ODRL::Use.new(value: "use") # subclass of action
25
+
26
+ # Constraints: :uid, :rightOperand, :leftOperand, :operator, :rightOperandReference, :dataType, :unit, :status
27
+ constraint = ODRL::Constraint.new(
28
+ title: "Only during the hackathon",
29
+ leftOperand: "event",
30
+ operator: "eq",
31
+ rightOperand: "https://2023.biohackathon.org"
32
+ )
33
+ permission.addConstraint(constraint: constraint)
34
+ permission.addAsset(asset: asset)
35
+ permission.addAssigner(party: toshiaki)
36
+ permission.addAssignee(party: mark)
37
+ permission.addAction(action: use)
38
+
39
+ policy.addPermission(rule: permission)
40
+
41
+ policy.load_graph
42
+ result = policy.serialize(format: 'turtle')
43
+ puts result
44
+
data/launch.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "RSpec - all",
3
+ "type": "Ruby",
4
+ "request": "launch",
5
+ "cwd": "${workspaceRoot}",
6
+ "program": "/home/osboxes/.rvm/rubies/ruby-3.0.0/bin/rspec",
7
+ "args": [
8
+ "-I",
9
+ "${workspaceRoot}"
10
+ ]
11
+ }
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ODRL
4
+
5
+ class Action < Base
6
+ attr_accessor :uid, :refinements, :predicate, :type, :value, :vallabel
7
+ def initialize(args)
8
+ @value = args[:value]
9
+ @vallabel = args[:value]
10
+ raise "Actions must haves a value such as 'use' - I'm dead!" unless @value
11
+ @value = "http://www.w3.org/ns/odrl/2/#{@value}" unless @value =~ /http:\/\// # if it is already a URI, then let it go
12
+
13
+ @uid = @value
14
+ # unless @uid
15
+ # self.uid = Base.baseURI + "#action_" + Base.getuuid
16
+ # end
17
+ super(args.merge({uid: @uid}))
18
+
19
+ self.type="http://www.w3.org/ns/odrl/2/Action"
20
+
21
+ @refinements = Hash.new
22
+
23
+ args[:refinements] = [args[:refinements]] unless args[:refinements].is_a? Array
24
+ if !(args[:refinements].first.nil?)
25
+ args[:refinements].each do |c|
26
+ self.addRefinement(refinement: c)
27
+ end
28
+ end
29
+
30
+ self.predicate = PACTION unless self.predicate
31
+
32
+ end
33
+
34
+ def addRefinement(refinement: args)
35
+ unless refinement.is_a?(Constraint)
36
+ raise "Refinement is not an ODRL Constraint"
37
+ else
38
+ self.refinements[refinement.uid] = [PREFINEMENT, refinement]
39
+ end
40
+ end
41
+
42
+
43
+ def load_graph
44
+ super
45
+ # TODO This is bad DRY!! Put the bulk of this method into the base object
46
+ [:refinements].each do |connected_object_type|
47
+ next unless self.send(connected_object_type)
48
+ self.send(connected_object_type).each do |uid, typedconnection|
49
+ predicate, odrlobject = typedconnection # e.g. "refinement", RefinementObject
50
+ object = odrlobject.uid
51
+ subject = self.uid
52
+ repo = self.repository
53
+ triplify(subject, predicate, object, repo)
54
+ odrlobject.load_graph # start the cascade
55
+ end
56
+ end
57
+ subject = self.uid
58
+ object = self.vallabel
59
+ predicate = SCHEMA.name
60
+ repo = self.repository
61
+ triplify(subject, predicate, object, repo)
62
+ object = self.vallabel
63
+ predicate = RDFS.label
64
+ repo = self.repository
65
+ triplify(subject, predicate, object, repo)
66
+ end
67
+
68
+ def serialize
69
+ super
70
+ end
71
+
72
+ end
73
+
74
+
75
+
76
+ class Use < Action
77
+ def initialize(args)
78
+ super(args)
79
+ self.type = "http://www.w3.org/ns/odrl/2/Action" unless self.type
80
+ end
81
+ end
82
+ class Transfer < Action
83
+ def initialize(args)
84
+ super(args)
85
+ self.type = "http://www.w3.org/ns/odrl/2/Action" unless self.type
86
+ end
87
+ end
88
+
89
+ end
data/lib/odrl/asset.rb ADDED
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ODRL
4
+
5
+ class Asset < Base
6
+ attr_accessor :uid, :hasPolicy, :refinements, :partOf
7
+
8
+ def initialize(args)
9
+ @uid = args[:uid]
10
+ unless @uid
11
+ self.uid = Base.baseURI + "#asset_" + Base.getuuid
12
+ end
13
+ super(args.merge({uid: @uid}))
14
+ self.type="http://www.w3.org/ns/odrl/2/Asset"
15
+
16
+ @refinements = Hash.new
17
+ @partOf = args[:partOf]
18
+ @hasPolicy = args[:hasPolicy]
19
+
20
+ if @hasPolicy and !(@hasPolicy.is_a? Policy) # if it exists and is the wrong type
21
+ raise "The policy of an Asset must be of type ODRL::Policy. The provided value will be discarded"
22
+ @hasPolicy = nil
23
+ end
24
+ if @partOf and !(@partOf.is_a? AssetCollection) # if it exists and is the wrong type
25
+ raise "The parent collection of an Asset must be of type ODRL::AssetCollection. The provided value will be discarded"
26
+ @partOf = nil
27
+ end
28
+
29
+ args[:refinements] = [args[:refinements]] unless args[:refinements].is_a? Array
30
+ if !(args[:refinements].first.nil?)
31
+ args[:refinements].each do |c|
32
+ self.addRefinement(refinement: c)
33
+ end
34
+ end
35
+ end
36
+
37
+
38
+ def addPart(part: args)
39
+ unless self.is_a?(AssetCollection)
40
+ raise "Asset cannot be added as part of something that is not an asset collection"
41
+ end
42
+ unless part.is_a?(Asset)
43
+ raise "Only Assets can be added as part of asset collections"
44
+ end
45
+ part.partOf[self.uid] = [PPARTOF, self]
46
+ end
47
+
48
+ def addRefinement(refinement: args)
49
+ unless refinement.is_a?(Constraint)
50
+ raise "Refinement is not an ODRL Constraint"
51
+ else
52
+ self.refinements[refinement.uid] = [PREFINEMENT, refinement]
53
+ end
54
+ end
55
+
56
+ def load_graph
57
+ super
58
+ # TODO This is bad DRY!! Put the bulk of this method into the base object
59
+ [:refinements, :partOf, :hasPolicy].each do |connected_object_type|
60
+ next unless self.send(connected_object_type)
61
+ self.send(connected_object_type).each do |uid, typedconnection|
62
+ predicate, odrlobject = typedconnection # e.g. "refinement", RefinementObject
63
+ object = odrlobject.uid
64
+ subject = self.uid
65
+ repo = self.repository
66
+ triplify(subject, predicate, object, repo)
67
+ odrlobject.load_graph # start the cascade
68
+ end
69
+ end
70
+ end
71
+
72
+ def serialize(format:)
73
+ super
74
+ end
75
+
76
+ end
77
+
78
+ class AssetCollection < Asset
79
+
80
+ def initialize(args)
81
+ super(args)
82
+ self.type="http://www.w3.org/ns/odrl/2/AssetCollection"
83
+ end
84
+ end
85
+
86
+
87
+ end
data/lib/odrl/base.rb ADDED
@@ -0,0 +1,195 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "odrl/version"
4
+
5
+ # one day move these all to ODRLV.xxxx
6
+ CPOLICY= "http://www.w3.org/ns/odrl/2/Policy"
7
+
8
+ CSET= "http://www.w3.org/ns/odrl/2/Set"
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"
12
+
13
+ PASSET = "http://www.w3.org/ns/odrl/2/target"
14
+ CASSET= "http://www.w3.org/ns/odrl/2/Asset"
15
+
16
+ CPERMISSION= "http://www.w3.org/ns/odrl/2/Permission"
17
+ PPERMISSION = "http://www.w3.org/ns/odrl/2/permission"
18
+ CPROHIBITION= "http://www.w3.org/ns/odrl/2/Prohibition"
19
+ PPROHIBITION = "http://www.w3.org/ns/odrl/2/prohibition"
20
+ PDUTY= "http://www.w3.org/ns/odrl/2/obligation"
21
+ CDUTY = "http://www.w3.org/ns/odrl/2/Duty"
22
+
23
+ PRULE = "http://www.w3.org/ns/odrl/2/Rule"
24
+
25
+
26
+ PACTION = "http://www.w3.org/ns/odrl/2/action"
27
+ CACTION= "http://www.w3.org/ns/odrl/2/Action"
28
+
29
+ PREFINEMENT = "http://www.w3.org/ns/odrl/2/refinement"
30
+
31
+ PASSIGNER = "http://www.w3.org/ns/odrl/2/assigner"
32
+ PASSIGNEE = "http://www.w3.org/ns/odrl/2/assignee"
33
+ CPARTY= "http://www.w3.org/ns/odrl/2/Party"
34
+
35
+ PCONSTRAINT = "http://www.w3.org/ns/odrl/2/constraint"
36
+ CCONSTRAINT = "http://www.w3.org/ns/odrl/2/Constraint"
37
+ PLEFT = "http://www.w3.org/ns/odrl/2/leftOperand"
38
+ PRIGHT = "http://www.w3.org/ns/odrl/2/rightOperand"
39
+ POPERATOR = "http://www.w3.org/ns/odrl/2/operator"
40
+ POPERANDREFERENCE = "http://www.w3.org/ns/odrl/2/rightOperandReference"
41
+ PDATATYPE = "http://www.w3.org/ns/odrl/2/dataType"
42
+ PUNIT = "http://www.w3.org/ns/odrl/2/unit"
43
+ PSTATUS = "http://www.w3.org/ns/odrl/2/status"
44
+
45
+ PPARTOF = "http://www.w3.org/ns/odrl/2/partOf"
46
+
47
+
48
+ PROPERTIES = {
49
+ title: DCT.title,
50
+ creator: DCT.creator,
51
+ description: DCT.description,
52
+ uid: DCT.identifier,
53
+ type: RDF.type,
54
+ subject: DCT.subject
55
+
56
+ }
57
+
58
+ module ODRL
59
+ class Base
60
+
61
+ @@repository = RDF::Repository.new()
62
+
63
+ attr_accessor :title, :creator, :description, :subject, :baseURI, :uid, :type
64
+
65
+ def self.baseURI
66
+ return ENV['ODRL_BASEURI'] || "http://example.org"
67
+ end
68
+
69
+ def self.repository
70
+ return @@repository
71
+ end
72
+ def repository
73
+ return @@repository
74
+ end
75
+
76
+ def self.clear_repository
77
+ @@repository.clear!
78
+ return true
79
+ end
80
+
81
+ def initialize(args)
82
+ #args = defaults.merge(args)
83
+
84
+ @title = args[:title]
85
+ @creator = args[:creator]
86
+ @description = args[:description]
87
+ @subject = args[:subject]
88
+ @baseURI = args[:baseURI] || self.baseURI
89
+ @uid = args[:uid]
90
+ @type = args[:type]
91
+ #@repository = RDF::Repository.new() unless self.repository
92
+
93
+ raise "Every object must have a uid - attempt to create #{@type}" unless @uid
94
+
95
+ $g = RDF::Graph.new()
96
+ if ENV["TRIPLES_FORMAT"]
97
+ $format = ENV["TRIPLES_FORMAT"].to_sym
98
+ else
99
+ $format = :jsonld
100
+ end
101
+ $writer = get_writer(type: $format) # set it by default
102
+
103
+ end
104
+
105
+ def get_writer(type:)
106
+ $writer = RDF::Writer.for(type).buffer do |w|
107
+ w.prefix(:foaf, RDF::URI.new("http://xmlns.com/foaf/0.1/"))
108
+ w.prefix(:dc, RDF::URI.new("http://purl.org/dc/terms/"))
109
+ w.prefix(:rdf, RDF::URI.new("http://www.w3.org/1999/02/22-rdf-syntax-ns#"))
110
+ w.prefix(:rdfs, RDF::URI.new("http://www.w3.org/2000/01/rdf-schema#"))
111
+ w.prefix(:vcard, RDF::URI.new("http://www.w3.org/2006/vcard/ns#"))
112
+ w.prefix(:odrl, RDF::URI.new("http://www.w3.org/ns/odrl/2/"))
113
+ w.prefix(:this, RDF::URI.new("http://w3id.org/FAIR_Training_LDP/DAV/home/LDP/DUC-CCE/IPGB#"))
114
+ w.prefix(:obo, RDF::URI.new("http://purl.obolibrary.org/obo/"))
115
+ w.prefix(:xsd, RDF::URI.new("http://www.w3.org/2001/XMLSchema#"))
116
+ end
117
+ return $writer
118
+ end
119
+
120
+ def triplify(s, p, o, repo)
121
+
122
+ if s.class == String
123
+ s = s.strip
124
+ end
125
+ if p.class == String
126
+ p = p.strip
127
+ end
128
+ if o.class == String
129
+ o = o.strip
130
+ end
131
+
132
+ unless s.respond_to?('uri')
133
+
134
+ if s.to_s =~ /^\w+:\/?\/?[^\s]+/
135
+ s = RDF::URI.new(s.to_s)
136
+ else
137
+ raise "Subject #{s.to_s} must be a URI-compatible thingy #{s}, #{p}, #{o}"
138
+ end
139
+ end
140
+
141
+ unless p.respond_to?('uri')
142
+
143
+ if p.to_s =~ /^\w+:\/?\/?[^\s]+/
144
+ p = RDF::URI.new(p.to_s)
145
+ else
146
+ raise "Predicate #{p.to_s} must be a URI-compatible thingy #{s}, #{p}, #{o}"
147
+ end
148
+ end
149
+ unless o.respond_to?('uri')
150
+ if o.to_s =~ /^\w+:\/?\/?[^\s]+/
151
+ o = RDF::URI.new(o.to_s)
152
+ elsif o.to_s =~ /^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d/
153
+ o = RDF::Literal.new(o.to_s, :datatype => RDF::XSD.date)
154
+ elsif o.to_s =~ /^\d\.\d/
155
+ o = RDF::Literal.new(o.to_s, :datatype => RDF::XSD.float)
156
+ elsif o.to_s =~ /^[0-9]+$/
157
+ o = RDF::Literal.new(o.to_s, :datatype => RDF::XSD.int)
158
+ else
159
+ o = RDF::Literal.new(o.to_s, :language => :en)
160
+ end
161
+ end
162
+
163
+ triple = RDF::Statement(s, p, o)
164
+ repo.insert(triple)
165
+
166
+ return true
167
+ end
168
+
169
+ def self.getuuid
170
+ return Time.now.to_f.to_s.gsub("\.", "")[1..14]
171
+ end
172
+
173
+ def load_graph
174
+ [:title, :creator, :description, :subject, :uid, :type].each do |method|
175
+ next unless self.send(method)
176
+ next if self.send(method).empty?
177
+ subject = self.uid
178
+ predicate = PROPERTIES[method]
179
+ #warn "prediate #{predicate} for method #{method}"
180
+ object = self.send(method)
181
+ repo = self.repository
182
+ triplify(subject, predicate, object, repo)
183
+ end
184
+ end
185
+
186
+ def serialize(format: $format)
187
+ format = format.to_sym
188
+ return self.repository.dump(format)
189
+ end
190
+
191
+ private
192
+
193
+
194
+ end
195
+ end
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ODRL
4
+
5
+ class Constraint < Base
6
+
7
+ attr_accessor :uid, :rightOperand, :leftOperand, :operator, :rightOperandReference, :dataType, :unit, :status
8
+ def initialize(args)
9
+ @uid = args[:uid]
10
+ unless @uid
11
+ @uid = Base.baseURI + "#constraint_" + Base.getuuid
12
+ end
13
+ super(args.merge({uid: @uid}))
14
+
15
+ self.type = "http://www.w3.org/ns/odrl/2/Constraint"
16
+
17
+ @rightOperand = args[:rightOperand]
18
+ raise "Constraints must haves a Right operand such as 'event' - I'm dead!" unless @rightOperand
19
+ @rightOperand = "http://www.w3.org/ns/odrl/2/#{@rightOperand}" unless @rightOperand =~ /https?:\/\// # if it is already a URI, then let it go
20
+
21
+ @leftOperand = args[:leftOperand]
22
+ raise "Constraints must haves a Left Operand such as 'http://some.event.org/on-now' - I'm dead!" unless @leftOperand
23
+ @leftOperand = "http://www.w3.org/ns/odrl/2/#{@leftOperand}" unless @leftOperand =~ /https?:\/\// # if it is already a URI, then let it go
24
+
25
+ @operator = args[:operator]
26
+ raise "Constraints must haves an operator such as 'eq' - I'm dead!" unless @operator
27
+ @operator = "http://www.w3.org/ns/odrl/2/#{@operator}" unless @operator =~ /https?:\/\// # if it is already a URI, then let it go
28
+
29
+ @rightOperandReference = args[:rightOperandReference]
30
+ @dataType = args[:dataType]
31
+ @unit = args[:unit]
32
+ @status = args[:status]
33
+ end
34
+
35
+ def load_graph
36
+ super
37
+ # TODO This is bad DRY!! Put the bulk of this method into the base object
38
+ if self.rightOperand
39
+ predicate = PRIGHT
40
+ object = self.rightOperand
41
+ subject = self.uid
42
+ repo = self.repository
43
+ triplify(subject, predicate, object, repo)
44
+ end
45
+ if self.leftOperand
46
+ predicate = PLEFT
47
+ object = self.leftOperand
48
+ subject = self.uid
49
+ repo = self.repository
50
+ triplify(subject, predicate, object, repo)
51
+ end
52
+ if self.operator
53
+ predicate = POPERATOR
54
+ object = self.operator
55
+ subject = self.uid
56
+ repo = self.repository
57
+ triplify(subject, predicate, object, repo)
58
+ end
59
+ if self.rightOperandReference
60
+ predicate = POPERANDREFERENCE
61
+ object = self.rightOperandReference
62
+ subject = self.uid
63
+ repo = self.repository
64
+ triplify(subject, predicate, object, repo)
65
+ end
66
+ if self.dataType
67
+ predicate = PDATATYPE
68
+ object = self.dataType
69
+ subject = self.uid
70
+ repo = self.repository
71
+ triplify(subject, predicate, object, repo)
72
+ end
73
+ if self.unit
74
+ predicate = PUNIT
75
+ object = self.unit
76
+ subject = self.uid
77
+ repo = self.repository
78
+ triplify(subject, predicate, object, repo)
79
+ end
80
+ if self.status
81
+ predicate = PSTATUS
82
+ object = self.status
83
+ subject = self.uid
84
+ repo = self.repository
85
+ triplify(subject, predicate, object, repo)
86
+ end
87
+ end
88
+
89
+ def serialize(format:)
90
+ super
91
+ end
92
+
93
+ end
94
+
95
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ODRL
4
+ module ODRL
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
data/lib/odrl/party.rb ADDED
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ODRL
4
+
5
+ class Party < Base
6
+ attr_accessor :uid, :refinements, :partOf, :predicate, :type
7
+ def initialize(args)
8
+ @uid = args[:uid]
9
+ unless @uid
10
+ @uid = Base.baseURI + "#party_" + Base.getuuid
11
+ end
12
+ super(args.merge({uid: @uid}))
13
+ self.type="http://www.w3.org/ns/odrl/2/Party"
14
+
15
+
16
+ @refinements = Hash.new
17
+ @partOf = args[:partOf]
18
+ @predicate = args[:predicate]
19
+ @type = CPARTY
20
+
21
+ unless @predicate
22
+ raise "If you don't indicate a predicate (assigner/assignee) we will default to assigner. This may not be what you want!"
23
+ @predicate = "http://www.w3.org/ns/odrl/2/assigner"
24
+ else
25
+ unless [PASSIGNER, PASSIGNEE].include? @predicate
26
+ raise "You didn't indicate a valid predicate (assigner/assignee) so we will default to assigner. This may not be what you want!"
27
+ @predicate = PASSIGNER
28
+ end
29
+ end
30
+
31
+
32
+
33
+ args[:refinements] = [args[:refinements]] unless args[:refinements].is_a? Array
34
+ if !(args[:refinements].first.nil?)
35
+ args[:refinements].each do |c|
36
+ self.addRefinement(refinement: c)
37
+ end
38
+ end
39
+
40
+ if @partOf and !(@partOf.is_a? PartyCollection) # if it exists and is the wrong type
41
+ raise "The parent collection of a Party must be of type ODRL::PaertyCollection. The provided value will be discarded"
42
+ @partOf = nil
43
+ end
44
+
45
+ end
46
+
47
+ def addRefinement(refinement: args)
48
+ unless refinement.is_a?(Constraint)
49
+ raise "Refinement is not an ODRL Constraint"
50
+ else
51
+ self.refinements[refinement.uid] = [PREFINEMENT, refinement]
52
+ end
53
+ end
54
+
55
+ def addPart(part: args)
56
+ unless self.is_a?(PartyCollection)
57
+ raise "Party cannot be added as part of something that is not an PartyCollection"
58
+ end
59
+ unless part.is_a?(Asset)
60
+ raise "Only Parties can be added as part of PartyCollections"
61
+ end
62
+ part.partOf[self.uid] = [PPARTOF, self]
63
+ end
64
+
65
+ def load_graph
66
+ super
67
+ # TODO This is bad DRY!! Put the bulk of this method into the base object
68
+ [:refinements, :partOf].each do |connected_object_type|
69
+ next unless self.send(connected_object_type)
70
+ self.send(connected_object_type).each do |uid, typedconnection|
71
+ predicate, odrlobject = typedconnection # e.g. "refinement", RefinementObject
72
+ object = odrlobject.uid
73
+ subject = self.uid
74
+ repo = self.repository
75
+ triplify(subject, predicate, object, repo)
76
+ odrlobject.load_graph # start the cascade
77
+ end
78
+ end
79
+ end
80
+
81
+ def serialize(format:)
82
+ super
83
+ end
84
+
85
+ end
86
+ class PartyCollection < Party
87
+
88
+ def initialize(args)
89
+ super(args)
90
+ self.type = "http://www.w3.org/ns/odrl/2/PartyCollection"
91
+ end
92
+ end
93
+
94
+
95
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "odrl/version"
4
+
5
+ module ODRL
6
+ class Error < StandardError; end
7
+
8
+
9
+ class Policy < Base
10
+ attr_accessor :rules
11
+
12
+ def initialize(args)
13
+ @uid = args[:uid]
14
+ unless @uid
15
+ self.uid = Base.baseURI + "#policy_" + Base.getuuid
16
+ end
17
+ super(args.merge({uid: @uid}))
18
+
19
+ @rules = Hash.new
20
+ end
21
+
22
+ def addDuty(rule:)
23
+ uid = rule.uid
24
+ self.rules[uid] = [POBLIGATION, rule]
25
+ end
26
+
27
+ def addPermission(rule:)
28
+ uid = rule.uid
29
+ self.rules[uid] = [PPERMISSION, rule]
30
+
31
+ end
32
+
33
+ def addProhibition(rule:)
34
+ uid = rule.uid
35
+ self.rules[uid] = [PPROHIBITION, rule]
36
+ end
37
+
38
+ def load_graph
39
+ super
40
+ self.rules.each do |uid, rulepair|
41
+ predicate, ruleobject = rulepair # e.g. "permission", RuleObject
42
+ object = ruleobject.uid
43
+ subject = self.uid
44
+ repo = self.repository
45
+ triplify(subject, predicate, object, repo)
46
+ ruleobject.load_graph # start the cascade
47
+ end
48
+ end
49
+
50
+ def serialize(format:)
51
+ super
52
+ end
53
+ end
54
+
55
+ class Set < Policy
56
+ def initialize(args)
57
+ super({type: CSET}.merge(args))
58
+ end
59
+ end
60
+
61
+ class Offer < Set
62
+ def initialize(args)
63
+ super({type: COFFER}.merge(args))
64
+ end
65
+ end
66
+ class Agreement < Set
67
+ def initialize(args)
68
+ super({type: CAGREEMENT}.merge(args))
69
+ end
70
+ end
71
+ class Request < Set
72
+ def initialize(args)
73
+ super({type: CREQUEST}.merge(args))
74
+ end
75
+ end
76
+ # ====================================================
77
+
78
+
79
+ end
data/lib/odrl/ruby.rb ADDED
@@ -0,0 +1,27 @@
1
+ require 'linkeddata'
2
+ require 'rdf/raptor'
3
+
4
+ #RDF = RDF::Vocabulary.new("http://www.w3.org/1999/02/22-rdf-syntax-ns#")
5
+
6
+
7
+ RDFS = RDF::Vocabulary.new("http://www.w3.org/2000/01/rdf-schema#")
8
+ DCAT = RDF::Vocabulary.new("http://www.w3.org/ns/dcat#")
9
+ DC = RDF::Vocabulary.new("http://purl.org/dc/elements/1.1/")
10
+ DCT = RDF::Vocabulary.new("http://purl.org/dc/terms/")
11
+ FUND = RDF::Vocabulary.new("http://vocab.ox.ac.uk/projectfunding#")
12
+ SKOS = RDF::Vocabulary.new("http://www.w3.org/2004/02/skos/core#")
13
+ ODRLV = RDF::Vocabulary.new("http://www.w3.org/ns/odrl/2/")
14
+ OBO = RDF::Vocabulary.new("http://purl.obolibrary.org/obo/")
15
+ XSD = RDF::Vocabulary.new("http://www.w3.org/2001/XMLSchema#")
16
+ SCHEMA = RDF::Vocabulary.new("https://schema.org/")
17
+
18
+ require_relative "./base"
19
+ require_relative "./action"
20
+ require_relative "./asset"
21
+ require_relative "./constraint"
22
+ require_relative "./party"
23
+ require_relative "./policy"
24
+ require_relative "./rule"
25
+
26
+ module ODRL
27
+ end
data/lib/odrl/rule.rb ADDED
@@ -0,0 +1,131 @@
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
+ def initialize(args)
11
+ @uid = args[:uid]
12
+
13
+ unless @uid
14
+ @uid = Base.baseURI + "#rule_" + Base.getuuid
15
+ end
16
+ super(args.merge({uid: @uid}))
17
+
18
+ @constraints = Hash.new
19
+ @assets = Hash.new
20
+ @assigner = Hash.new
21
+ @assignee = Hash.new
22
+ @action = Hash.new
23
+
24
+ args[:assets] = [args[:assets]] unless args[:assets].is_a? Array
25
+ if !(args[:assets].first.nil?)
26
+ args[:assets].each do |c|
27
+ self.addAsset(asset: c)
28
+ end
29
+ end
30
+ args[:constraints] = [args[:constraints]] unless args[:constraints].is_a? Array
31
+ if !(args[:constraints].first.nil?)
32
+ args[:constraints].each do |c|
33
+ self.addConstraint(constraint: c)
34
+ end
35
+ end
36
+ end
37
+
38
+
39
+ def addAsset(asset:)
40
+ unless asset.is_a?(Asset)
41
+ raise "Asset is not an ODRL Asset"
42
+ else
43
+ uid = asset.uid
44
+ self.assets[uid] = [PASSET, asset]
45
+ end
46
+ end
47
+
48
+ def addConstraint(constraint:)
49
+ unless constraint.is_a?(Constraint)
50
+ raise "Constraint is not an ODRL Constraint"
51
+ else
52
+ self.constraints[constraint.uid] = [PCONSTRAINT, constraint]
53
+ end
54
+ end
55
+
56
+ def addAction(action:)
57
+ unless action.is_a?(Action)
58
+ raise "Action is not an ODRL Action"
59
+ else
60
+ self.action[action.uid] = [PACTION, action]
61
+ end
62
+ end
63
+
64
+ def addAssigner(party:)
65
+ unless party.is_a?(Party)
66
+ raise "Assigner is not an ODRL Party"
67
+ else
68
+ self.assigner[party.uid] = [PASSIGNER, party]
69
+ end
70
+ end
71
+
72
+ def addAssignee(party:)
73
+ unless party.is_a?(Party)
74
+ raise "Asigner is not an ODRL Party"
75
+ else
76
+ self.assignee[party.uid] = [PASSIGNEE, party]
77
+ end
78
+ end
79
+
80
+ def load_graph
81
+ super
82
+ [:constraints, :assets, :action, :assigner, :assignee].each do |connected_object_type|
83
+ next unless self.send(connected_object_type)
84
+ self.send(connected_object_type).each do |uid, typedconnection|
85
+ predicate, odrlobject = typedconnection # e.g. "action", ActionObject
86
+ object = odrlobject.uid
87
+ subject = self.uid
88
+ repo = self.repository
89
+ triplify(subject, predicate, object, repo)
90
+ odrlobject.load_graph # start the cascade
91
+ end
92
+ end
93
+ end
94
+
95
+ def serialize(format:)
96
+ super
97
+ end
98
+ end
99
+
100
+
101
+ class Permission < Rule
102
+ def initialize(args)
103
+ super(args)
104
+ self.predicate = PPERMISSION
105
+ self.type = CPERMISSION
106
+
107
+
108
+ end
109
+ end
110
+
111
+ class Duty < Rule
112
+ def initialize(args)
113
+ super(args)
114
+ self.predicate = PDUTY
115
+ self.type = CDUTY
116
+
117
+
118
+ end
119
+ end
120
+
121
+ class Prohibition < Rule
122
+ def initialize(args)
123
+ super(args)
124
+ self.predicate = PPROHIBITION
125
+ self.type = CPROHIBITION
126
+
127
+
128
+ end
129
+ end
130
+
131
+ end
data/testme.rb ADDED
@@ -0,0 +1,28 @@
1
+ require_relative "./lib/odrl/policy.rb"
2
+ require_relative "./lib/odrl/rule.rb"
3
+ require_relative "./lib/odrl/base.rb"
4
+ require_relative "./lib/odrl/asset.rb"
5
+ require_relative "./lib/odrl/constraint.rb"
6
+
7
+
8
+ t = ODRL::Policy.new(
9
+ title: "this",
10
+ author: "mark",
11
+ baseURI: "http://adsjfhalsdjfasdh",
12
+
13
+ )
14
+
15
+ pro = ODRL::Prohibition.new({})
16
+ # puts t.methods
17
+ # abort
18
+ # t.addProhibition(rule: pro)
19
+ # puts t.rules.length
20
+ # puts t.rules[t.rules.keys.first][1].inspect
21
+ # puts t.rules[t.rules.keys.first][1].class.to_s == "ODRL::Prohibition"
22
+
23
+ #p t.inspect
24
+ c1 = ODRL::Constraint.new({})
25
+ #p c1.inspect
26
+ c2 = ODRL::Constraint.new({})
27
+ d = ODRL::Duty.new({constraints: c1})
28
+ puts d.inspect
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: odrl-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mark Wilkinson
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-06-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: builds ODRL files nicely.
14
+ email:
15
+ - markw@illuminae.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".rubocop.yml"
21
+ - CHANGELOG.md
22
+ - Gemfile
23
+ - Gemfile.lock
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - bin/console
28
+ - bin/setup
29
+ - examples/create-biohackathon-offer.rb
30
+ - launch.json
31
+ - lib/odrl/action.rb
32
+ - lib/odrl/asset.rb
33
+ - lib/odrl/base.rb
34
+ - lib/odrl/constraint.rb
35
+ - lib/odrl/odrl/version.rb
36
+ - lib/odrl/party.rb
37
+ - lib/odrl/policy.rb
38
+ - lib/odrl/ruby.rb
39
+ - lib/odrl/rule.rb
40
+ - testme.rb
41
+ homepage: https://example.org
42
+ licenses:
43
+ - MIT
44
+ metadata:
45
+ allowed_push_host: https://rubygems.org
46
+ homepage_uri: https://example.org
47
+ source_code_uri: https://github.com/markwilkinson/ODRL-RUBY
48
+ changelog_uri: https://github.com/markwilkinson/ODRL-RUBY/blob/master/CHANGELOG.md
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 2.6.0
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubygems_version: 3.3.23
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: builds ODRL files.
68
+ test_files: []