From 434d48fa4bf0bbca8e0f4bfac7e3a2859ea031de Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Fri, 28 Jan 2022 11:42:35 -0800 Subject: [PATCH 1/6] Update documentation links to use gh-pages, and add action to publish gh-pages from Yard docs. --- .github/workflows/ci.yml | 2 +- .github/workflows/generate-docs.yml | 27 +++++++++++++++++++++++++++ README.md | 2 +- lib/rdf/rdfa/reader.rb | 2 +- lib/rdf/rdfa/writer.rb | 2 +- rdf-rdfa.gemspec | 7 +++++++ 6 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/generate-docs.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9eaddce..cbb9114 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: ruby: - 2.6 - 2.7 - - 3.0 + - "3.0" - 3.1 - ruby-head - jruby diff --git a/.github/workflows/generate-docs.yml b/.github/workflows/generate-docs.yml new file mode 100644 index 0000000..b8d16ed --- /dev/null +++ b/.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@v2 + - 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 diff --git a/README.md b/README.md index 6d918ef..36beb04 100755 --- a/README.md +++ b/README.md @@ -473,7 +473,7 @@ see 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 diff --git a/lib/rdf/rdfa/reader.rb b/lib/rdf/rdfa/reader.rb index 5020e3f..ea7ee84 100644 --- a/lib/rdf/rdfa/reader.rb +++ b/lib/rdf/rdfa/reader.rb @@ -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( diff --git a/lib/rdf/rdfa/writer.rb b/lib/rdf/rdfa/writer.rb index dcbe8c5..97af1fd 100644 --- a/lib/rdf/rdfa/writer.rb +++ b/lib/rdf/rdfa/writer.rb @@ -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( diff --git a/rdf-rdfa.gemspec b/rdf-rdfa.gemspec index 3eadc19..93d272b 100755 --- a/rdf-rdfa.gemspec +++ b/rdf-rdfa.gemspec @@ -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' From 9522e3361b98237c7a3c4f09c9e8b5bd335f5597 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Tue, 29 Mar 2022 13:25:02 -0700 Subject: [PATCH 2/6] Define the format URI to http://www.w3.org/ns/formats/RDFa. --- lib/rdf/rdfa/format.rb | 3 ++- spec/format_spec.rb | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/rdf/rdfa/format.rb b/lib/rdf/rdfa/format.rb index 327cbee..1666352 100644 --- a/lib/rdf/rdfa/format.rb +++ b/lib/rdf/rdfa/format.rb @@ -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 } diff --git a/spec/format_spec.rb b/spec/format_spec.rb index 784157b..8cc9701 100644 --- a/spec/format_spec.rb +++ b/spec/format_spec.rb @@ -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: '
', From fb9e6666c35131717ceeabe1fd347e02730788e8 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Wed, 4 Jan 2023 13:35:47 -0800 Subject: [PATCH 3/6] CI on 3.2. --- .github/workflows/ci.yml | 10 ++-------- .github/workflows/generate-docs.yml | 2 +- Gemfile | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cbb9114..7eb055f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/.github/workflows/generate-docs.yml b/.github/workflows/generate-docs.yml index b8d16ed..65aea93 100644 --- a/.github/workflows/generate-docs.yml +++ b/.github/workflows/generate-docs.yml @@ -10,7 +10,7 @@ jobs: name: Update gh-pages with docs steps: - name: Clone repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: diff --git a/Gemfile b/Gemfile index d90521f..18c90f2 100644 --- a/Gemfile +++ b/Gemfile @@ -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] gem 'equivalent-xml', '~> 0.6' group :development, :test do From dda33651cf52c25f62c82a39ea69e5f3453d1ddc Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Mon, 3 Apr 2023 15:46:48 -0700 Subject: [PATCH 4/6] Allow Haml versions >= 5.2 and < 7. --- Gemfile | 2 +- README.md | 2 +- lib/rdf/rdfa/writer.rb | 10 +++- lib/rdf/rdfa/writer/haml_templates.rb | 66 +++++++++++++-------------- rdf-rdfa.gemspec | 2 +- script/tc | 8 ++-- 6 files changed, 49 insertions(+), 41 deletions(-) diff --git a/Gemfile b/Gemfile index 18c90f2..f9269db 100644 --- a/Gemfile +++ b/Gemfile @@ -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.13', '>= 1.13.4', platforms: [:mri, :jruby] +gem "nokogiri", '~> 1.14', platforms: [:mri, :jruby] gem 'equivalent-xml', '~> 0.6' group :development, :test do diff --git a/README.md b/README.md index 36beb04..3c4ad69 100755 --- a/README.md +++ b/README.md @@ -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) diff --git a/lib/rdf/rdfa/writer.rb b/lib/rdf/rdfa/writer.rb index 97af1fd..50ed098 100644 --- a/lib/rdf/rdfa/writer.rb +++ b/lib/rdf/rdfa/writer.rb @@ -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 @@ -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 diff --git a/lib/rdf/rdfa/writer/haml_templates.rb b/lib/rdf/rdfa/writer/haml_templates.rb index 8ae19d0..4d20fa1 100644 --- a/lib/rdf/rdfa/writer/haml_templates.rb +++ b/lib/rdf/rdfa/writer/haml_templates.rb @@ -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 @@ -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| @@ -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 @@ -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} 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' diff --git a/script/tc b/script/tc index f04650e..8f0f281 100755 --- a/script/tc +++ b/script/tc @@ -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], @@ -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]}" @@ -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 @@ -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| From ff4314f7e34eb705506f517fb7e653c4a6f8e93a Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Mon, 3 Apr 2023 16:03:40 -0700 Subject: [PATCH 5/6] Rollback Nokogiri dependency in Gemfile until Ruby 2.6 is removed. --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index f9269db..0b0874b 100644 --- a/Gemfile +++ b/Gemfile @@ -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.14', 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 From 9ef1fcbecc49d66633b974d9a85b838a0c42b2e7 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Mon, 3 Apr 2023 16:20:55 -0700 Subject: [PATCH 6/6] Versioni 3.2.1. --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 944880f..e4604e3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.2.0 +3.2.1