Skip to content

Commit

Permalink
Finish 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Dec 16, 2019
2 parents ff1f361 + 351b296 commit 6eabc80
Show file tree
Hide file tree
Showing 19 changed files with 118 additions and 1,319 deletions.
12 changes: 5 additions & 7 deletions .travis.yml
@@ -1,18 +1,16 @@
language: ruby
bundler_args: --without debug
script: "bundle exec rspec spec"
env:
- CI=true
rvm:
- 2.2
- 2.3
- 2.4
- jruby-9
- rbx-3
- 2.5
- 2.6
- 2.7
- jruby
cache: bundler
sudo: false
matrix:
allow_failures:
- rvm: jruby-9
- rvm: rbx-3
- rvm: jruby
dist: trusty
13 changes: 4 additions & 9 deletions Gemfile
Expand Up @@ -5,11 +5,12 @@ gemspec
gem "rdf", git: "https://github.com/ruby-rdf/rdf", branch: "develop"
gem "rdf-rdfa", git: "https://github.com/ruby-rdf/rdf-rdfa", branch: "develop"
gem "rdf-xsd", git: "https://github.com/ruby-rdf/rdf-xsd", branch: "develop"
gem "nokogumbo", '~> 1.4'
gem "nokogumbo", '~> 2.0'

group :development do
gem 'linkeddata'
gem 'ebnf', git: "https://github.com/gkellogg/ebnf", branch: "develop"
gem "json-ld", git: "https://github.com/ruby-rdf/json-ld", branch: "develop"
#gem 'linkeddata'
gem 'ebnf', git: "https://github.com/dryruby/ebnf", branch: "develop"
gem 'rdf-aggregate-repo', git: "https://github.com/ruby-rdf/rdf-aggregate-repo", branch: "develop"
gem 'rdf-isomorphic', git: "https://github.com/ruby-rdf/rdf-isomorphic", branch: "develop"
gem "rdf-spec", git: "https://github.com/ruby-rdf/rdf-spec", branch: "develop"
Expand All @@ -20,9 +21,3 @@ end
group :debug do
gem "byebug", platform: :mri
end

platforms :rbx do
gem 'rubysl', '~> 2.0'
gem 'rubinius', '~> 2.0'
gem 'json'
end
15 changes: 4 additions & 11 deletions README.md
Expand Up @@ -45,11 +45,11 @@ GRDDL-type triple generation, such as for html>head>title anchor tags.
If the `RDFa` parser is available, {RDF::Microdata::Format} will not assert content type `text/html` or file extension `.html`, as this is also asserted by RDFa. Instead, the RDFa reader will invoke the microdata reader if an `@itemscope` attribute is detected.

