Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
spec/examples/*.output
.byebug_history
.idea
coverage/
12 changes: 7 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -90,6 +91,7 @@ DEPENDENCIES
rubocop
rubocop-performance
rubocop-rake
simplecov

BUNDLED WITH
4.1.0
4.1.0
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 5 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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]
1 change: 1 addition & 0 deletions html2text.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 0 additions & 21 deletions lib/html2text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -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'

Expand Down