From 79dce290c26d1383fe015b07df79b76b46586c73 Mon Sep 17 00:00:00 2001 From: Michael Scrivo Date: Tue, 24 Nov 2026 15:24:36 -0500 Subject: [PATCH 1/3] refactor: remove unused previous_node helpers previous_node_name and previous_node_is_text? are private and have no callers; they were the only uncovered lines in the library. Co-Authored-By: Claude Opus 5.5 --- lib/html2text.rb | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/lib/html2text.rb b/lib/html2text.rb index e6dca85..448c2a9 100644 --- a/lib/html2text.rb +++ b/lib/html2text.rb @@ -232,25 +232,4 @@ def next_node_name(node) def next_node_is_text?(node) !node.next_sibling.nil? && node.next_sibling.text? && !node.next_sibling.text.strip.empty? end - - def previous_node_name(node) - previous_node = node.previous_sibling - until previous_node.nil? - break if previous_node.element? - - previous_node = previous_node.previous_sibling - end - - return unless previous_node&.element? - - previous_node.name.downcase - end - - def previous_node_is_text?(node) - !node.previous_sibling.nil? && node.previous_sibling.text? && !node.previous_sibling.text.strip.empty? - end - - # def previous_node_is_not_text?(node) - # return node.previous_sibling.nil? || !node.previous_sibling.text? || node.previous_sibling.text.strip.empty? - # end end From 4c06f529ee87d6af14214e41028e0cb1fb9727e5 Mon Sep 17 00:00:00 2001 From: Michael Scrivo Date: Tue, 24 Nov 2026 15:24:36 -0500 Subject: [PATCH 2/3] test: enforce 100% line and branch coverage with SimpleCov Also bumps bundler-audit to 0.9.3; 0.6.1 requires bundler < 3. Co-Authored-By: Claude Opus 5.5 --- .gitignore | 1 + Gemfile.lock | 12 +++++++----- README.md | 2 +- html2text.gemspec | 1 + spec/spec_helper.rb | 7 +++++++ 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 41896d2..2b05839 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ spec/examples/*.output .byebug_history .idea +coverage/ diff --git a/Gemfile.lock b/Gemfile.lock index e0deaa1..14f51dd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,9 +8,9 @@ GEM remote: https://rubygems.org/ specs: ast (2.4.3) - bundler-audit (0.6.1) - bundler (>= 1.2.0, < 3) - thor (~> 0.18) + bundler-audit (0.9.3) + bundler (>= 1.2.0) + thor (~> 1.0) colorize (0.7.7) diff-lcs (1.3) json (2.21.2) @@ -70,7 +70,8 @@ GEM lint_roller (~> 1.1) rubocop (>= 1.72.1) ruby-progressbar (1.13.0) - thor (0.20.3) + simplecov (1.3.2) + thor (1.5.0) unicode-display_width (3.2.0) unicode-emoji (~> 4.1) unicode-emoji (4.2.0) @@ -90,6 +91,7 @@ DEPENDENCIES rubocop rubocop-performance rubocop-rake + simplecov BUNDLED WITH - 4.1.0 + 4.1.0 diff --git a/README.md b/README.md index 29b2558..6054bc9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -html2text ![Build](https://github.com/soundasleep/html2text_ruby/actions/workflows/build.yml/badge.svg) [![Gem Version](https://badge.fury.io/rb/html2text.svg)](https://badge.fury.io/rb/html2text) +html2text ![Build](https://github.com/soundasleep/html2text_ruby/actions/workflows/build.yml/badge.svg) [![Gem Version](https://badge.fury.io/rb/html2text.svg)](https://badge.fury.io/rb/html2text) ![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen) --- `html2text` is a very simple gem that uses DOM methods to convert HTML into a format similar to what would be diff --git a/html2text.gemspec b/html2text.gemspec index 4a29d3d..2e122eb 100644 --- a/html2text.gemspec +++ b/html2text.gemspec @@ -29,6 +29,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'rubocop' s.add_development_dependency 'rubocop-performance' s.add_development_dependency 'rubocop-rake' + s.add_development_dependency 'simplecov' s.metadata['rubygems_mfa_required'] = 'true' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e2acb5a..c1bd1ba 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,12 @@ # frozen_string_literal: true +require 'simplecov' +SimpleCov.start do + enable_coverage :branch + add_filter '/spec/' + minimum_coverage line: 100, branch: 100 +end + require 'rspec' require 'rspec/collection_matchers' From ba2cdea1674c3e4f20ffaa28deecd7dafdd2cf5e Mon Sep 17 00:00:00 2001 From: Michael Scrivo Date: Tue, 24 Nov 2026 15:24:36 -0500 Subject: [PATCH 3/3] ci: run RuboCop from the default rake task Running 'rake' locally now lints too. The CI test job already runs 'rake', so the separate lint job is redundant and removed. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/build.yml | 18 +----------------- Rakefile | 6 +++++- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9918012..0416db1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,21 +30,5 @@ jobs: with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true # runs 'bundle install' and caches installed gems automatically - - name: Run tests + - name: Run tests and RuboCop run: bundle exec rake - - lint: - runs-on: ubuntu-latest - strategy: - matrix: - ruby-version: ['3.3', '3.4', '4.0'] - - steps: - - uses: actions/checkout@v7 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby-version }} - bundler-cache: true # runs 'bundle install' and caches installed gems automatically - - name: Run Rubocop - run: bundle exec rubocop diff --git a/Rakefile b/Rakefile index e8a1339..9b7e4a2 100644 --- a/Rakefile +++ b/Rakefile @@ -13,4 +13,8 @@ require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) -task default: :spec +require 'rubocop/rake_task' + +RuboCop::RakeTask.new + +task default: %i[spec rubocop]