fsp-proxies 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: 5035fbe4f296e7893ea19ed102dc66df4e18d95db3b29b04edc3ec0843b4145e
4
+ data.tar.gz: a0bfde86d21933b95318472cc08f16dc74e24674da4140ce0c13b4cf1b803790
5
+ SHA512:
6
+ metadata.gz: 8989f886fefe6c7d47e26ed11f65313f6e494e5f6914be6b353d9754c0247f2714aa2519dc394313f07d73ff086a8cc50d6f5f6fab2dc699e37fe4911a172359
7
+ data.tar.gz: 3d7c732bf276e24d860c2c77783ca309f56e88d11419a50adaade75b959f734c831a3b5bc727e2e9d2bef1a4a498726fecaf8c27db824b79618c2afe3204637a
data/.rubocop.yml ADDED
@@ -0,0 +1,3 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.0.0
3
+ NewCops: enable
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-08-24
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at markw@illuminae.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in fsp-proxies.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,260 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fsp-proxies (0.1.0)
5
+ link_header (~> 0.0.8)
6
+ linkeddata (~> 3.2)
7
+ rest-client (~> 2.1)
8
+ sparql (~> 3.2)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ addressable (2.8.0)
14
+ public_suffix (>= 2.0.2, < 5.0)
15
+ amazing_print (1.4.0)
16
+ ast (2.4.2)
17
+ bcp47 (0.3.3)
18
+ i18n
19
+ builder (3.2.4)
20
+ concurrent-ruby (1.1.10)
21
+ connection_pool (2.2.5)
22
+ diff-lcs (1.5.0)
23
+ domain_name (0.5.20190701)
24
+ unf (>= 0.0.5, < 1.0.0)
25
+ ebnf (2.3.1)
26
+ amazing_print (~> 1.4)
27
+ htmlentities (~> 4.3)
28
+ rdf (~> 3.2)
29
+ scanf (~> 1.0)
30
+ sxp (~> 1.2)
31
+ unicode-types (~> 1.7)
32
+ haml (5.2.2)
33
+ temple (>= 0.8.0)
34
+ tilt
35
+ hamster (3.0.0)
36
+ concurrent-ruby (~> 1.0)
37
+ htmlentities (4.3.4)
38
+ http-accept (1.7.0)
39
+ http-cookie (1.0.5)
40
+ domain_name (~> 0.5)
41
+ i18n (1.12.0)
42
+ concurrent-ruby (~> 1.0)
43
+ json (2.6.2)
44
+ json-canonicalization (0.3.0)
45
+ json-ld (3.2.3)
46
+ htmlentities (~> 4.3)
47
+ json-canonicalization (~> 0.3)
48
+ link_header (~> 0.0, >= 0.0.8)
49
+ multi_json (~> 1.15)
50
+ rack (~> 2.2)
51
+ rdf (~> 3.2, >= 3.2.9)
52
+ json-ld-preloaded (3.2.0)
53
+ json-ld (~> 3.2)
54
+ rdf (~> 3.2)
55
+ ld-patch (3.2.0)
56
+ ebnf (~> 2.2)
57
+ rdf (~> 3.2)
58
+ rdf-xsd (~> 3.2)
59
+ sparql (~> 3.2)
60
+ sxp (~> 1.2)
61
+ link_header (0.0.8)
62
+ linkeddata (3.2.1)
63
+ json-ld (~> 3.2, >= 3.2.3)
64
+ json-ld-preloaded (~> 3.2)
65
+ ld-patch (~> 3.2)
66
+ nokogiri (~> 1.13, >= 1.13.8)
67
+ rdf (~> 3.2, >= 3.2.9)
68
+ rdf-aggregate-repo (~> 3.2, >= 3.2.1)
69
+ rdf-hamster-repo (~> 3.2)
70
+ rdf-isomorphic (~> 3.2, >= 3.2.1)
71
+ rdf-json (~> 3.2)
72
+ rdf-microdata (~> 3.2, >= 3.2.1)
73
+ rdf-n3 (~> 3.2, >= 3.2.1)
74
+ rdf-normalize (~> 0.5)
75
+ rdf-ordered-repo (~> 3.2, >= 3.2.1)
76
+ rdf-rdfa (~> 3.2)
77
+ rdf-rdfxml (~> 3.2)
78
+ rdf-reasoner (~> 0.8)
79
+ rdf-tabular (~> 3.2, >= 3.2.1)
80
+ rdf-trig (~> 3.2)
81
+ rdf-trix (~> 3.2)
82
+ rdf-turtle (~> 3.2, >= 3.2.1)
83
+ rdf-vocab (~> 3.2, >= 3.2.1)
84
+ rdf-xsd (~> 3.2, >= 3.2.1)
85
+ shacl (~> 0.2, >= 0.2.1)
86
+ shex (~> 0.7, >= 0.7.1)
87
+ sparql (~> 3.2, >= 3.2.4)
88
+ sparql-client (~> 3.2, >= 3.2.1)
89
+ yaml-ld (~> 0.0)
90
+ logger (1.5.1)
91
+ matrix (0.4.2)
92
+ mime-types (3.4.1)
93
+ mime-types-data (~> 3.2015)
94
+ mime-types-data (3.2022.0105)
95
+ multi_json (1.15.0)
96
+ net-http-persistent (4.0.1)
97
+ connection_pool (~> 2.2)
98
+ netrc (0.11.0)
99
+ nokogiri (1.13.8-x86_64-linux)
100
+ racc (~> 1.4)
101
+ parallel (1.22.1)
102
+ parser (3.1.2.1)
103
+ ast (~> 2.4.1)
104
+ psych (4.0.4)
105
+ stringio
106
+ public_suffix (4.0.7)
107
+ racc (1.6.0)
108
+ rack (2.2.4)
109
+ rainbow (3.1.1)
110
+ rake (13.0.6)
111
+ rdf (3.2.9)
112
+ link_header (~> 0.0, >= 0.0.8)
113
+ rdf-aggregate-repo (3.2.1)
114
+ rdf (~> 3.2)
115
+ rdf-hamster-repo (3.2.1)
116
+ hamster (~> 3.0)
117
+ rdf (~> 3.2, >= 3.2.1)
118
+ rdf-isomorphic (3.2.1)
119
+ rdf (~> 3.2)
120
+ rdf-json (3.2.0)
121
+ rdf (~> 3.2)
122
+ rdf-microdata (3.2.1)
123
+ htmlentities (~> 4.3)
124
+ nokogiri (~> 1.13)
125
+ rdf (~> 3.2)
126
+ rdf-rdfa (~> 3.2)
127
+ rdf-xsd (~> 3.2)
128
+ rdf-n3 (3.2.1)
129
+ ebnf (~> 2.2)
130
+ rdf (~> 3.2)
131
+ sparql (~> 3.2)
132
+ sxp (~> 1.2)
133
+ rdf-normalize (0.5.0)
134
+ rdf (~> 3.2)
135
+ rdf-ordered-repo (3.2.1)
136
+ rdf (~> 3.2, >= 3.2.1)
137
+ rdf-rdfa (3.2.0)
138
+ haml (~> 5.2)
139
+ htmlentities (~> 4.3)
140
+ rdf (~> 3.2)
141
+ rdf-aggregate-repo (~> 3.2)
142
+ rdf-vocab (~> 3.2)
143
+ rdf-xsd (~> 3.2)
144
+ rdf-rdfxml (3.2.0)
145
+ htmlentities (~> 4.3)
146
+ rdf (~> 3.2)
147
+ rdf-rdfa (~> 3.2)
148
+ rdf-xsd (~> 3.2)
149
+ rdf-reasoner (0.8.0)
150
+ rdf (~> 3.2)
151
+ rdf-xsd (~> 3.2)
152
+ rdf-tabular (3.2.1)
153
+ addressable (~> 2.8)
154
+ bcp47 (~> 0.3, >= 0.3.3)
155
+ json-ld (~> 3.2)
156
+ rdf (~> 3.2, >= 3.2.7)
157
+ rdf-vocab (~> 3.2)
158
+ rdf-xsd (~> 3.2)
159
+ rdf-trig (3.2.0)
160
+ ebnf (~> 2.2)
161
+ rdf (~> 3.2)
162
+ rdf-turtle (~> 3.2)
163
+ rdf-trix (3.2.0)
164
+ rdf (~> 3.2)
165
+ rdf-xsd (~> 3.2)
166
+ rdf-turtle (3.2.1)
167
+ ebnf (~> 2.3)
168
+ rdf (~> 3.2)
169
+ rdf-vocab (3.2.1)
170
+ rdf (~> 3.2, >= 3.2.4)
171
+ rdf-xsd (3.2.1)
172
+ rdf (~> 3.2)
173
+ rexml (~> 3.2)
174
+ regexp_parser (2.5.0)
175
+ rest-client (2.1.0)
176
+ http-accept (>= 1.7.0, < 2.0)
177
+ http-cookie (>= 1.0.2, < 2.0)
178
+ mime-types (>= 1.16, < 4.0)
179
+ netrc (~> 0.8)
180
+ rexml (3.2.5)
181
+ rspec (3.11.0)
182
+ rspec-core (~> 3.11.0)
183
+ rspec-expectations (~> 3.11.0)
184
+ rspec-mocks (~> 3.11.0)
185
+ rspec-core (3.11.0)
186
+ rspec-support (~> 3.11.0)
187
+ rspec-expectations (3.11.0)
188
+ diff-lcs (>= 1.2.0, < 2.0)
189
+ rspec-support (~> 3.11.0)
190
+ rspec-mocks (3.11.1)
191
+ diff-lcs (>= 1.2.0, < 2.0)
192
+ rspec-support (~> 3.11.0)
193
+ rspec-support (3.11.0)
194
+ rubocop (1.35.0)
195
+ json (~> 2.3)
196
+ parallel (~> 1.10)
197
+ parser (>= 3.1.2.1)
198
+ rainbow (>= 2.2.2, < 4.0)
199
+ regexp_parser (>= 1.8, < 3.0)
200
+ rexml (>= 3.2.5, < 4.0)
201
+ rubocop-ast (>= 1.20.1, < 2.0)
202
+ ruby-progressbar (~> 1.7)
203
+ unicode-display_width (>= 1.4.0, < 3.0)
204
+ rubocop-ast (1.21.0)
205
+ parser (>= 3.1.1.0)
206
+ ruby-progressbar (1.11.0)
207
+ scanf (1.0.0)
208
+ shacl (0.3.0)
209
+ json-ld (~> 3.2)
210
+ rdf (~> 3.2, >= 3.2.8)
211
+ sparql (~> 3.2, >= 3.2.4)
212
+ sxp (~> 1.2)
213
+ shex (0.7.1)
214
+ ebnf (~> 2.2)
215
+ htmlentities (~> 4.3)
216
+ json-ld (~> 3.2)
217
+ json-ld-preloaded (~> 3.2)
218
+ rdf (~> 3.2)
219
+ rdf-xsd (~> 3.2)
220
+ sparql (~> 3.2)
221
+ sxp (~> 1.2)
222
+ sparql (3.2.4)
223
+ builder (~> 3.2)
224
+ ebnf (~> 2.2, >= 2.3.1)
225
+ logger (~> 1.5)
226
+ rdf (~> 3.2, >= 3.2.8)
227
+ rdf-aggregate-repo (~> 3.2)
228
+ rdf-xsd (~> 3.2)
229
+ sparql-client (~> 3.2, >= 3.2.1)
230
+ sxp (~> 1.2, >= 1.2.2)
231
+ sparql-client (3.2.1)
232
+ net-http-persistent (~> 4.0, >= 4.0.1)
233
+ rdf (~> 3.2, >= 3.2.6)
234
+ stringio (3.0.2)
235
+ sxp (1.2.2)
236
+ matrix
237
+ rdf (~> 3.2)
238
+ temple (0.8.2)
239
+ tilt (2.0.11)
240
+ unf (0.1.4)
241
+ unf_ext
242
+ unf_ext (0.0.8.2)
243
+ unicode-display_width (2.2.0)
244
+ unicode-types (1.7.0)
245
+ yaml-ld (0.0.1)
246
+ json-ld (~> 3.2, >= 3.2.2)
247
+ psych (~> 4.0)
248
+ rdf (~> 3.2)
249
+
250
+ PLATFORMS
251
+ x86_64-linux
252
+
253
+ DEPENDENCIES
254
+ fsp-proxies!
255
+ rake (~> 13.0)
256
+ rspec (~> 3.0)
257
+ rubocop (~> 1.21)
258
+
259
+ BUNDLED WITH
260
+ 2.3.12
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,37 @@
1
+ # Fsp::Proxies
2
+
3
+ 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/fsp/proxies`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Install the gem and add to the application's Gemfile by executing:
10
+
11
+ $ bundle add fsp-proxies
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by executing:
14
+
15
+ $ gem install fsp-proxies
16
+
17
+ ## Usage
18
+
19
+ TODO: Write usage instructions here
20
+
21
+ ## Development
22
+
23
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
+
25
+ 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).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fsp-proxies. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/fsp-proxies/blob/master/CODE_OF_CONDUCT.md).
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
34
+
35
+ ## Code of Conduct
36
+
37
+ Everyone interacting in the Fsp::Proxies project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/fsp-proxies/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
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/gems/ruby-3.0.0/bin/rspec",
7
+ "args": [
8
+ "-I",
9
+ "${workspaceRoot}"
10
+ ]
11
+ }
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fsp
4
+ module Proxies
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,177 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'proxies/version'
4
+ require_relative './web_utils'
5
+ require 'rest-client'
6
+ require 'linkeddata'
7
+ require 'sparql'
8
+ require 'link_header'
9
+
10
+ module Fsp
11
+ module Proxies
12
+ class Error < StandardError; end
13
+ # Your code goes here...
14
+
15
+ class FairDataPoint
16
+ attr_accessor :url, :cite_as, :describedby, :items, :html, :types
17
+
18
+ def initialize(url:)
19
+ @url = url
20
+ @cite_as = ''
21
+ @describedby = ''
22
+ @items = ''
23
+ @html = ''
24
+ @types = ''
25
+ end
26
+
27
+ def proxy
28
+ self.html = Fsp::Proxies::WebUtils.fetch(
29
+ url: url,
30
+ headers: { 'Accept' => 'text/html' }
31
+ )
32
+ ttl = Fsp::Proxies::WebUtils.fetch(
33
+ url: url,
34
+ headers: { 'Accept' => 'text/turtle' }
35
+ )
36
+ warn 'no turtle' unless ttl
37
+ return self unless ttl
38
+
39
+ repo = RDF::Repository.new
40
+ RDF::Reader.for(:turtle).new(StringIO.new(ttl)) do |reader|
41
+ reader.each_statement do |statement|
42
+ repo << statement
43
+ # warn statement.to_s
44
+ end
45
+ end
46
+
47
+ self.cite_as = get_cite_as(repo: repo) # returns html links
48
+ self.items = get_items(repo: repo)
49
+ self.describedby = get_described_by(repo: repo)
50
+ self.types = get_types(repo: repo)
51
+ end
52
+
53
+ def get_cite_as(repo:)
54
+ query = SPARQL.parse("
55
+ PREFIX dcterms: <http://purl.org/dc/terms/>
56
+ SELECT * WHERE {
57
+ ?s a <http://purl.org/spar/datacite/Identifier> .
58
+ ?s dcterms:identifier ?id
59
+ }")
60
+ id = ''
61
+ repo.query(query) do |result|
62
+ warn result.inspect
63
+ id = result[:id].to_s
64
+ end
65
+
66
+ link = LinkHeader.new([[id, [%w[rel cite-as]]]]).to_html
67
+ warn "LINK: #{link}"
68
+ link
69
+ end
70
+
71
+ def get_described_by(repo:)
72
+ query = SPARQL.parse("
73
+ PREFIX dcterms: <http://purl.org/dc/terms/>
74
+ PREFIX ldp: <http://www.w3.org/ns/ldp#>
75
+ SELECT distinct ?meta WHERE {
76
+ VALUES ?pred {<https://w3id.org/fdp/fdp-o#metadataIssued> <http://rdf.biosemantics.org/ontologies/fdp-o#metadataIssued>}
77
+ ?meta ?pred ?o .
78
+ }")
79
+ ids = []
80
+ repo.query(query) do |result|
81
+ warn result.inspect
82
+ ids << [result[:meta].to_s, [%w[rel describedby], %w[type text/turtle]]]
83
+ end
84
+
85
+ link = LinkHeader.new(ids).to_html
86
+ warn "LINK: #{link}"
87
+ link
88
+ end
89
+
90
+ def get_items(repo:)
91
+ query = SPARQL.parse("
92
+ PREFIX dcterms: <http://purl.org/dc/terms/>
93
+ PREFIX ldp: <http://www.w3.org/ns/ldp#>
94
+ SELECT distinct ?id WHERE {
95
+ ?s a ldp:DirectContainer .
96
+ ?s ldp:contains ?id
97
+ }")
98
+ ids = []
99
+ repo.query(query) do |result|
100
+ warn result.inspect
101
+ ids << [result[:id].to_s, [%w[rel item], %w[type text/html]]]
102
+ end
103
+
104
+ link = LinkHeader.new(ids).to_html
105
+ warn "LINK: #{link}"
106
+ link
107
+ end
108
+
109
+ def get_types(repo:)
110
+ # https://schema.org/CreativeWork http://www.re3data.org/schema/3-0#Repository
111
+ # https://schema.org/DataCatalog http://www.re3data.org/schema/3-0#dataCatalog dcat:Catalog
112
+ # https://schema.org/Dataset dcat:Dataset
113
+ # https://schema.org/DataDownload dcat:Distribution
114
+
115
+ query = SPARQL.parse("
116
+ PREFIX dcterms: <http://purl.org/dc/terms/>
117
+ PREFIX ldp: <http://www.w3.org/ns/ldp#>
118
+ SELECT distinct ?type WHERE {
119
+ VALUES ?type {<https://schema.org/CreativeWork> <http://www.re3data.org/schema/3-0#Repository> <https://w3id.org/fdp/fdp-o#FAIRDataPoint> <https://w3id.org/fdp/fdp-o#MetadataService> <http://www.w3.org/ns/dcat#DataService>
120
+ <https://schema.org/DataCatalog> <http://www.re3data.org/schema/3-0#dataCatalog> <http://www.w3.org/ns/dcat#Catalog>
121
+ <https://schema.org/Dataset> <http://www.w3.org/ns/dcat#Dataset>
122
+ <https://schema.org/DataDownload> <http://www.w3.org/ns/dcat#Distribution> }
123
+
124
+ VALUES ?pred {<https://w3id.org/fdp/fdp-o#metadataIssued> <http://rdf.biosemantics.org/ontologies/fdp-o#metadataIssued>}
125
+ ?s a ?type .
126
+ ?s ?pred ?val . # the main subject will have the metadata issued property
127
+ }")
128
+ types = []
129
+ links = []
130
+ link = ''
131
+ repo.query(query) do |result|
132
+ warn result.inspect
133
+ if %w[http://www.re3data.org/schema/3-0#Repository https://w3id.org/fdp/fdp-o#FAIRDataPoint
134
+ https://w3id.org/fdp/fdp-o#MetadataService http://www.w3.org/ns/dcat#DataService].include?(result[:type].to_s)
135
+ types << 'https://schema.org/CreativeWork'
136
+ types << result[:type].to_s
137
+
138
+ elsif %w[http://www.re3data.org/schema/3-0#dataCatalog
139
+ http://www.w3.org/ns/dcat#Catalog].include?(result[:type].to_s)
140
+ types << 'https://schema.org/DataCatalog'
141
+ types << result[:type].to_s
142
+
143
+ elsif %w[http://www.w3.org/ns/dcat#Dataset].include?(result[:type].to_s)
144
+ types << 'https://schema.org/Dataset'
145
+ types << result[:type].to_s
146
+
147
+ elsif %w[http://www.w3.org/ns/dcat#Distribution].include?(result[:type].to_s)
148
+ types << 'https://schema.org/DataDownload'
149
+ types << result[:type].to_s
150
+
151
+ else
152
+ types << 'https://schema.org/CreativeWork'
153
+ end
154
+
155
+ types.each do |type|
156
+ links << [type, [%w[rel type]]]
157
+ end
158
+ link = LinkHeader.new(links).to_html
159
+ warn "LINK: #{link}"
160
+ break
161
+ end
162
+ link
163
+ end
164
+
165
+ def to_html()
166
+ html = self.html
167
+ # warn "HTML " + html
168
+ match = html.match(/(.*?)(>)(<link)(.*)/)
169
+ # warn "MATCH " + match.inspect.to_s
170
+ pre = match[1]+match[2]
171
+ post = match[3]+ match[4]
172
+ final = pre + self.cite_as + self.types + self.describedby + self.items + post
173
+ final
174
+ end
175
+ end
176
+ end
177
+ end
@@ -0,0 +1,41 @@
1
+ module Fsp
2
+ module Proxies
3
+ class WebUtils
4
+ def self.fetch(url:, headers: { 'Accept' => '*/*' }, method: :get, verifyssl: false)
5
+ warn 'In fetch routine now. '
6
+
7
+ begin
8
+ warn "executing call over the Web to #{url}"
9
+ response = RestClient::Request.execute({
10
+ method: method,
11
+ url: url.to_s,
12
+ # user: user,
13
+ # password: pass,
14
+ headers: headers,
15
+ :verify_ssl => verifyssl
16
+ })
17
+ warn "starting URL #{url}"
18
+ warn "final URL #{response.request.url}"
19
+ warn "Response code #{response.code}"
20
+ response
21
+ rescue RestClient::ExceptionWithResponse => e
22
+ warn "EXCEPTION WITH RESPONSE! #{e.response.code} with response #{e.response}\nfailed response headers: #{e.response.headers}"
23
+ if e.response.code == 500 or e.response.code == 404
24
+ false
25
+ else
26
+ e.response
27
+ end
28
+ # now we are returning the headers and body that were returned
29
+ rescue RestClient::Exception => e
30
+ warn "EXCEPTION WITH NO RESPONSE! #{e}"
31
+ false
32
+ # now we are returning 'False', and we will check that with an \"if\" statement in our main code
33
+ rescue Exception => e
34
+ warn "EXCEPTION UNKNOWN! #{e}"
35
+ false
36
+ # now we are returning 'False', and we will check that with an \"if\" statement in our main code
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,6 @@
1
+ module Fsp
2
+ module Proxies
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fsp-proxies
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: 2022-08-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: linkeddata
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: link_header
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.8
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.8
41
+ - !ruby/object:Gem::Dependency
42
+ name: rest-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sparql
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.2'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.2'
69
+ description: Proxy popular repositories to make them compatible with FAIR Signposting
70
+ spec (currently only FAIR Data Point).
71
+ email:
72
+ - markw@illuminae.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".rubocop.yml"
78
+ - CHANGELOG.md
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - launch.json
86
+ - lib/fsp/proxies.rb
87
+ - lib/fsp/proxies/version.rb
88
+ - lib/fsp/web_utils.rb
89
+ - sig/fsp/proxies.rbs
90
+ homepage: https://github.com/markwilkinson/fsp-proxies.
91
+ licenses:
92
+ - MIT
93
+ metadata:
94
+ allowed_push_host: https://rubygems.org
95
+ homepage_uri: https://github.com/markwilkinson/fsp-proxies.
96
+ source_code_uri: https://github.com/markwilkinson/fsp-proxies
97
+ changelog_uri: https://github.com/markwilkinson/fsp-proxies
98
+ rubygems_mfa_required: 'true'
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: 3.0.0
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubygems_version: 3.2.28
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Proxy repo HTML to FSP Spec.
118
+ test_files: []