Skip to content

Commit 637c68e

Browse files
committed
Finish 3.2.0
2 parents 737f015 + 9dbf716 commit 637c68e

17 files changed

+274
-84
lines changed

.github/workflows/ci.yml

+8-12
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,29 @@
11
# This workflow runs continuous CI across different versions of ruby on all branches and pull requests to develop.
22

33
name: CI
4-
5-
# Controls when the action will run.
64
on:
7-
# Triggers the workflow on push or pull request events but only for the develop branch
85
push:
96
branches: [ '**' ]
107
pull_request:
118
branches: [ develop ]
12-
13-
# Allows you to run this workflow manually from the Actions tab
149
workflow_dispatch:
1510

16-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1711
jobs:
18-
# This workflow contains a single job called "build"
1912
tests:
2013
name: Ruby ${{ matrix.ruby }}
2114
if: "contains(github.event.commits[0].message, '[ci skip]') == false"
2215
runs-on: ubuntu-latest
2316
env:
2417
CI: true
25-
ALLOW_FAILURES: false ${{ endsWith(matrix.ruby, 'head') }}
18+
ALLOW_FAILURES: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'jruby' }}
2619
strategy:
2720
fail-fast: false
2821
matrix:
2922
ruby:
30-
- 2.4
31-
- 2.5
3223
- 2.6
3324
- 2.7
3425
- 3.0
26+
- 3.1
3527
- ruby-head
3628
- jruby
3729
steps:
@@ -44,5 +36,9 @@ jobs:
4436
- name: Install dependencies
4537
run: bundle install --jobs 4 --retry 3
4638
- name: Run tests
47-
run: bundle exec rspec spec || $ALLOW_FAILURES
48-
39+
run: ruby --version; bundle exec rspec spec || $ALLOW_FAILURES
40+
- name: Coveralls GitHub Action
41+
uses: coverallsapp/[email protected]
42+
if: "matrix.ruby == '3.0'"
43+
with:
44+
github-token: ${{ secrets.GITHUB_TOKEN }}

.travis.yml

-16
This file was deleted.

Gemfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
source "https://rubygems.org"
22
gem "nokogiri", '~> 1.10'
3-
gem "nokogumbo", platforms: :mri
43

54
gemspec
65
gem 'rdf', git: "https://github.com/ruby-rdf/rdf", branch: "develop"
6+
gem 'json-canonicalization',git: "https://github.com/dryruby/json-canonicalization",branch: "develop"
77

88
group :development do
99
gem 'ebnf', git: "https://github.com/dryruby/ebnf", branch: "develop"
@@ -38,8 +38,8 @@ group :development do
3838
end
3939

4040
group :development, :test do
41-
gem 'simplecov', platforms: :mri
42-
gem 'coveralls', '~> 0.8', platforms: :mri
41+
gem 'simplecov', '~> 0.21', platforms: :mri
42+
gem 'simplecov-lcov', '~> 0.8', platforms: :mri
4343
gem 'psych', platforms: [:mri, :rbx]
4444
gem 'benchmark-ips'
4545
gem 'rake'

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ JSON::LD parses and serializes [JSON-LD][] into [RDF][] and implements expansion
1414
JSON::LD can now be used to create a _context_ from an RDFS/OWL definition, and optionally include a JSON-LD representation of the ontology itself. This is currently accessed through the `script/gen_context` script.
1515

1616
* If the [jsonlint][] gem is installed, it will be used when validating an input document.
17-
* If available, uses [Nokogiri][] and/or [Nokogumbo][] for parsing HTML, falls back to REXML otherwise.
17+
* If available, uses [Nokogiri][] for parsing HTML, falls back to REXML otherwise.
1818
* Provisional support for [JSON-LD-star][JSON-LD-star].
1919

