Skip to content

Commit

Permalink
Finish 3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Dec 29, 2021
2 parents 737f015 + 9dbf716 commit 637c68e
Show file tree
Hide file tree
Showing 17 changed files with 274 additions and 84 deletions.
20 changes: 8 additions & 12 deletions .github/workflows/ci.yml
@@ -1,37 +1,29 @@
# This workflow runs continuous CI across different versions of ruby on all branches and pull requests to develop.

name: CI

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the develop branch
push:
branches: [ '**' ]
pull_request:
branches: [ develop ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
tests:
name: Ruby ${{ matrix.ruby }}
if: "contains(github.event.commits[0].message, '[ci skip]') == false"
runs-on: ubuntu-latest
env:
CI: true
ALLOW_FAILURES: false ${{ endsWith(matrix.ruby, 'head') }}
ALLOW_FAILURES: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'jruby' }}
strategy:
fail-fast: false
matrix:
ruby:
- 2.4
- 2.5
- 2.6
- 2.7
- 3.0
- 3.1
- ruby-head
- jruby
steps:
Expand All @@ -44,5 +36,9 @@ jobs:
- name: Install dependencies
run: bundle install --jobs 4 --retry 3
- name: Run tests
run: bundle exec rspec spec || $ALLOW_FAILURES

run: ruby --version; bundle exec rspec spec || $ALLOW_FAILURES
- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v1.1.2
if: "matrix.ruby == '3.0'"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions Gemfile
@@ -1,9 +1,9 @@
source "https://rubygems.org"
gem "nokogiri", '~> 1.10'
gem "nokogumbo", platforms: :mri

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

group :development do
gem 'ebnf', git: "https://github.com/dryruby/ebnf", branch: "develop"
Expand Down Expand Up @@ -38,8 +38,8 @@ group :development do
end

group :development, :test do
gem 'simplecov', platforms: :mri
gem 'coveralls', '~> 0.8', platforms: :mri
gem 'simplecov', '~> 0.21', platforms: :mri
gem 'simplecov-lcov', '~> 0.8', platforms: :mri
gem 'psych', platforms: [:mri, :rbx]
gem 'benchmark-ips'
gem 'rake'
Expand Down
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -14,7 +14,7 @@ JSON::LD parses and serializes [JSON-LD][] into [RDF][] and implements expansion
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.

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

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

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

