Skip to content

Commit

Permalink
Finish 3.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Apr 3, 2023
2 parents 2ada0d9 + 9ef1fcb commit f5050e7
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 54 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/ci.yml
Expand Up @@ -20,19 +20,13 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby:
- 2.6
- 2.7
- 3.0
- 3.1
- ruby-head
- jruby
ruby: [2.6, 2.7, '3.0', 3.1, 3.2, ruby-head, jruby]
gemfile:
- Gemfile
- Gemfile-pure
steps:
- name: Clone repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/generate-docs.yml
@@ -0,0 +1,27 @@
name: Build & deploy documentation
on:
push:
branches:
- master
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
name: Update gh-pages with docs
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1"
- name: Install required gem dependencies
run: gem install yard --no-document
- name: Build YARD Ruby Documentation
run: yardoc
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./doc/yard
publish_branch: gh-pages
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -5,7 +5,7 @@ gemspec
gem "rdf", github: "ruby-rdf/rdf", branch: "develop"
gem "rdf-spec", github: "ruby-rdf/rdf-spec", branch: "develop"
gem "rdf-xsd", github: "ruby-rdf/rdf-xsd", branch: "develop"
gem "nokogiri", '~> 1.12', platforms: [:mri, :jruby]
gem "nokogiri", '~> 1.13', '>= 1.13.4', platforms: [:mri, :jruby] # Ruby 2.6
gem 'equivalent-xml', '~> 0.6'

