diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9eaddce..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 new file mode 100644 index 0000000..65aea93 --- /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@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 diff --git a/Gemfile b/Gemfile index d90521f..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.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 diff --git a/README.md b/README.md index 6d918ef..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) @@ -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/VERSION b/VERSION index 944880f..e4604e3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.2.0 +3.2.1 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/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..50ed098 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( @@ -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} "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' @@ -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' 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| 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: '
',