nokogiri-html-ext 0.4.0 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 746b9d0d7073149ccc6a40216589a3a1ee5eee93a6c4913c8adefdfcebcd1aa6
4
- data.tar.gz: 1319d933924bd467b4130fdadc0207babd2d748278ca0d35a21a37575310c450
3
+ metadata.gz: a1e8ccc895065ee004f1a9af49239a904bd8502c3ab04de7d3847c3853e00fc7
4
+ data.tar.gz: a3dad0ed90b2c1e9c21495fb8bf5c5a1657347141fb314c8c8c74c63d5a897ca
5
5
  SHA512:
6
- metadata.gz: ad763192112beed01a81baa4826b434e6ef942b3b04e5c7629af130c8a6e3a5225fde4dd2deeb5aab505d4b0c5c228c31170e6b5843c843d50031f2e5b361d2a
7
- data.tar.gz: f7e77bfae05a60f2a0f7bab509a9879befc6690e4f0cad879b2ac116faa608646ebe5118ae59fd9a6a3cdb71e32e02ae5186a6ca7b3eca9fda0e66085275d92e
6
+ metadata.gz: 67f1cdaa630087d202ac0cd4b524a4f125755cac8f727dcece8d8a13b8d352b4ee100a0fa4e045b1da87ef5a709e147410b34a2bb7aebbb7d152357536837324
7
+ data.tar.gz: bb27e089de5d905bafb9f4f8c129a474686b487585fd745c094abe0d623e8499748af76cc7bb63a669b207aad2b71fd51e4695cb81eb1cab38e0c1fb259c20e9
data/CHANGELOG.md CHANGED
@@ -1,6 +1,22 @@
1
1
  # Changelog
2
2
 