## Dependencies
* [RDF.rb](http://rubygems.org/gems/rdf) (>= 2.0)
* [RDF::XSD](http://rubygems.org/gems/rdf-xsd) (>= 2.0)
* [RDF.rb](http://rubygems.org/gems/rdf) (>= 3.1)
* [RDF::XSD](http://rubygems.org/gems/rdf-xsd) (>= 3.1)
* [HTMLEntities](https://rubygems.org/gems/htmlentities) ('>= 4.3.0')
* [Nokogiri](http://rubygems.org/gems/nokogiri) (>= 1.7.1)
* Soft dependency on [Nokogumbo](https://github.com/rubys/nokogumbo) (>= 1.4.10)
* [Nokogiri](http://rubygems.org/gems/nokogiri) (>= 1.10)
* Soft dependency on [Nokogumbo](https://github.com/rubys/nokogumbo) (~> 2.0)

## Documentation
Full documentation available on [Rubydoc.info][Microdata doc]
Expand All @@ -68,13 +68,6 @@ use {RDF::Microdata::RdfaReader} directly.

The reader exposes a `#rdfa` method, which can be used to retrieve the transformed HTML+RDFa

### JSON-lD-based Reader
There is an experimental reader based on transforming Microdata to JSON-LD. To invoke
this, add the `jsonld: true` option to the {RDF::Microdata::Reader.new}, or
use {RDF::Microdata::JsonLdReader} directly.

The reader exposes a `#json` method, which can be used to retrieve the generated JSON-LD

## Resources
* [RDF.rb][RDF.rb]
* [Documentation](http://www.rubydoc.info/github/ruby-rdf/rdf-microdata/)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
2.2.3
3.1.0
1 change: 0 additions & 1 deletion lib/rdf/microdata.rb
Expand Up @@ -26,7 +26,6 @@ module Microdata
require 'rdf/microdata/format'
require 'rdf/microdata/vocab'
autoload :Expansion, 'rdf/microdata/expansion'
autoload :JsonLdReader, 'rdf/microdata/jsonld_reader'
autoload :Profile, 'rdf/microdata/profile'
autoload :RdfaReader, 'rdf/microdata/rdfa_reader'
autoload :Reader, 'rdf/microdata/reader'
Expand Down
5 changes: 2 additions & 3 deletions lib/rdf/microdata/expansion.rb
Expand Up @@ -26,7 +26,6 @@ def expand
repo = RDF::Repository.new
repo << self # Add default graph

count = repo.count
log_debug("expand") {"Loaded #{repo.size} triples into default graph"}

repo = owl_entailment(repo)
Expand All @@ -38,7 +37,7 @@ def expand
end

def rule(name, &block)
Rule.new(name, @options, block)
Rule.new(name, **@options, &block)
end

##
Expand Down Expand Up @@ -72,7 +71,7 @@ class Rule
# r.execute(queryable) {|statement| puts statement.inspect}
#
# @param [String] name
def initialize(name, options = {}, &block)
def initialize(name, **options, &block)
@antecedents = []
@consequents = []
@options = options.dup
Expand Down
32 changes: 3 additions & 29 deletions lib/rdf/microdata/format.rb
Expand Up @@ -55,7 +55,7 @@ def self.cli_commands
format: :microdata
},
option_use: {output_format: :disabled},
lambda: ->(files, options) do
lambda: ->(files, **options) do
out = options[:output] || $stdout
xsl = Nokogiri::XSLT(%(<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="indent-increment" select="' '"/>
Expand Down Expand Up @@ -107,15 +107,15 @@ def self.cli_commands
# If files are empty, either use options[::evaluate]
input = options[:evaluate] ? StringIO.new(options[:evaluate]) : STDIN
input.set_encoding(options.fetch(:encoding, Encoding::UTF_8))
RDF::Microdata::Reader.new(input, options.merge(rdfa: true)) do |reader|
RDF::Microdata::Reader.new(input, **options.merge(rdfa: true)) do |reader|
reader.rdfa.xpath("//text()").each do |txt|
txt.content = txt.content.to_s.strip
end
out.puts xsl.apply_to(reader.rdfa).to_s
end
else
files.each do |file|
RDF::Microdata::Reader.open(file, options.merge(rdfa: true)) do |reader|
RDF::Microdata::Reader.open(file, **options.merge(rdfa: true)) do |reader|
reader.rdfa.xpath("//text()").each do |txt|
txt.content = txt.content.to_s.strip
end
Expand All @@ -125,32 +125,6 @@ def self.cli_commands
end
end
},
"to-jsonld": {
description: "Transform HTML+Microdata into JSON-LD",
parse: false,
help: "to-jsonld files ...\nTransform HTML+Microdata into JSON-LD",
filter: {
format: :microdata
},
option_use: {output_format: :disabled},
lambda: ->(files, options) do
out = options[:output] || $stdout
if files.empty?
# If files are empty, either use options[::evaluate]
input = options[:evaluate] ? StringIO.new(options[:evaluate]) : STDIN
input.set_encoding(options.fetch(:encoding, Encoding::UTF_8))
RDF::Microdata::Reader.new(input, options.merge(jsonld: true)) do |reader|
out.puts reader.jsonld.to_json(::JSON::LD::JSON_STATE)
end
else
files.each do |file|
RDF::Microdata::Reader.open(file, options.merge(jsonld: true)) do |reader|
out.puts reader.jsonld.to_json(::JSON::LD::JSON_STATE)
end
end
end
end
},
}
end
end
Expand Down

0 comments on commit 6eabc80

Please sign in to comment.