diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d49a23..16487f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,17 +15,17 @@ jobs: runs-on: ubuntu-latest env: CI: true + 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 - ruby-head - #- jruby # No Nokogumbo on JRuby + - jruby steps: - name: Clone repository uses: actions/checkout@v2 @@ -34,7 +34,11 @@ jobs: with: ruby-version: ${{ matrix.ruby }} - name: Install dependencies - run: bundle install --jobs 4 --retry 3 + run: ruby --version; bundle install --jobs 4 --retry 3 - name: Run tests - run: bundle exec rspec spec - + 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 }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 83a126b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: ruby -script: "bundle exec rspec spec" -env: - - CI=true -rvm: - - 2.4 - - 2.5 - - 2.6 - - 2.7 - - jruby -cache: bundler -sudo: false -matrix: - allow_failures: - - rvm: jruby -dist: trusty diff --git a/Gemfile b/Gemfile index e33063c..f4d64cd 100644 --- a/Gemfile +++ b/Gemfile @@ -5,10 +5,9 @@ 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", '~> 2.0' group :development do - gem "json-ld", git: "https://github.com/ruby-rdf/json-ld", branch: "develop" + gem "json-ld", git: "https://github.com/ruby-rdf/json-ld", branch: "develop" 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" @@ -23,6 +22,6 @@ group :debug do end group :test do - gem 'simplecov', '~> 0.16', platforms: :mri - gem 'coveralls', '~> 0.8', platforms: :mri + gem 'simplecov', '~> 0.21', platforms: :mri + gem 'simplecov-lcov', '~> 0.8', platforms: :mri end diff --git a/README.md b/README.md index ea16205..1f502c5 100755 --- a/README.md +++ b/README.md @@ -15,7 +15,6 @@ RDF::Microdata parses [Microdata][] into statements or triples using the rules d * Microdata parser. * Uses Nokogiri for parsing HTML -* If available, uses [Nokogumbo][] gem for are pure-HTML5 parser with better error detection. Install with 'gem install rdf-microdata' @@ -52,7 +51,6 @@ If the `RDFa` parser is available, {RDF::Microdata::Format} will not assert cont * [RDF::XSD](https://rubygems.org/gems/rdf-xsd) (~> 3.1) * [HTMLEntities](https://rubygems.org/gems/htmlentities) ('~> 4.3') * [Nokogiri](https://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] @@ -116,4 +114,3 @@ see or the accompanying {file:UNLICENSE} file. [Microdata]: https://dev.w3.org/html5/md/Overview.html "HTML Microdata" [Microdata RDF]: https://dvcs.w3.org/hg/htmldata/raw-file/default/microdata-rdf/index.html "Microdata to RDF" [Microdata doc]: https://rubydoc.info/github/ruby-rdf/rdf-microdata/frames -[Nokogumbo]: https://github.com/rubys/nokogumbo/#readme diff --git a/VERSION b/VERSION index ff365e0..0aec50e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.1.3 +3.1.4 diff --git a/lib/rdf/microdata/rdfa_reader.rb b/lib/rdf/microdata/rdfa_reader.rb index 3157af9..343ea89 100644 --- a/lib/rdf/microdata/rdfa_reader.rb +++ b/lib/rdf/microdata/rdfa_reader.rb @@ -1,5 +1,4 @@ require 'rdf/rdfa' -require 'nokogumbo' module RDF::Microdata ## @@ -42,8 +41,12 @@ def initialize(input = $stdin, **options, &block) # Otherwise, default is utf-8 options[:encoding] ||= 'utf-8' options[:encoding] = options[:encoding].to_s if options[:encoding] - input = input.read if input.respond_to?(:read) - ::Nokogiri::HTML5(input.force_encoding(options[:encoding])) + begin + input = input.read if input.respond_to?(:read) + ::Nokogiri::HTML5(input.force_encoding(options[:encoding]), max_parse_errors: 1000) + rescue LoadError, NoMethodError + ::Nokogiri::HTML.parse(input, base_uri.to_s, options[:encoding]) + end end # For all members having @itemscope diff --git a/lib/rdf/microdata/reader/nokogiri.rb b/lib/rdf/microdata/reader/nokogiri.rb index 561330c..4b851cd 100644 --- a/lib/rdf/microdata/reader/nokogiri.rb +++ b/lib/rdf/microdata/reader/nokogiri.rb @@ -192,10 +192,9 @@ def initialize_html(input, **options) options[:encoding] = options[:encoding].to_s if options[:encoding] begin - require 'nokogumbo' unless defined?(::Nokogumbo) input = input.read if input.respond_to?(:read) ::Nokogiri::HTML5(input.force_encoding(options[:encoding]), max_parse_errors: 1000) - rescue LoadError + rescue LoadError, NoMethodError ::Nokogiri::HTML.parse(input, base_uri.to_s, options[:encoding]) end end diff --git a/rdf-microdata.gemspec b/rdf-microdata.gemspec index a0d124a..f184dbd 100755 --- a/rdf-microdata.gemspec +++ b/rdf-microdata.gemspec @@ -24,7 +24,7 @@ Gem::Specification.new do |gem| gem.add_runtime_dependency 'rdf-rdfa', '~> 3.1', '>= 3.1.3' gem.add_runtime_dependency 'rdf-xsd', '~> 3.1' gem.add_runtime_dependency 'htmlentities', '~> 4.3' - gem.add_runtime_dependency 'nokogiri' , '~> 1.10' # 1.11 Ruby 2.5 + gem.add_runtime_dependency 'nokogiri' , '~> 1.12' gem.add_development_dependency 'equivalent-xml' , '~> 0.6' gem.add_development_dependency 'yard' , '~> 0.9' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 62e89fa..b338b77 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -4,7 +4,6 @@ require "bundler/setup" require 'rspec' require 'rdf/isomorphic' -require 'rdf/microdata' require 'rdf/turtle' require 'rdf/spec' require 'rdf/spec/matchers' @@ -19,18 +18,25 @@ begin require 'simplecov' - require 'coveralls' + require 'simplecov-lcov' + + SimpleCov::Formatter::LcovFormatter.config do |config| + #Coveralls is coverage by default/lcov. Send info results + config.report_with_single_file = true + config.single_report_path = 'coverage/lcov.info' + end + SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([ SimpleCov::Formatter::HTMLFormatter, - Coveralls::SimpleCov::Formatter + SimpleCov::Formatter::LcovFormatter ]) SimpleCov.start do add_filter "/spec/" end - Coveralls.wear! rescue LoadError => e STDERR.puts "Coverage Skipped: #{e.message}" end +require 'rdf/microdata' # Heuristically detect the input stream def detect_format(stream)