## Installation
The recommended installation method is via [RubyGems](https://rubygems.org/).
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
3.1.9
3.2.0
16 changes: 16 additions & 0 deletions example-files/frame-title-frame.jsonld
@@ -0,0 +1,16 @@
{
"@context": [
{
"@language": "en"
},
{
"title": {
"@id": "dct:title"
},
"titles": {
"@id": "dct:title",
"@container": "@language"
}
}
]
}
17 changes: 17 additions & 0 deletions example-files/frame-title.jsonld
@@ -0,0 +1,17 @@
{
"@context": [
{
"@language": "en"
},
{
"title": {
"@id": "dct:title"
},
"titles": {
"@id": "dct:title",
"@container": "@language"
}
}
],
"title": "myTitle"
}
26 changes: 13 additions & 13 deletions json-ld.gemspec
Expand Up @@ -23,26 +23,26 @@ Gem::Specification.new do |gem|
gem.require_paths = %w(lib)
gem.test_files = Dir.glob('spec/**/*.rb') + Dir.glob('spec/test-files/*')

gem.required_ruby_version = '>= 2.4'
gem.required_ruby_version = '>= 2.6'
gem.requirements = []
gem.add_runtime_dependency 'rdf', '~> 3.1'
gem.add_runtime_dependency 'multi_json', '~> 1.14'
gem.add_runtime_dependency 'rdf', '~> 3.2'
gem.add_runtime_dependency 'multi_json', '~> 1.15'
gem.add_runtime_dependency 'link_header', '~> 0.0', '>= 0.0.8'
gem.add_runtime_dependency 'json-canonicalization', '~> 0.2'
gem.add_runtime_dependency 'json-canonicalization', '~> 0.3'
gem.add_runtime_dependency 'htmlentities', '~> 4.3'
gem.add_runtime_dependency 'rack', '~> 2.0'
gem.add_runtime_dependency 'rack', '~> 2.2'
gem.add_development_dependency 'sinatra-linkeddata','~> 3.1'
gem.add_development_dependency 'jsonlint', '~> 0.3' unless is_java
gem.add_development_dependency 'oj', '~> 3.9' unless is_java
gem.add_development_dependency 'oj', '~> 3.13' unless is_java
gem.add_development_dependency 'yajl-ruby', '~> 1.4' unless is_java
gem.add_development_dependency 'rack-test', '~> 1.1'
gem.add_development_dependency 'rdf-isomorphic', '~> 3.1'
gem.add_development_dependency 'rdf-spec', '~> 3.1'
gem.add_development_dependency 'rdf-trig', '~> 3.1'
gem.add_development_dependency 'rdf-turtle', '~> 3.1'
gem.add_development_dependency 'rdf-vocab', '~> 3.1'
gem.add_development_dependency 'rdf-xsd', '~> 3.1'
gem.add_development_dependency 'rspec', '~> 3.9'
gem.add_development_dependency 'rdf-isomorphic', '~> 3.2'
gem.add_development_dependency 'rdf-spec', '~> 3.2'
gem.add_development_dependency 'rdf-trig', '~> 3.2'
gem.add_development_dependency 'rdf-turtle', '~> 3.2'
gem.add_development_dependency 'rdf-vocab', '~> 3.2'
gem.add_development_dependency 'rdf-xsd', '~> 3.2'
gem.add_development_dependency 'rspec', '~> 3.10'
gem.add_development_dependency 'rspec-its', '~> 1.3'
gem.add_development_dependency 'yard' , '~> 0.9'

Expand Down
1 change: 1 addition & 0 deletions lib/json/ld/compact.rb
Expand Up @@ -297,6 +297,7 @@ def compact(element,
if index_key == '@index'
map_key = expanded_item['@index']
else
index_key = context.expand_iri(index_key, vocab: true)
container_key = context.compact_iri(index_key, vocab: true)
map_key, *others = Array(compacted_item[container_key])
if map_key.is_a?(String)
Expand Down
30 changes: 17 additions & 13 deletions lib/json/ld/context.rb
Expand Up @@ -253,6 +253,7 @@ def parse(local_context,

local_context = as_array(local_context)

log_depth do
local_context.each do |context|
case context
when nil,false
Expand All @@ -266,22 +267,22 @@ def parse(local_context,
"Attempt to clear a context with protected terms"
end
when Context
#log_debug("parse") {"context: #{context.inspect}"}
log_debug("parse") {"context: #{context.inspect}"}
result = result.merge(context)
when IO, StringIO
#log_debug("parse") {"io: #{context}"}
log_debug("parse") {"io: #{context}"}
# Load context document, if it is an open file
begin
ctx = JSON.load(context)
raise JSON::LD::JsonLdError::InvalidRemoteContext, "Context missing @context key" if @options[:validate] && ctx['@context'].nil?
result = result.parse(ctx["@context"] ? ctx["@context"] : {})
rescue JSON::ParserError => e
#log_debug("parse") {"Failed to parse @context from remote document at #{context}: #{e.message}"}
log_info("parse") {"Failed to parse @context from remote document at #{context}: #{e.message}"}
raise JSON::LD::JsonLdError::InvalidRemoteContext, "Failed to parse remote context at #{context}: #{e.message}" if @options[:validate]
self
end
when String, RDF::URI
#log_debug("parse") {"remote: #{context}, base: #{result.context_base || result.base}"}
log_debug("parse") {"remote: #{context}, base: #{result.context_base || result.base}"}

# 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].
context = RDF::URI(result.context_base || base).join(context)
Expand All @@ -296,11 +297,11 @@ def parse(local_context,

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

# If this is a Proc, then replace the entry with the result of running the Proc
if PRELOADED[context_canon.to_s].respond_to?(:call)
#log_debug("parse") {"=> (call)"}
log_debug("parse") {"=> (call)"}
PRELOADED[context_canon.to_s] = PRELOADED[context_canon.to_s].call
end
PRELOADED[context_canon.to_s]
Expand All @@ -320,16 +321,17 @@ def parse(local_context,
ctx = Context.new(unfrozen: true, **options).dup
ctx.context_base = context.to_s
ctx = ctx.parse(remote_doc.document['@context'], remote_contexts: remote_contexts.dup)
ctx.context_base = context.to_s # In case it was altered
ctx.instance_variable_set(:@base, nil)
ctx
end
rescue JsonLdError::LoadingDocumentFailed => e
#log_debug("parse") {"Failed to retrieve @context from remote document at #{context_no_base.context_base.inspect}: #{e.message}"}
log_info("parse") {"Failed to retrieve @context from remote document at #{context_canon.inspect}: #{e.message}"}
raise JsonLdError::LoadingRemoteContextFailed, "#{context}: #{e.message}", e.backtrace
rescue JsonLdError
raise
rescue StandardError => e
#log_debug("parse") {"Failed to retrieve @context from remote document at #{context_no_base.context_base.inspect}: #{e.message}"}
log_info("parse") {"Failed to retrieve @context from remote document at #{context_canon.inspect}: #{e.message}"}
raise JsonLdError::LoadingRemoteContextFailed, "#{context}: #{e.message}", e.backtrace
end
end
Expand Down Expand Up @@ -406,6 +408,7 @@ def parse(local_context,
raise JsonLdError::InvalidLocalContext, "must be a URL, JSON object or array of same: #{context.inspect}"
end
end
end
result
end

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

# 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.
case defined[term]
Expand Down Expand Up @@ -646,7 +649,7 @@ def create_term_definition(local_context, term, defined,
# Otherwise, term is an absolute IRI. Set the IRI mapping for definition to term
term
end
#log_debug("") {"=> #{definition.id}"}
log_debug("") {"=> #{definition.id}"}
elsif term.include?('/')
# If term is a relative IRI
definition.id = expand_iri(term, vocab: true)
Expand All @@ -659,7 +662,7 @@ def create_term_definition(local_context, term, defined,
# 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.
raise JsonLdError::InvalidIRIMapping, "relative term definition without vocab: #{term} on term #{term.inspect}" unless vocab
definition.id = vocab + term
#log_debug("") {"=> #{definition.id}"}
log_debug("") {"=> #{definition.id}"}
end

@iri_to_term[definition.id] = term if simple_term && definition.id
Expand Down Expand Up @@ -699,6 +702,7 @@ def create_term_definition(local_context, term, defined,
when nil then [nil]
else value['@context']
end
log_debug("") {"context: #{definition.context.inspect}"}
rescue JsonLdError => e
raise JsonLdError::InvalidScopedContext, "Term definition for #{term.inspect} contains illegal value for @context: #{e.message}"
end
Expand Down Expand Up @@ -1684,7 +1688,7 @@ def dup
ec.default_direction = that.default_direction
ec.default_language = that.default_language
ec.previous_context = that.previous_context
ec.processingMode = that.processingMode if that.instance_variable_get(:@processingModee)
ec.processingMode = that.processingMode if that.instance_variable_get(:@processingMode)
ec.vocab = that.vocab if that.vocab

ec.instance_eval do
Expand Down Expand Up @@ -1884,7 +1888,7 @@ def remove_base(base, iri)
@base_and_parents ||= begin
u = base
iri_set = u.to_s.end_with?('/') ? [u.to_s] : []
iri_set << u.to_s while (u = u.parent)
iri_set << u.to_s while (u != './' && u = u.parent)
iri_set
end
b = base.to_s
Expand Down

0 comments on commit 637c68e

Please sign in to comment.