group :development, :test do
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -399,7 +399,7 @@ The template hash defines four Haml templates:
## Dependencies
* [Ruby](https://ruby-lang.org/) (>= 2.6)
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.2)
* [Haml](https://rubygems.org/gems/haml) (~> 5.2)
* [Haml](https://rubygems.org/gems/haml) (>- 5.2, < 7)
* [HTMLEntities](https://rubygems.org/gems/htmlentities) (~> 4.3)
* Soft dependency on [Nokogiri](https://rubygems.org/gems/nokogiri) (~> 1.12)

Expand Down Expand Up @@ -473,7 +473,7 @@ see <https://unlicense.org/> or the accompanying [UNLICENSE](UNLICENSE) file.
[HTML+RDFa 1.1]: https://www.w3.org/TR/rdfa-in-html/ "HTML+RDFa 1.1"
[RDFa-test-suite]: https://rdfa.info/test-suite/ "RDFa test suite"
[Role Attr]: https://www.w3.org/TR/role-attribute/ "Role Attribute"
[RDFa doc]: https://rubydoc.info/github/ruby-rdf/rdf-rdfa/frames
[RDFa doc]: https://ruby-rdf.github.io/rdf-rdfa/frames
[Haml]: https://haml-lang.com/
[Turtle]: https://www.w3.org/TR/2011/WD-turtle-20110809/
[Nokogiri]: https://www.nokogiri.org
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
3.2.0
3.2.1
3 changes: 2 additions & 1 deletion lib/rdf/rdfa/format.rb
Expand Up @@ -21,7 +21,8 @@ class Format < RDF::Format
content_encoding 'utf-8'
content_type 'text/html;q=0.5',
aliases: %w(application/xhtml+xml;q=0.7 image/svg+xml;q=0.4),
extensions: [:html, :xhtml, :svg]
extensions: [:html, :xhtml, :svg],
uri: 'http://www.w3.org/ns/formats/RDFa'
reader { RDF::RDFa::Reader }
writer { RDF::RDFa::Writer }

Expand Down
2 changes: 1 addition & 1 deletion lib/rdf/rdfa/reader.rb
Expand Up @@ -245,7 +245,7 @@ def inspect

##
# RDFa Reader options
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Reader#options-class_method
# @see https://ruby-rdf.github.io/rdf/RDF/Reader#options-class_method
def self.options
super + [
RDF::CLI::Option.new(
Expand Down
12 changes: 10 additions & 2 deletions lib/rdf/rdfa/writer.rb
Expand Up @@ -75,7 +75,7 @@ class Writer < RDF::Writer

##
# RDFa Writer options
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Writer#options-class_method
# @see https://ruby-rdf.github.io/rdf/RDF/Writer#options-class_method
def self.options
super + [
RDF::CLI::Option.new(
Expand Down Expand Up @@ -721,6 +721,8 @@ def get_curie(resource)
# @return [String]
# Entity-encoded string
def escape_entities(str)
# Haml 6 does escaping
return str if Haml.const_defined?(:Template)
CGI.escapeHTML(str).gsub(/[\n\r]/) {|c| '&#x' + c.unpack('h').first + ';'}
end

Expand Down Expand Up @@ -761,7 +763,13 @@ def hamlify(template, locals = {})
template = template.align_left
log_debug {"hamlify locals: #{locals.inspect}"}

Haml::Engine.new(template, @options[:haml_options] || HAML_OPTIONS).render(self, locals) do |*args|
haml_opts = @options[:haml_options] || HAML_OPTIONS
haml_runner = if Haml.const_defined?(:Template)
Haml::Template.new(**haml_opts) {template}
else
Haml::Engine.new(template, **haml_opts)
end
haml_runner.render(self, locals) do |*args|
yield(*args) if block_given?
end
rescue Haml::Error => e
Expand Down
66 changes: 33 additions & 33 deletions lib/rdf/rdfa/writer/haml_templates.rb
Expand Up @@ -10,11 +10,11 @@ class Writer
doc: %q(
!!! XML
!!! 5
%html{xmlns: "http://www.w3.org/1999/xhtml", lang: lang, prefix: prefix}
%html{**{xmlns: "http://www.w3.org/1999/xhtml", lang: lang, prefix: prefix}.compact}
- if base || title
%head
- if base
%base{href: base}
%base{**{href: base}.compact}
- if title
%title= title
%body
Expand All @@ -33,13 +33,13 @@ class Writer
# Yield: predicates.each
subject: %q(
- if element == :li
%li{rel: rel, resource: (about || resource), typeof: typeof, inlist: inlist}
%li{**{rel: rel, resource: (about || resource), typeof: typeof, inlist: inlist}.compact}
- if typeof
%span.type!= typeof
- predicates.each do |predicate|
!= yield(predicate)
- else
%div{rel: rel, resource: (about || resource), typeof: typeof, inlist: inlist}
%div{**{rel: rel, resource: (about || resource), typeof: typeof, inlist: inlist}.compact}
- if typeof
%span.type!= typeof
- predicates.each do |predicate|
Expand All @@ -53,7 +53,7 @@ class Writer
# Otherwise, render result
property_value: %q(
- if heading_predicates.include?(predicate) && object.literal?
%h1{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}= escape_entities(get_value(object))
%h1{**{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}.compact}= escape_entities(get_value(object))
- else
%div.property
%span.label
Expand All @@ -63,13 +63,13 @@ class Writer
- elsif get_curie(object) == 'rdf:nil'
%span{rel: get_curie(predicate), inlist: ''}
- elsif object.node?
%span{property: get_curie(predicate), resource: get_curie(object), inlist: inlist}= get_curie(object)
%span{**{property: get_curie(predicate), resource: get_curie(object), inlist: inlist}.compact}= get_curie(object)
- elsif object.uri?
%a{property: get_curie(predicate), href: object.to_s, inlist: inlist}= object.to_s
%a{**{property: get_curie(predicate), href: object.to_s, inlist: inlist}.compact}= object.to_s
- elsif object.datatype == RDF.XMLLiteral
%span{property: get_curie(predicate), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}<!= get_value(object)
%span{**{property: get_curie(predicate), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}.compact}<!= get_value(object)
- else
%span{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}= escape_entities(get_value(object))
%span{**{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}.compact}= escape_entities(get_value(object))
),

# Output for multi-valued properties
Expand All @@ -84,14 +84,14 @@ class Writer
- if res = yield(object)
!= res
- elsif object.node?
%li{property: get_curie(predicate), resource: get_curie(object), inlist: inlist}= get_curie(object)
%li{**{property: get_curie(predicate), resource: get_curie(object), inlist: inlist}.compact}= get_curie(object)
- elsif object.uri?
%li
%a{property: get_curie(predicate), href: object.to_s, inlist: inlist}= object.to_s
%a{**{property: get_curie(predicate), href: object.to_s, inlist: inlist}.compact}= object.to_s
- elsif object.datatype == RDF.XMLLiteral
%li{property: get_curie(predicate), lang: get_lang(object), datatype: get_curie(object.datatype), inlist: inlist}<!= get_value(object)
%li{**{property: get_curie(predicate), lang: get_lang(object), datatype: get_curie(object.datatype), inlist: inlist}.compact}<!= get_value(object)
- else
%li{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}= escape_entities(get_value(object))
%li{**{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}.compact}= escape_entities(get_value(object))
),
}

Expand All @@ -106,10 +106,10 @@ class Writer
doc: %q(
!!! XML
!!! 5
%html{xmlns: "http://www.w3.org/1999/xhtml", lang: lang, prefix: prefix}
%html{**{xmlns: "http://www.w3.org/1999/xhtml", lang: lang, prefix: prefix}.compact}
- if base
%head
%base{href: base}
%base{*{href: base}.compact}
%body
- subjects.each do |subject|
!= yield(subject)
Expand All @@ -121,7 +121,7 @@ class Writer
# Locals: about, typeof, predicates, :inlist
# Yield: predicates.each
subject: %q(
%div{rel: rel, resource: (about || resource), typeof: typeof}
%div{**{rel: rel, resource: (about || resource), typeof: typeof}.compact}
- predicates.each do |predicate|
!= yield(predicate)
),
Expand All @@ -138,13 +138,13 @@ class Writer
- elsif get_curie(object) == 'rdf:nil'
%span{rel: get_curie(predicate), inlist: ''}
- elsif object.node?
%span{property: get_curie(predicate), resource: get_curie(object), inlist: inlist}= get_curie(object)
%span{**{property: get_curie(predicate), resource: get_curie(object), inlist: inlist}.compact}= get_curie(object)
- elsif object.uri?
%a{property: get_curie(predicate), href: object.to_s, inlist: inlist}= object.to_s
%a{**{property: get_curie(predicate), href: object.to_s, inlist: inlist}.compact}= object.to_s
- elsif object.datatype == RDF.XMLLiteral
%span{property: get_curie(predicate), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}<!= get_value(object)
%span{**{property: get_curie(predicate), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}.compact}<!= get_value(object)
- else
%span{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}= escape_entities(get_value(object))
%span{**{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}.compact}= escape_entities(get_value(object))
)
}

Expand All @@ -156,7 +156,7 @@ class Writer
doc: %q(
!!! XML
!!! 5
%html{xmlns: "http://www.w3.org/1999/xhtml", lang: lang, prefix: prefix}
%html{**{xmlns: "http://www.w3.org/1999/xhtml", lang: lang, prefix: prefix}.compact}
- if base || title
%head
- if base
Expand Down Expand Up @@ -189,21 +189,21 @@ class Writer
# Yield: predicates.each
subject: %q(
- if element == :li
%li{rel: rel, resource: (about || resource), typeof: typeof, inlist: inlist}
%li{**{rel: rel, resource: (about || resource), typeof: typeof, inlist: inlist}.compact}
- if typeof
%span.type!= typeof
%table.properties
- predicates.each do |predicate|
!= yield(predicate)
- elsif rel
%td{rel: rel, resource: (about || resource), typeof: typeof, inlist: inlist}
%td{**{rel: rel, resource: (about || resource), typeof: typeof, inlist: inlist}.compact}
- if typeof
%span.type!= typeof
%table.properties
- predicates.each do |predicate|
!= yield(predicate)
- else
%div{resource: (about || resource), typeof: typeof, inlist: inlist}
%div{**{resource: (about || resource), typeof: typeof, inlist: inlist}.compact}
- if typeof
%span.type!= typeof
%table.properties
Expand All @@ -218,7 +218,7 @@ class Writer
# Otherwise, render result
property_value: %q(
- if heading_predicates.include?(predicate) && object.literal?
%h1{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}= escape_entities(get_value(object))
%h1{**{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}.compact}= escape_entities(get_value(object))
- else
%tr.property
%td.label
Expand All @@ -228,14 +228,14 @@ class Writer
- elsif get_curie(object) == 'rdf:nil'
%td{rel: get_curie(predicate), inlist: ''}= "Empty"
- elsif object.node?
%td{property: get_curie(predicate), resource: get_curie(object), inlist: inlist}= get_curie(object)
%td{**{property: get_curie(predicate), resource: get_curie(object), inlist: inlist}.compact}= get_curie(object)
- elsif object.uri?
%td
%a{property: get_curie(predicate), href: object.to_s, inlist: inlist}= object.to_s
%a{**{property: get_curie(predicate), href: object.to_s, inlist: inlist}.compact}= object.to_s
- elsif object.datatype == RDF.XMLLiteral
%td{property: get_curie(predicate), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}<!= get_value(object)
%td{**{property: get_curie(predicate), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}.compact}<!= get_value(object)
- else
%td{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}= escape_entities(get_value(object))
%td{**{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}.compact}= escape_entities(get_value(object))
),

# Output for multi-valued properties
Expand All @@ -251,14 +251,14 @@ class Writer
- if res = yield(object)
!= res
- elsif object.node?
%li{property: get_curie(predicate), resource: get_curie(object), inlist: inlist}= get_curie(object)
%li{**{property: get_curie(predicate), resource: get_curie(object), inlist: inlist}.compact}= get_curie(object)
- elsif object.uri?
%li
%a{property: get_curie(predicate), href: object.to_s, inlist: inlist}= object.to_s
%a{**{property: get_curie(predicate), href: object.to_s, inlist: inlist}.compact}= object.to_s
- elsif object.datatype == RDF.XMLLiteral
%li{property: get_curie(predicate), lang: get_lang(object), datatype: get_curie(object.datatype), inlist: inlist}<!= get_value(object)
%li{**{property: get_curie(predicate), lang: get_lang(object), datatype: get_curie(object.datatype), inlist: inlist}.compact}<!= get_value(object)
- else
%li{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}= escape_entities(get_value(object))
%li{**{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}.compact}= escape_entities(get_value(object))
),
}
HAML_TEMPLATES = {base: BASE_HAML, min: MIN_HAML, distiller: DISTILLER_HAML}
Expand Down
9 changes: 8 additions & 1 deletion rdf-rdfa.gemspec
Expand Up @@ -10,6 +10,13 @@ Gem::Specification.new do |gem|
gem.license = 'Unlicense'
gem.summary = "RDFa reader/writer for RDF.rb."
gem.description = "RDF::RDFa is an RDFa reader/writer for Ruby using the RDF.rb library suite."
gem.metadata = {
"documentation_uri" => "https://ruby-rdf.github.io/rdf-rdfa",
"bug_tracker_uri" => "https://github.com/ruby-rdf/rdf-rdfa/issues",
"homepage_uri" => "https://github.com/ruby-rdf/rdf-rdfa",
"mailing_list_uri" => "https://lists.w3.org/Archives/Public/public-rdf-ruby/",
"source_code_uri" => "https://github.com/ruby-rdf/rdf-rdfa",
}

gem.authors = %w(Gregg Kellogg)
gem.email = 'public-rdf-ruby@w3.org'
Expand All @@ -23,7 +30,7 @@ Gem::Specification.new do |gem|

gem.add_runtime_dependency 'rdf', '~> 3.2'
gem.add_runtime_dependency 'rdf-vocab', '~> 3.2'
gem.add_runtime_dependency 'haml', '~> 5.2'
gem.add_runtime_dependency 'haml', '>= 5.2', "< 7"
gem.add_runtime_dependency 'rdf-xsd', '~> 3.2'
gem.add_runtime_dependency 'rdf-aggregate-repo', '~> 3.2'
gem.add_runtime_dependency 'htmlentities', '~> 4.3'
Expand Down
8 changes: 4 additions & 4 deletions script/tc
Expand Up @@ -92,7 +92,7 @@ options = {

opts = GetoptLong.new(
["--help", "-?", GetoptLong::NO_ARGUMENT],
["--dbg", GetoptLong::NO_ARGUMENT],
["--debug", GetoptLong::NO_ARGUMENT],
["--format", GetoptLong::REQUIRED_ARGUMENT],
["--host-language", "-h", GetoptLong::REQUIRED_ARGUMENT],
["--library", GetoptLong::REQUIRED_ARGUMENT],
Expand All @@ -107,7 +107,7 @@ def help(options)
puts "Usage: #{$0} [options] [test-number ...]"
puts "Options:"
puts " --dump: Dump raw output, otherwise serialize to Ruby"
puts " --dbg: Display detailed debug output"
puts " --debug: Display detailed debug output"
puts " --expand Expand graph with vocab_expansion option"
puts " --format: Format for output, defaults to #{options[:format].inspect}"
puts " --host-language: Run for specified host language, defaults to #{options[:host_language]}"
Expand All @@ -124,7 +124,7 @@ end
opts.each do |opt, arg|
case opt
when '--help' then help(options)
when '--dbg' then logger.level = Logger::DEBUG
when '--debug' then logger.level = Logger::DEBUG
when '--format' then options[:format] = arg.to_sym
when '--host-language' then options[:host_language] = arg
when '--library' then options[:library] = arg.to_sym
Expand All @@ -142,7 +142,7 @@ result_count = {}
Fixtures::TestCase.for_specific(options[:host_language], options[:version]) do |tc|
next unless ARGV.empty? || ARGV.any? {|n| tc.num.match(/#{n}/)}
next if tc.classification.to_s =~ /deprecated/
run_tc(tc, options.merge(result_count: result_count))
run_tc(tc, **options.merge(result_count: result_count))
end

result_count.each do |result, count|
Expand Down
4 changes: 4 additions & 0 deletions spec/format_spec.rb
Expand Up @@ -36,6 +36,10 @@
specify {expect(RDF::RDFa::Format.to_sym).to eq :rdfa}
end

describe "#to_uri" do
specify {expect(described_class.to_uri).to eq RDF::URI('http://www.w3.org/ns/formats/RDFa')}
end

describe ".detect" do
{
about: '<div about="foo"></div>',
Expand Down

0 comments on commit f5050e7

Please sign in to comment.