2020
[Implementation Report](https://ruby-rdf.github.io/json-ld/etc/earl.html)
@@ -588,9 +588,9 @@ Note, the API method signatures differed in versions before 1.0, in that they al
588588
* {JSON::LD::Writer}
589589

590590
## Dependencies
591-
* [Ruby](https://ruby-lang.org/) (>= 2.4)
592-
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.1)
593-
* [JSON](https://rubygems.org/gems/json) (>= 2.2)
591+
* [Ruby](https://ruby-lang.org/) (>= 2.6)
592+
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.2)
593+
* [JSON](https://rubygems.org/gems/json) (>= 2.6)
594594

595595
## Installation
596596
The recommended installation method is via [RubyGems](https://rubygems.org/).

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.9
1+
3.2.0
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"@context": [
3+
{
4+
"@language": "en"
5+
},
6+
{
7+
"title": {
8+
"@id": "dct:title"
9+
},
10+
"titles": {
11+
"@id": "dct:title",
12+
"@container": "@language"
13+
}
14+
}
15+
]
16+
}

example-files/frame-title.jsonld

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"@context": [
3+
{
4+
"@language": "en"
5+
},
6+
{
7+
"title": {
8+
"@id": "dct:title"
9+
},
10+
"titles": {
11+
"@id": "dct:title",
12+
"@container": "@language"
13+
}
14+
}
15+
],
16+
"title": "myTitle"
17+
}

json-ld.gemspec

+13-13
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,26 @@ Gem::Specification.new do |gem|
2323
gem.require_paths = %w(lib)
2424
gem.test_files = Dir.glob('spec/**/*.rb') + Dir.glob('spec/test-files/*')
2525

26-
gem.required_ruby_version = '>= 2.4'
26+
gem.required_ruby_version = '>= 2.6'
2727
gem.requirements = []
28-
gem.add_runtime_dependency 'rdf', '~> 3.1'
29-
gem.add_runtime_dependency 'multi_json', '~> 1.14'
28+
gem.add_runtime_dependency 'rdf', '~> 3.2'
29+
gem.add_runtime_dependency 'multi_json', '~> 1.15'
3030
gem.add_runtime_dependency 'link_header', '~> 0.0', '>= 0.0.8'
31-
gem.add_runtime_dependency 'json-canonicalization', '~> 0.2'
31+
gem.add_runtime_dependency 'json-canonicalization', '~> 0.3'
3232
gem.add_runtime_dependency 'htmlentities', '~> 4.3'
33-
gem.add_runtime_dependency 'rack', '~> 2.0'
33+
gem.add_runtime_dependency 'rack', '~> 2.2'
3434
gem.add_development_dependency 'sinatra-linkeddata','~> 3.1'
3535
gem.add_development_dependency 'jsonlint', '~> 0.3' unless is_java
36-
gem.add_development_dependency 'oj', '~> 3.9' unless is_java
36+
gem.add_development_dependency 'oj', '~> 3.13' unless is_java
3737
gem.add_development_dependency 'yajl-ruby', '~> 1.4' unless is_java
3838
gem.add_development_dependency 'rack-test', '~> 1.1'
39-
gem.add_development_dependency 'rdf-isomorphic', '~> 3.1'
40-
gem.add_development_dependency 'rdf-spec', '~> 3.1'
41-
gem.add_development_dependency 'rdf-trig', '~> 3.1'
42-
gem.add_development_dependency 'rdf-turtle', '~> 3.1'
43-
gem.add_development_dependency 'rdf-vocab', '~> 3.1'
44-
gem.add_development_dependency 'rdf-xsd', '~> 3.1'
45-
gem.add_development_dependency 'rspec', '~> 3.9'
39+
gem.add_development_dependency 'rdf-isomorphic', '~> 3.2'
40+
gem.add_development_dependency 'rdf-spec', '~> 3.2'
41+
gem.add_development_dependency 'rdf-trig', '~> 3.2'
42+
gem.add_development_dependency 'rdf-turtle', '~> 3.2'
43+
gem.add_development_dependency 'rdf-vocab', '~> 3.2'
44+
gem.add_development_dependency 'rdf-xsd', '~> 3.2'
45+
gem.add_development_dependency 'rspec', '~> 3.10'
4646
gem.add_development_dependency 'rspec-its', '~> 1.3'
4747
gem.add_development_dependency 'yard' , '~> 0.9'
4848

lib/json/ld/compact.rb

+1
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ def compact(element,
297297
if index_key == '@index'
298298
map_key = expanded_item['@index']
299299
else
300+
index_key = context.expand_iri(index_key, vocab: true)
300301
container_key = context.compact_iri(index_key, vocab: true)
301302
map_key, *others = Array(compacted_item[container_key])
302303
if map_key.is_a?(String)

lib/json/ld/context.rb

+17-13
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ def parse(local_context,
253253

254254
local_context = as_array(local_context)
255255

256+
log_depth do
256257
local_context.each do |context|
257258
case context
258259
when nil,false
@@ -266,22 +267,22 @@ def parse(local_context,
266267
"Attempt to clear a context with protected terms"
267268
end
268269
when Context
269-
#log_debug("parse") {"context: #{context.inspect}"}
270+
log_debug("parse") {"context: #{context.inspect}"}
270271
result = result.merge(context)
271272
when IO, StringIO
272-
#log_debug("parse") {"io: #{context}"}
273+
log_debug("parse") {"io: #{context}"}
273274
# Load context document, if it is an open file
274275
begin
275276
ctx = JSON.load(context)
276277
raise JSON::LD::JsonLdError::InvalidRemoteContext, "Context missing @context key" if @options[:validate] && ctx['@context'].nil?
277278
result = result.parse(ctx["@context"] ? ctx["@context"] : {})
278279
rescue JSON::ParserError => e
279-
#log_debug("parse") {"Failed to parse @context from remote document at #{context}: #{e.message}"}
280+
log_info("parse") {"Failed to parse @context from remote document at #{context}: #{e.message}"}
280281
raise JSON::LD::JsonLdError::InvalidRemoteContext, "Failed to parse remote context at #{context}: #{e.message}" if @options[:validate]
281282
self
282283
end
283284
when String, RDF::URI
284-
#log_debug("parse") {"remote: #{context}, base: #{result.context_base || result.base}"}
285+
log_debug("parse") {"remote: #{context}, base: #{result.context_base || result.base}"}
285286

286287
# 3.2.1) Set context to the result of resolving value against the base IRI which is established as specified in section 5.1 Establishing a Base URI of [RFC3986]. Only the basic algorithm in section 5.2 of [RFC3986] is used; neither Syntax-Based Normalization nor Scheme-Based Normalization are performed. Characters additionally allowed in IRI references are treated in the same way that unreserved characters are treated in URI references, per section 6.5 of [RFC3987].
287288
context = RDF::URI(result.context_base || base).join(context)
@@ -296,11 +297,11 @@ def parse(local_context,
296297

297298
cached_context = if PRELOADED[context_canon.to_s]
298299
# If we have a cached context, merge it into the current context (result) and use as the new context
299-
#log_debug("parse") {"=> cached_context: #{context_canon.to_s.inspect}"}
300+
log_debug("parse") {"=> cached_context: #{context_canon.to_s.inspect}"}
300301

301302
# If this is a Proc, then replace the entry with the result of running the Proc
302303
if PRELOADED[context_canon.to_s].respond_to?(:call)
303-
#log_debug("parse") {"=> (call)"}
304+
log_debug("parse") {"=> (call)"}
304305
PRELOADED[context_canon.to_s] = PRELOADED[context_canon.to_s].call
305306
end
306307
PRELOADED[context_canon.to_s]
@@ -320,16 +321,17 @@ def parse(local_context,
320321
ctx = Context.new(unfrozen: true, **options).dup
321322
ctx.context_base = context.to_s
322323
ctx = ctx.parse(remote_doc.document['@context'], remote_contexts: remote_contexts.dup)
324+
ctx.context_base = context.to_s # In case it was altered
323325
ctx.instance_variable_set(:@base, nil)
324326
ctx
325327
end
326328
rescue JsonLdError::LoadingDocumentFailed => e
327-
#log_debug("parse") {"Failed to retrieve @context from remote document at #{context_no_base.context_base.inspect}: #{e.message}"}
329+
log_info("parse") {"Failed to retrieve @context from remote document at #{context_canon.inspect}: #{e.message}"}
328330
raise JsonLdError::LoadingRemoteContextFailed, "#{context}: #{e.message}", e.backtrace
329331
rescue JsonLdError
330332
raise
331333
rescue StandardError => e
332-
#log_debug("parse") {"Failed to retrieve @context from remote document at #{context_no_base.context_base.inspect}: #{e.message}"}
334+
log_info("parse") {"Failed to retrieve @context from remote document at #{context_canon.inspect}: #{e.message}"}
333335
raise JsonLdError::LoadingRemoteContextFailed, "#{context}: #{e.message}", e.backtrace
334336
end
335337
end
@@ -406,6 +408,7 @@ def parse(local_context,
406408
raise JsonLdError::InvalidLocalContext, "must be a URL, JSON object or array of same: #{context.inspect}"
407409
end
408410
end
411+
end
409412
result
410413
end
411414

@@ -475,7 +478,7 @@ def create_term_definition(local_context, term, defined,
475478
remote_contexts: [],
476479
validate_scoped: true)
477480
# Expand a string value, unless it matches a keyword
478-
#log_debug("create_term_definition") {"term = #{term.inspect}"}
481+
log_debug("create_term_definition") {"term = #{term.inspect}"}
479482

480483
# If defined contains the key term, then the associated value must be true, indicating that the term definition has already been created, so return. Otherwise, a cyclical term definition has been detected, which is an error.
481484
case defined[term]
@@ -646,7 +649,7 @@ def create_term_definition(local_context, term, defined,
646649
# Otherwise, term is an absolute IRI. Set the IRI mapping for definition to term
647650
term
648651
end
649-
#log_debug("") {"=> #{definition.id}"}
652+
log_debug("") {"=> #{definition.id}"}
650653
elsif term.include?('/')
651654
# If term is a relative IRI
652655
definition.id = expand_iri(term, vocab: true)
@@ -659,7 +662,7 @@ def create_term_definition(local_context, term, defined,
659662
# Otherwise, active context must have a vocabulary mapping, otherwise an invalid value has been detected, which is an error. Set the IRI mapping for definition to the result of concatenating the value associated with the vocabulary mapping and term.
660663
raise JsonLdError::InvalidIRIMapping, "relative term definition without vocab: #{term} on term #{term.inspect}" unless vocab
661664
definition.id = vocab + term
662-
#log_debug("") {"=> #{definition.id}"}
665+
log_debug("") {"=> #{definition.id}"}
663666
end
664667

665668
@iri_to_term[definition.id] = term if simple_term && definition.id
@@ -699,6 +702,7 @@ def create_term_definition(local_context, term, defined,
699702
when nil then [nil]
700703
else value['@context']
701704
end
705+
log_debug("") {"context: #{definition.context.inspect}"}
702706
rescue JsonLdError => e
703707
raise JsonLdError::InvalidScopedContext, "Term definition for #{term.inspect} contains illegal value for @context: #{e.message}"
704708
end
@@ -1684,7 +1688,7 @@ def dup
16841688
ec.default_direction = that.default_direction
16851689
ec.default_language = that.default_language
16861690
ec.previous_context = that.previous_context
1687-
ec.processingMode = that.processingMode if that.instance_variable_get(:@processingModee)
1691+
ec.processingMode = that.processingMode if that.instance_variable_get(:@processingMode)
16881692
ec.vocab = that.vocab if that.vocab
16891693

16901694
ec.instance_eval do
@@ -1884,7 +1888,7 @@ def remove_base(base, iri)
18841888
@base_and_parents ||= begin
18851889
u = base
18861890
iri_set = u.to_s.end_with?('/') ? [u.to_s] : []
1887-
iri_set << u.to_s while (u = u.parent)
1891+
iri_set << u.to_s while (u != './' && u = u.parent)
18881892
iri_set
18891893
end
18901894
b = base.to_s

0 commit comments

Comments
 (0)