3
- ## 0.4.0 / unreleased
3
+ ## 0.4.2 / 2023-12-30
4
+
5
+ - Add `source_code_uri` to metadata (fd29f7c)
6
+
7
+ ## 0.4.1 / 2023-12-07
8
+
9
+ - Add publish workflow (039abd0)
10
+ - Use `filter_map` instead of `compact` and `map` (ab574c9)
11
+ - Add ignored revs file (3e24d9f)
12
+ - RuboCop: address Style/StringLiterals warnings (a04b4d3)
13
+ - Update to newest rubocop-configs format (0ed51ce)
14
+ - Update RSpec configuration (#8) (4968bee)
15
+ - Update development Ruby version (#7) (0e4613a)
16
+ - Refactor CI workflow (#6) (5259b68)
17
+ - Remove CodeClimate (#5) (284fce7)
18
+
19
+ ## 0.4.0 / 2023-01-20
4
20
 
5
21
  - Improve (hopefully) handling of non-ASCII input (6d1fc4d)
6
22
  - Update Nokogiri version constraint to >= 1.14 (4b7ed74)
data/README.md CHANGED
@@ -5,8 +5,6 @@
5
5
  [![Gem](https://img.shields.io/gem/v/nokogiri-html-ext.svg?logo=rubygems&style=for-the-badge)](https://rubygems.org/gems/nokogiri-html-ext)
6
6
  [![Downloads](https://img.shields.io/gem/dt/nokogiri-html-ext.svg?logo=rubygems&style=for-the-badge)](https://rubygems.org/gems/nokogiri-html-ext)
7
7
  [![Build](https://img.shields.io/github/actions/workflow/status/jgarber623/nokogiri-html-ext/ci.yml?branch=main&logo=github&style=for-the-badge)](https://github.com/jgarber623/nokogiri-html-ext/actions/workflows/ci.yml)
8
- [![Maintainability](https://img.shields.io/codeclimate/maintainability/jgarber623/nokogiri-html-ext.svg?logo=code-climate&style=for-the-badge)](https://codeclimate.com/github/jgarber623/nokogiri-html-ext)
9
- [![Coverage](https://img.shields.io/codeclimate/c/jgarber623/nokogiri-html-ext.svg?logo=code-climate&style=for-the-badge)](https://codeclimate.com/github/jgarber623/nokogiri-html-ext/code)
10
8
 
11
9
  ## Key features
12
10
 
@@ -16,24 +14,18 @@
16
14
 
17
15
  ## Getting Started
18
16
 
19
- Before installing and using nokogiri-html-ext, you'll want to have [Ruby](https://www.ruby-lang.org) 2.7 (or newer) installed. It's recommended that you use a Ruby version managment tool like [rbenv](https://github.com/rbenv/rbenv), [chruby](https://github.com/postmodern/chruby), or [rvm](https://github.com/rvm/rvm).
17
+ Before installing and using nokogiri-html-ext, you'll want to have [Ruby](https://www.ruby-lang.org) 2.7 (or newer) installed. Using a Ruby version managment tool like [rbenv](https://github.com/rbenv/rbenv), [chruby](https://github.com/postmodern/chruby), or [rvm](https://github.com/rvm/rvm) is recommended.
20
18
 
21
- nokogiri-html-ext is developed using Ruby 2.7.7 and is additionally tested against Ruby 3.0, 3.1, and 3.2 using [GitHub Actions](https://github.com/jgarber623/nokogiri-html-ext/actions).
19
+ nokogiri-html-ext is developed using Ruby 2.7.8 and is tested against additional Ruby versions using [GitHub Actions](https://github.com/jgarber623/nokogiri-html-ext/actions).
22
20
 
23
21
  ## Installation
24
22
 
25
- If you're using [Bundler](https://bundler.io) to manage gem dependencies, add nokogiri-html-ext to your project's Gemfile:
23
+ Add nokogiri-html-ext to your project's `Gemfile` and run `bundle install`:
26
24
 
27
25
  ```ruby
28
- gem 'nokogiri-html-ext'
29
- ```
30
-
31
- …and run `bundle install` in your shell.
32
-
33
- To install the gem manually, run the following in your shell:
26
+ source "https://rubygems.org"
34
27
 
35
- ```sh
36
- gem install nokogiri-html-ext
28
+ gem "nokogiri-html-ext"
37
29
  ```
38
30
 
39
31
  ## Usage
@@ -43,19 +35,19 @@ gem install nokogiri-html-ext
43
35
  nokogiri-html-ext provides two helper methods for getting and setting a document's `<base>` element's `href` attribute. The first, `base_href`, retrieves the element's `href` attribute value if it exists.
44
36
 
45
37
  ```ruby
46
- require 'nokogiri/html-ext'
38
+ require "nokogiri/html-ext"
47
39
 
48
- doc = Nokogiri::HTML('<html><body>Hello, world!</body></html>')
40
+ doc = Nokogiri::HTML(%(<html><body>Hello, world!</body></html>))
49
41
 
50
42
  doc.base_href
51
43
  #=> nil
52
44
 
53
- doc = Nokogiri::HTML('<html><head><base target="_top"><body>Hello, world!</body></html>')
45
+ doc = Nokogiri::HTML(%(<html><head><base target="_top"><body>Hello, world!</body></html>))
54
46
 
55
47
  doc.base_href
56
48
  #=> nil
57
49
 
58
- doc = Nokogiri::HTML('<html><head><base href="/foo"><body>Hello, world!</body></html>')
50
+ doc = Nokogiri::HTML(%(<html><head><base href="/foo"><body>Hello, world!</body></html>))
59
51
 
60
52
  doc.base_href
61
53
  #=> "/foo"
@@ -64,22 +56,22 @@ doc.base_href
64
56
  The `base_href=` method allows you to manipulate the document's `<base>` element.
65
57
 
66
58
  ```ruby
67
- require 'nokogiri/html-ext'
59
+ require "nokogiri/html-ext"
68
60
 
69
- doc = Nokogiri::HTML('<html><body>Hello, world!</body></html>')
61
+ doc = Nokogiri::HTML(%(<html><body>Hello, world!</body></html>))
70
62
 
71
- doc.base_href = '/foo'
63
+ doc.base_href = "/foo"
72
64
  #=> "/foo"
73
65
 
74
- doc.at_css('base').to_s
66
+ doc.at_css("base").to_s
75
67
  #=> "<base href=\"/foo\">"
76
68
 
77
- doc = Nokogiri::HTML('<html><head><base href="/foo"><body>Hello, world!</body></html>')
69
+ doc = Nokogiri::HTML(%(<html><head><base href="/foo"><body>Hello, world!</body></html>))
78
70
 
79
- doc.base_href = '/bar'
71
+ doc.base_href = "/bar"
80
72
  #=> "/bar"
81
73
 
82
- doc.at_css('base').to_s
74
+ doc.at_css("base").to_s
83
75
  #=> "<base href=\"/bar\">"
84
76
  ```
85
77
 
@@ -96,7 +88,7 @@ URL resolution uses Ruby's built-in URL parsing and normalizing capabilities. Ab
96
88
  An abbreviated example:
97
89
 
98
90
  ```ruby
99
- require 'nokogiri/html-ext'
91
+ require "nokogiri/html-ext"
100
92
 
101
93
  markup = <<-HTML
102
94
  <html>
@@ -107,7 +99,7 @@ markup = <<-HTML
107
99
  </html>
108
100
  HTML
109
101
 
110
- doc = Nokogiri::HTML(markup, 'https://jgarber.example')
102
+ doc = Nokogiri::HTML(markup, "https://jgarber.example")
111
103
 
112
104
  doc.url
113
105
  #=> "https://jgarber.example"
@@ -115,18 +107,18 @@ doc.url
115
107
  doc.base_href
116
108
  #=> nil
117
109
 
118
- doc.base_href = '/foo/bar/biz'
110
+ doc.base_href = "/foo/bar/biz"
119
111
  #=> "/foo/bar/biz"
120
112
 
121
113
  doc.resolve_relative_urls!
122
114
 
123
- doc.at_css('base')['href']
115
+ doc.at_css("base")["href"]
124
116
  #=> "https://jgarber.example/foo/bar/biz"
125
117
 
126
- doc.at_css('a')['href']
118
+ doc.at_css("a")["href"]
127
119
  #=> "https://jgarber.example/home"
128
120
 
129
- doc.at_css('img').to_s
121
+ doc.at_css("img").to_s
130
122
  #=> "<img src=\"https://jgarber.example/foo.png\" srcset=\"https://jgarber.example/foo/bar.png 720w\">"
131
123
  ```
132
124
 
@@ -135,16 +127,12 @@ doc.at_css('img').to_s
135
127
  You may also resolve an arbitrary `String` representing a relative URL against the document's URL (or `<base>` element's `href` attribute value):
136
128
 
137
129
  ```ruby
138
- doc = Nokogiri::HTML('<html><base href="/foo/bar"></html>', 'https://jgarber.example')
130
+ doc = Nokogiri::HTML(%(<html><base href="/foo/bar"></html>), "https://jgarber.example")
139
131
 
140
- doc.resolve_relative_url('biz/baz')
132
+ doc.resolve_relative_url("biz/baz")
141
133
  #=> "https://jgarber.example/foo/biz/baz"
142
134
  ```
143
135
 
144
- ## Contributing
145
-
146
- Interested in helping improve nokogiri-html-ext? Awesome! Your help is greatly appreciated. See [CONTRIBUTING.md](https://github.com/jgarber623/nokogiri-html-ext/blob/main/CONTRIBUTING.md) for details.
147
-
148
136
  ## Acknowledgments
149
137
 
150
138
  nokogiri-html-ext wouldn't exist without the [Nokogiri](https://nokogiri.org) project and its [community](https://github.com/sparklemotion/nokogiri).
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'html_ext/version'
3
+ require_relative "html_ext/version"
4
4
 
5
- require_relative 'html_ext/document'
5
+ require_relative "html_ext/document"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'nokogiri'
3
+ require "nokogiri"
4
4
 
5
5
  module Nokogiri
6
6
  module HTML4
@@ -10,8 +10,8 @@ module Nokogiri
10
10
  # @see https://html.spec.whatwg.org/#srcset-attributes
11
11
  # @see https://html.spec.whatwg.org/#attributes-3
12
12
  IMAGE_CANDIDATE_STRINGS_ATTRIBUTES_MAP = {
13
- 'imagesrcset' => %w[link],
14
- 'srcset' => %w[img source]
13
+ "imagesrcset" => ["link"],
14
+ "srcset" => ["img", "source"]
15
15
  }.freeze
16
16
 
17
17
  private_constant :IMAGE_CANDIDATE_STRINGS_ATTRIBUTES_MAP
@@ -20,14 +20,14 @@ module Nokogiri
20
20
  #
21
21
  # @see https://html.spec.whatwg.org/#attributes-3
22
22
  URL_ATTRIBUTES_MAP = {
23
- 'action' => %w[form],
24
- 'cite' => %w[blockquote del ins q],
25
- 'data' => %w[object],
26
- 'formaction' => %w[button input],
27
- 'href' => %w[a area base link],
28
- 'ping' => %w[a area],
29
- 'poster' => %w[video],
30
- 'src' => %w[audio embed iframe img input script source track video]
23
+ "action" => ["form"],
24
+ "cite" => ["blockquote", "del", "ins", "q"],
25
+ "data" => ["object"],
26
+ "formaction" => ["button", "input"],
27
+ "href" => ["a", "area", "base", "link"],
28
+ "ping" => ["a", "area"],
29
+ "poster" => ["video"],
30
+ "src" => ["audio", "embed", "iframe", "img", "input", "script", "source", "track", "video"]
31
31
  }.freeze
32
32
 
33
33
  private_constant :URL_ATTRIBUTES_MAP
@@ -36,7 +36,7 @@ module Nokogiri
36
36
  #
37
37
  # @return [String, nil]
38
38
  def base_href
39
- (base = at_xpath('//base[@href]')) && base['href'].strip
39
+ (base = at_xpath("//base[@href]")) && base["href"].strip
40
40
  end
41
41
 
42
42
  # Set the +<base>+ element's HREF attribute value.
@@ -52,12 +52,12 @@ module Nokogiri
52
52
  def base_href=(url)
53
53
  url_str = url.to_s
54
54
 
55
- if (base = at_xpath('//base'))
56
- base['href'] = url_str
55
+ if (base = at_xpath("//base"))
56
+ base["href"] = url_str
57
57
  url_str
58
58
  else
59
- base = XML::Node.new('base', self)
60
- base['href'] = url_str
59
+ base = XML::Node.new("base", self)
60
+ base["href"] = url_str
61
61
 
62
62
  set_metadata_element(base)
63
63
  end
@@ -75,7 +75,7 @@ module Nokogiri
75
75
  # ASCII) and subsequently unescaping.
76
76
  uri_parser.unescape(
77
77
  uri_parser
78
- .join(*[doc_url_str, base_href, url_str].compact.map { |u| uri_parser.escape(u) })
78
+ .join(*[doc_url_str, base_href, url_str].filter_map { |u| uri_parser.escape(u) unless u.nil? })
79
79
  .normalize
80
80
  .to_s
81
81
  )
@@ -93,9 +93,9 @@ module Nokogiri
93
93
 
94
94
  resolve_relative_urls_for(IMAGE_CANDIDATE_STRINGS_ATTRIBUTES_MAP) do |value|
95
95
  value
96
- .split(',')
96
+ .split(",")
97
97
  .map { |candidate| candidate.strip.sub(/^(.+?)(\s+.+)?$/) { "#{resolve_relative_url($1)}#{$2}" } }
98
- .join(', ')
98
+ .join(", ")
99
99
  end
100
100
 
101
101
  self
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nokogiri
4
4
  module HTMLExt
5
- VERSION = '0.4.0'
5
+ VERSION = "0.4.2"
6
6
  end
7
7
  end
@@ -1,31 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'lib/nokogiri/html_ext/version'
3
+ require_relative "lib/nokogiri/html_ext/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.required_ruby_version = '>= 2.7'
6
+ spec.required_ruby_version = ">= 2.7"
7
7
 
8
- spec.name = 'nokogiri-html-ext'
8
+ spec.name = "nokogiri-html-ext"
9
9
  spec.version = Nokogiri::HTMLExt::VERSION
10
- spec.authors = ['Jason Garber']
11
- spec.email = ['jason@sixtwothree.org']
10
+ spec.authors = ["Jason Garber"]
11
+ spec.email = ["jason@sixtwothree.org"]
12
12
 
13
- spec.summary = 'Extend Nokogiri with several useful HTML-centric features.'
13
+ spec.summary = "Extend Nokogiri with several useful HTML-centric features."
14
14
  spec.description = spec.summary
15
- spec.homepage = 'https://github.com/jgarber623/nokogiri-html-ext'
16
- spec.license = 'MIT'
15
+ spec.homepage = "https://github.com/jgarber623/nokogiri-html-ext"
16
+ spec.license = "MIT"
17
17
 
18
- spec.files = Dir['lib/**/*'].reject { |f| File.directory?(f) }
19
- spec.files += %w[LICENSE CHANGELOG.md CONTRIBUTING.md README.md]
20
- spec.files += %w[nokogiri-html-ext.gemspec]
18
+ spec.files = Dir["lib/**/*"].reject { |f| File.directory?(f) }
19
+ spec.files += ["LICENSE", "CHANGELOG.md", "README.md"]
20
+ spec.files += ["nokogiri-html-ext.gemspec"]
21
21
 
22
- spec.require_paths = ['lib']
22
+ spec.require_paths = ["lib"]
23
23
 
24
24
  spec.metadata = {
25
- 'bug_tracker_uri' => "#{spec.homepage}/issues",
26
- 'changelog_uri' => "#{spec.homepage}/blob/v#{spec.version}/CHANGELOG.md",
27
- 'rubygems_mfa_required' => 'true'
25
+ "bug_tracker_uri" => "#{spec.homepage}/issues",
26
+ "changelog_uri" => "#{spec.homepage}/blob/v#{spec.version}/CHANGELOG.md",
27
+ "rubygems_mfa_required" => "true",
28
+ "source_code_uri" => "#{spec.homepage}/tree/v#{spec.version}"
28
29
  }
29
30
 
30
- spec.add_runtime_dependency 'nokogiri', '>= 1.14'
31
+ spec.add_runtime_dependency "nokogiri", ">= 1.14"
31
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogiri-html-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Garber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-21 00:00:00.000000000 Z
11
+ date: 2023-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -32,7 +32,6 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - CHANGELOG.md
35
- - CONTRIBUTING.md
36
35
  - LICENSE
37
36
  - README.md
38
37
  - lib/nokogiri/html-ext.rb
@@ -44,8 +43,9 @@ licenses:
44
43
  - MIT
45
44
  metadata:
46
45
  bug_tracker_uri: https://github.com/jgarber623/nokogiri-html-ext/issues
47
- changelog_uri: https://github.com/jgarber623/nokogiri-html-ext/blob/v0.4.0/CHANGELOG.md
46
+ changelog_uri: https://github.com/jgarber623/nokogiri-html-ext/blob/v0.4.2/CHANGELOG.md
48
47
  rubygems_mfa_required: 'true'
48
+ source_code_uri: https://github.com/jgarber623/nokogiri-html-ext/tree/v0.4.2
49
49
  post_install_message:
50
50
  rdoc_options: []
51
51
  require_paths:
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  requirements: []
64
- rubygems_version: 3.3.26
64
+ rubygems_version: 3.1.6
65
65
  signing_key:
66
66
  specification_version: 4
67
67
  summary: Extend Nokogiri with several useful HTML-centric features.
data/CONTRIBUTING.md DELETED
@@ -1,37 +0,0 @@
1
- # Contributing to nokogiri-html-ext
2
-
3
- There are a couple ways you can help improve nokogiri-html-ext:
4
-
5
- 1. Fix an existing [issue][issues] and submit a [pull request][pulls].
6
- 1. Review open [pull requests][pulls].
7
- 1. Report a new [issue][issues]. _Only do this after you've made sure the behavior or problem you're observing isn't already documented in an open issue._
8
-
9
- ## Getting Started
10
-
11
- nokogiri-html-ext is developed using Ruby 2.7.7 and is additionally tested against Ruby 3.0, 3.1, and 3.2 using [GitHub Actions](https://github.com/jgarber623/nokogiri-html-ext/actions).
12
-
13
- Before making changes to nokogiri-html-ext, you'll want to install Ruby 2.7.7. It's recommended that you use a Ruby version managment tool like [rbenv](https://github.com/rbenv/rbenv), [chruby](https://github.com/postmodern/chruby), or [rvm](https://github.com/rvm/rvm). Once you've installed Ruby 2.7.7 using your method of choice, install the project's gems by running:
14
-
15
- ```sh
16
- bundle install
17
- ```
18
-
19
- ## Making Changes
20
-
21
- 1. Fork and clone the project's repo.
22
- 1. Install development dependencies as outlined above.
23
- 1. Create a feature branch for the code changes you're looking to make: `git checkout -b my-new-feature`.
24
- 1. _Write some code!_
25
- 1. If your changes would benefit from testing, add the necessary tests and verify everything passes by running `bundle exec rspec`.
26
- 1. Commit your changes: `git commit -am 'Add some new feature or fix some issue'`. _(See [this excellent article](https://chris.beams.io/posts/git-commit/) for tips on writing useful Git commit messages.)_
27
- 1. Push the branch to your fork: `git push -u origin my-new-feature`.
28
- 1. Create a new [pull request][pulls] and we'll review your changes.
29
-
30
- ## Code Style
31
-
32
- Code formatting conventions are defined in the `.editorconfig` file which uses the [EditorConfig](http://editorconfig.org) syntax. There are [plugins for a variety of editors](http://editorconfig.org/#download) that utilize the settings in the `.editorconfig` file. We recommended you install the EditorConfig plugin for your editor of choice.
33
-
34
- Your bug fix or feature addition won't be rejected if it runs afoul of any (or all) of these guidelines, but following the guidelines will definitely make everyone's lives a little easier.
35
-
36
- [issues]: https://github.com/jgarber623/nokogiri-html-ext/issues
37
- [pulls]: https://github.com/jgarber623/nokogiri-html-ext/pulls