nokogiri-diff 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4374cae69c49465afb2391000bc4c57c0f30db34155afe50c463cf54a86fe719
4
+ data.tar.gz: eb6e14af7ddca3cf72555d83f8f608cd90310d532c18bd6645afedd3bf3d8437
5
+ SHA512:
6
+ metadata.gz: d67440441d4581bf0ab7a59dc9ce7ab34fbc3c8078a36f305ee91b3835d808c9cdd7221c5e080fcd6dd7552f61698cb72b7a2df9d0bc1208ddfdc4b46ef7d364
7
+ data.tar.gz: 995fe16d4e4299b02f4d34a3a1c6a4061ae8f727343e64d5692c9fdeca89bd128d9eb8fa40ff934178580326c35fe63a07ed8fa5dc61458330c4dfe22cc1bd92
@@ -0,0 +1,28 @@
1
+ name: CI
2
+
3
+ on: [ push, pull_request ]
4
+
5
+ jobs:
6
+ tests:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ ruby:
12
+ - '3.0'
13
+ - '3.1'
14
+ - '3.2'
15
+ - '3.3'
16
+ - jruby
17
+ - truffleruby
18
+ name: Ruby ${{ matrix.ruby }}
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ - name: Set up Ruby
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ - name: Install dependencies
26
+ run: bundle install --jobs 4 --retry 3
27
+ - name: Run tests
28
+ run: bundle exec rake test
data/.gitignore CHANGED
@@ -1,2 +1,4 @@
1
- doc/
2
- pkg/
1
+ /Gemfile.lock
2
+ /coverage
3
+ /doc
4
+ /pkg
data/ChangeLog.md CHANGED
@@ -1,3 +1,10 @@
1
+ ### 0.3.0 / 2024-01-24
2
+
3
+ * Require [ruby](http://www.ruby-lang.org/) >= 2.0.0.
4
+ * Require [tdiff](http://github.com/postmodern/tdiff) ~> 0.4.
5
+ * Switched to using `require_relative` to improve load-times.
6
+ * Added `# frozen_string_literal: true` to all files.
7
+
1
8
  ### 0.2.0 / 2013-04-22
2
9
 
3
10
  * {Nokogiri::XML::Node#tdiff_each_child} now sorts attributes by name, so that
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'rake'
7
+ gem 'rubygems-tasks', '~> 0.2'
8
+
9
+ gem 'rspec', '~> 3.0'
10
+ gem 'simplecov', '~> 0.20', require: false
11
+
12
+ gem 'kramdown'
13
+ gem 'redcarpet', platform: :mri
14
+ gem 'yard', '~> 0.9'
15
+ end
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2012 Hal Brodigan
1
+ Copyright (c) 2010-2024 Hal Brodigan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,9 +1,10 @@
1
1
  # nokogiri-diff
2
2
 
3
+ [![CI](https://github.com/postmodern/nokogiri-diff/actions/workflows/ruby.yml/badge.svg)](https://github.com/postmodern/nokogiri-diff/actions/workflows/ruby.yml)
4
+
3
5
  * [Source](https://github.com/postmodern/nokogiri-diff)
4
6
  * [Issues](https://github.com/postmodern/nokogiri-diff/issues)
5
7
  * [Documentation](http://rubydoc.info/gems/nokogiri-diff/frames)
6
- * [Email](mailto:postmodern.mod3 at gmail.com)
7
8
 
8
9
  ## Description
9
10
 
@@ -19,56 +20,62 @@ removed nodes) between two XML/HTML documents.
19
20
 
20
21
  ## Examples
21
22
 
22
- Enumerate over the the differences between two HTML documents:
23
+ Enumerate over the differences between two HTML documents:
23
24
 
24
- require 'nokogiri/diff'
25
+ ```ruby
26
+ require 'nokogiri/diff'
25
27
 
26
- doc1 = Nokogiri::HTML('<div><p>one</p> two </div>')
27
- doc2 = Nokogiri::HTML('<div><p id="1">one</p> <p>three</p></div>')
28
+ doc1 = Nokogiri::HTML('<div><p>one</p> two </div>')
29
+ doc2 = Nokogiri::HTML('<div><p id="1">one</p> <p>three</p></div>')
28
30
 
29
- doc1.diff(doc2) do |change,node|
30
- puts "#{change} #{node.to_html}".ljust(30) + node.parent.path
31
- end
31
+ doc1.diff(doc2) do |change,node|
32
+ puts "#{change} #{node.to_html}".ljust(30) + node.parent.path
33
+ end
32
34
 
33
- # <div>
34
- # <p>one</p> two </div> /
35
- # <p>one</p> /div
36
- # - two /div
37
- # + /div
38
- # + <p>three</p> /div
39
- # + id="1" /div/p[1]
40
- # one /div/p
35
+ # <div>
36
+ # <p>one</p> two </div> /
37
+ # <p>one</p> /div
38
+ # - two /div
39
+ # + /div
40
+ # + <p>three</p> /div
41
+ # + id="1" /div/p[1]
42
+ # one /div/p
43
+ ```
41
44
 
42
45
  Only find the added nodes:
43
46
 
44
- doc1.diff(doc2, :added => true) do |change,node|
45
- puts node.to_html.ljust(30) + node.parent.path
46
- end
47
+ ```ruby
48
+ doc1.diff(doc2, :added => true) do |change,node|
49
+ puts node.to_html.ljust(30) + node.parent.path
50
+ end
47
51
 
48
- # /div
49
- # <p>three</p> /div
50
- # id="1" /div/p[1]
52
+ # /div
53
+ # <p>three</p> /div
54
+ # id="1" /div/p[1]
55
+ ```
51
56
 
52
57
  Only find the removed nodes:
53
58
 
54
- doc1.diff(doc2, :removed => true) do |change,node|
55
- puts node.to_html.ljust(30) + node.parent.path
56
- end
59
+ ```ruby
60
+ doc1.diff(doc2, :removed => true) do |change,node|
61
+ puts node.to_html.ljust(30) + node.parent.path
62
+ end
57
63
 
58
- # two /div
64
+ # two /div
65
+ ```
59
66
 
60
67
  ## Requirements
61
68
 
62
- * [ruby](http://www.ruby-lang.org/) >= 1.8.7
63
- * [tdiff](http://github.com/postmodern/tdiff) ~> 0.3, >= 0.3.2
69
+ * [ruby](http://www.ruby-lang.org/) >= 2.0.0
70
+ * [tdiff](http://github.com/postmodern/tdiff) ~> 0.4
64
71
  * [nokogiri](http://nokogiri.rubyforge.org/) ~> 1.5
65
72
 
66
73
  ## Install
67
74
 
68
- $ gem install nokogiri-diff
69
-
70
- ## Copyright
75
+ ```shell
76
+ $ gem install nokogiri-diff
77
+ ```
71
78
 
72
- Copyright (c) 2010-2012 Hal Brodigan
79
+ ## License
73
80
 
74
81
  See {file:LICENSE.txt} for details.
data/Rakefile CHANGED
@@ -1,36 +1,10 @@
1
- require 'rubygems'
2
- require 'rake'
1
+ require 'rubygems/tasks'
2
+ Gem::Tasks.new
3
3
 
4
- begin
5
- gem 'rubygems-tasks', '~> 0.1'
6
- require 'rubygems/tasks'
7
-
8
- Gem::Tasks.new
9
- rescue LoadError => e
10
- warn e.message
11
- warn "Run `gem install rubygems-tasks` to install 'rubygems/tasks'."
12
- end
13
-
14
- begin
15
- gem 'rspec', '~> 2.4'
16
- require 'rspec/core/rake_task'
17
-
18
- RSpec::Core::RakeTask.new
19
- rescue LoadError => e
20
- task :spec do
21
- abort "Please run `gem install rspec` to install RSpec."
22
- end
23
- end
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new
24
6
  task :test => :spec
25
7
  task :default => :spec
26
8
 
27
- begin
28
- gem 'yard', '~> 0.7'
29
- require 'yard'
30
-
31
- YARD::Rake::YardocTask.new
32
- rescue LoadError => e
33
- task :yard do
34
- abort "Please run `gem install yard` to install YARD."
35
- end
36
- end
9
+ require 'yard'
10
+ YARD::Rake::YardocTask.new
data/gemspec.yml CHANGED
@@ -10,13 +10,18 @@ email: postmodern.mod3@gmail.com
10
10
  homepage: https://github.com/postmodern/nokogiri-diff#readme
11
11
  has_yard: true
12
12
 
13
- required_ruby_version: ">= 1.8.7"
13
+ metadata:
14
+ documentation_uri: https://rubydoc.info/gems/nokogiri-diff
15
+ source_code_uri: https://github.com/postmodern/nokogiri-diff
16
+ bug_tracker_uri: https://github.com/postmodern/nokogiri-diff/issues
17
+ changelog_uri: https://github.com/postmodern/nokogiri-diff/blob/main/ChangeLog.md
18
+ rubygems_mfa_required: 'true'
19
+
20
+ required_ruby_version: ">= 2.0.0"
14
21
 
15
22
  dependencies:
16
- tdiff: ~> 0.3, >= 0.3.2
23
+ tdiff: ~> 0.4
17
24
  nokogiri: ~> 1.5
18
25
 
19
26
  development_dependencies:
20
- rubygems-tasks: ~> 0.1
21
- rspec: ~> 2.4
22
- yard: ~> 0.7
27
+ bundler: ~> 2.0
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Nokogiri
2
4
  module Diff
3
5
  # nokogiri-diff version
4
- VERSION = '0.2.0'
6
+ VERSION = '0.3.0'
5
7
  end
6
8
  end
@@ -1,4 +1,6 @@
1
- require 'nokogiri/diff/xml/node'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'node'
2
4
 
3
5
  class Nokogiri::XML::Document < Nokogiri::XML::Node
4
6
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'nokogiri'
2
4
  require 'tdiff'
3
5
 
@@ -25,7 +27,7 @@ class Nokogiri::XML::Node
25
27
  when Nokogiri::XML::Text, Nokogiri::XML::Comment
26
28
  self.text == node.text
27
29
  when Nokogiri::XML::ProcessingInstruction
28
- (self.name == node.name && self.content = self.content)
30
+ (self.name == node.name && self.content == node.content)
29
31
  else
30
32
  false
31
33
  end
@@ -1,2 +1,4 @@
1
- require 'nokogiri/diff/xml/node'
2
- require 'nokogiri/diff/xml/document'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'xml/node'
4
+ require_relative 'xml/document'
data/lib/nokogiri/diff.rb CHANGED
@@ -1,2 +1,4 @@
1
- require 'nokogiri/diff/xml'
2
- require 'nokogiri/diff/version'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'diff/xml'
4
+ require_relative 'diff/version'
@@ -7,10 +7,7 @@ Gem::Specification.new do |gem|
7
7
 
8
8
  gem.name = gemspec.fetch('name')
9
9
  gem.version = gemspec.fetch('version') do
10
- lib_dir = File.join(File.dirname(__FILE__),'lib')
11
- $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
12
-
13
- require 'nokogiri/diff/version'
10
+ require_relative 'lib/nokogiri/diff/version'
14
11
  Nokogiri::Diff::VERSION
15
12
  end
16
13
 
data/spec/diff_spec.rb CHANGED
@@ -21,197 +21,197 @@ describe "nokogiri/diff" do
21
21
  let(:removed_attr) { Nokogiri::XML('<div><p>one</p></div>') }
22
22
 
23
23
  it "should add #diff to Nokogiri::XML::Docuemnt" do
24
- doc.should respond_to(:diff)
24
+ expect(doc).to respond_to(:diff)
25
25
  end
26
26
 
27
27
  it "should add #diff to Nokogiri::XML::Element" do
28
- added_element.at('div').should respond_to(:diff)
28
+ expect(added_element.at('div')).to respond_to(:diff)
29
29
  end
30
30
 
31
31
  it "should add #diff to Nokogiri::XML::Text" do
32
- added_text.at('p/text()').should respond_to(:diff)
32
+ expect(added_text.at('p/text()')).to respond_to(:diff)
33
33
  end
34
34
 
35
35
  it "should add #diff to Nokogiri::XML::Attr" do
36
- added_attr.at('p/@id').should respond_to(:diff)
36
+ expect(added_attr.at('p/@id')).to respond_to(:diff)
37
37
  end
38
38
 
39
39
  it "should not compare the Document objects" do
40
40
  change = doc.diff(doc).first
41
41
 
42
- change[0].should == ' '
43
- change[1].should == doc.root
42
+ expect(change[0]).to eq(' ')
43
+ expect(change[1]).to eq(doc.root)
44
44
  end
45
45
 
46
46
  it "should determine when two different documents are identical" do
47
- doc.diff(Nokogiri::XML(contents)).all? { |change,node|
47
+ expect(doc.diff(Nokogiri::XML(contents)).all? { |change,node|
48
48
  change == ' '
49
- }.should == true
49
+ }).to eq(true)
50
50
  end
51
51
 
52
52
  it "should search down within Nokogiri::XML::Document objects" do
53
- doc.diff(changed_text).any? { |change,node|
53
+ expect(doc.diff(changed_text).any? { |change,node|
54
54
  change != ' '
55
- }.should == true
55
+ }).to eq(true)
56
56
  end
57
57
 
58
58
  it "should determine when text nodes are added" do
59
59
  changes = doc.at('div').diff(added_text.at('div')).to_a
60
60
 
61
- changes.length.should == 4
61
+ expect(changes.length).to eq(4)
62
62
 
63
- changes[0][0].should == ' '
64
- changes[0][1].should == doc.at('div')
63
+ expect(changes[0][0]).to eq(' ')
64
+ expect(changes[0][1]).to eq(doc.at('div'))
65
65
 
66
- changes[1][0].should == ' '
67
- changes[1][1].should == doc.at('//p')
66
+ expect(changes[1][0]).to eq(' ')
67
+ expect(changes[1][1]).to eq(doc.at('//p'))
68
68
 
69
- changes[2][0].should == '+'
70
- changes[2][1].should == added_text.at('//div/text()')
69
+ expect(changes[2][0]).to eq('+')
70
+ expect(changes[2][1]).to eq(added_text.at('//div/text()'))
71
71
 
72
- changes[3][0].should == ' '
73
- changes[3][1].should == doc.at('//p/text()')
72
+ expect(changes[3][0]).to eq(' ')
73
+ expect(changes[3][1]).to eq(doc.at('//p/text()'))
74
74
  end
75
75
 
76
76
  it "should determine when elements are added" do
77
77
  changes = doc.at('div').diff(added_element.at('div')).to_a
78
78
 
79
- changes.length.should == 5
79
+ expect(changes.length).to eq(5)
80
80
 
81
- changes[0][0].should == ' '
82
- changes[0][1].should == doc.at('div')
81
+ expect(changes[0][0]).to eq(' ')
82
+ expect(changes[0][1]).to eq(doc.at('div'))
83
83
 
84
- changes[1][0].should == '+'
85
- changes[1][1].should == added_element.at('//p[1]')
84
+ expect(changes[1][0]).to eq('+')
85
+ expect(changes[1][1]).to eq(added_element.at('//p[1]'))
86
86
 
87
- changes[2][0].should == ' '
88
- changes[2][1].should == doc.at('//p')
87
+ expect(changes[2][0]).to eq(' ')
88
+ expect(changes[2][1]).to eq(doc.at('//p'))
89
89
 
90
- changes[3][0].should == '-'
91
- changes[3][1].should == doc.at('//p/text()')
90
+ expect(changes[3][0]).to eq('-')
91
+ expect(changes[3][1]).to eq(doc.at('//p/text()'))
92
92
 
93
- changes[4][0].should == '+'
94
- changes[4][1].should == added_element.at('//p[2]/text()')
93
+ expect(changes[4][0]).to eq('+')
94
+ expect(changes[4][1]).to eq(added_element.at('//p[2]/text()'))
95
95
  end
96
96
 
97
97
  it "should ignore when attribute order changes" do
98
98
  changes = added_attrs.at('p').diff(changed_attr_order.at('p')).to_a
99
99
 
100
- changes.all? { |change| change[0] == ' ' }.should be_true
100
+ expect(changes.all? { |change| change[0] == ' ' }).to be_truthy
101
101
  end
102
102
 
103
103
  it "should determine when attributes are added" do
104
104
  changes = doc.at('p').diff(added_attr.at('p')).to_a
105
105
 
106
- changes.length.should == 3
106
+ expect(changes.length).to eq(3)
107
107
 
108
- changes[0][0].should == ' '
109
- changes[0][1].should == doc.at('p')
108
+ expect(changes[0][0]).to eq(' ')
109
+ expect(changes[0][1]).to eq(doc.at('p'))
110
110
 
111
- changes[1][0].should == '+'
112
- changes[1][1].should == added_attr.at('//p/@id')
111
+ expect(changes[1][0]).to eq('+')
112
+ expect(changes[1][1]).to eq(added_attr.at('//p/@id'))
113
113
 
114
- changes[2][0].should == ' '
115
- changes[2][1].should == doc.at('//p/text()')
114
+ expect(changes[2][0]).to eq(' ')
115
+ expect(changes[2][1]).to eq(doc.at('//p/text()'))
116
116
  end
117
117
 
118
118
  it "should determine when text nodes differ" do
119
119
  changes = doc.at('p').diff(changed_text.at('p')).to_a
120
120
 
121
- changes.length.should == 3
121
+ expect(changes.length).to eq(3)
122
122
 
123
- changes[0][0].should == ' '
124
- changes[0][1].should == doc.at('p')
123
+ expect(changes[0][0]).to eq(' ')
124
+ expect(changes[0][1]).to eq(doc.at('p'))
125
125
 
126
- changes[1][0].should == '-'
127
- changes[1][1].should == doc.at('//p/text()')
126
+ expect(changes[1][0]).to eq('-')
127
+ expect(changes[1][1]).to eq(doc.at('//p/text()'))
128
128
 
129
- changes[2][0].should == '+'
130
- changes[2][1].should == changed_text.at('//p/text()')
129
+ expect(changes[2][0]).to eq('+')
130
+ expect(changes[2][1]).to eq(changed_text.at('//p/text()'))
131
131
  end
132
132
 
133
133
  it "should determine when element names differ" do
134
134
  changes = doc.at('div').diff(changed_element.at('div')).to_a
135
135
 
136
- changes.length.should == 3
136
+ expect(changes.length).to eq(3)
137
137
 
138
- changes[0][0].should == ' '
139
- changes[0][1].should == doc.at('div')
138
+ expect(changes[0][0]).to eq(' ')
139
+ expect(changes[0][1]).to eq(doc.at('div'))
140
140
 
141
- changes[1][0].should == '-'
142
- changes[1][1].should == doc.at('p')
141
+ expect(changes[1][0]).to eq('-')
142
+ expect(changes[1][1]).to eq(doc.at('p'))
143
143
 
144
- changes[2][0].should == '+'
145
- changes[2][1].should == changed_element.at('span')
144
+ expect(changes[2][0]).to eq('+')
145
+ expect(changes[2][1]).to eq(changed_element.at('span'))
146
146
  end
147
147
 
148
148
  it "should determine when attribute names differ" do
149
149
  changes = added_attr.at('p').diff(changed_attr_name.at('p')).to_a
150
150
 
151
- changes.length.should == 4
151
+ expect(changes.length).to eq(4)
152
152
 
153
- changes[0][0].should == ' '
154
- changes[0][1].should == added_attr.at('p')
153
+ expect(changes[0][0]).to eq(' ')
154
+ expect(changes[0][1]).to eq(added_attr.at('p'))
155
155
 
156
- changes[1][0].should == '-'
157
- changes[1][1].should == added_attr.at('//p/@id')
156
+ expect(changes[1][0]).to eq('-')
157
+ expect(changes[1][1]).to eq(added_attr.at('//p/@id'))
158
158
 
159
- changes[2][0].should == '+'
160
- changes[2][1].should == changed_attr_name.at('//p/@i')
159
+ expect(changes[2][0]).to eq('+')
160
+ expect(changes[2][1]).to eq(changed_attr_name.at('//p/@i'))
161
161
 
162
- changes[3][0].should == ' '
163
- changes[3][1].should == added_attr.at('//p/text()')
162
+ expect(changes[3][0]).to eq(' ')
163
+ expect(changes[3][1]).to eq(added_attr.at('//p/text()'))
164
164
  end
165
165
 
166
166
  it "should determine when attribute values differ" do
167
167
  changes = added_attr.at('p').diff(changed_attr_value.at('p')).to_a
168
168
 
169
- changes.length.should == 4
169
+ expect(changes.length).to eq(4)
170
170
 
171
- changes[0][0].should == ' '
172
- changes[0][1].should == added_attr.at('p')
171
+ expect(changes[0][0]).to eq(' ')
172
+ expect(changes[0][1]).to eq(added_attr.at('p'))
173
173
 
174
- changes[1][0].should == '-'
175
- changes[1][1].should == added_attr.at('//p/@id')
174
+ expect(changes[1][0]).to eq('-')
175
+ expect(changes[1][1]).to eq(added_attr.at('//p/@id'))
176
176
 
177
- changes[2][0].should == '+'
178
- changes[2][1].should == changed_attr_value.at('//p/@id')
177
+ expect(changes[2][0]).to eq('+')
178
+ expect(changes[2][1]).to eq(changed_attr_value.at('//p/@id'))
179
179
 
180
- changes[3][0].should == ' '
181
- changes[3][1].should == added_attr.at('//p/text()')
180
+ expect(changes[3][0]).to eq(' ')
181
+ expect(changes[3][1]).to eq(added_attr.at('//p/text()'))
182
182
  end
183
183
 
184
184
  it "should determine when text nodes are removed" do
185
185
  changes = added_text.at('div').diff(removed_text.at('div')).to_a
186
186
 
187
- changes.length.should == 4
187
+ expect(changes.length).to eq(4)
188
188
 
189
- changes[0][0].should == ' '
190
- changes[0][1].should == added_text.at('div')
189
+ expect(changes[0][0]).to eq(' ')
190
+ expect(changes[0][1]).to eq(added_text.at('div'))
191
191
 
192
- changes[1][0].should == ' '
193
- changes[1][1].should == added_text.at('p')
192
+ expect(changes[1][0]).to eq(' ')
193
+ expect(changes[1][1]).to eq(added_text.at('p'))
194
194
 
195
- changes[2][0].should == ' '
196
- changes[2][1].should == added_text.at('//div/text()')
195
+ expect(changes[2][0]).to eq(' ')
196
+ expect(changes[2][1]).to eq(added_text.at('//div/text()'))
197
197
 
198
- changes[3][0].should == '-'
199
- changes[3][1].should == added_text.at('//p/text()')
198
+ expect(changes[3][0]).to eq('-')
199
+ expect(changes[3][1]).to eq(added_text.at('//p/text()'))
200
200
  end
201
201
 
202
202
  it "should determine when elements are removed" do
203
203
  changes = added_element.at('div').diff(removed_element.at('div')).to_a
204
204
 
205
- changes.length.should == 3
205
+ expect(changes.length).to eq(3)
206
206
 
207
- changes[0][0].should == ' '
208
- changes[0][1].should == added_element.at('div')
207
+ expect(changes[0][0]).to eq(' ')
208
+ expect(changes[0][1]).to eq(added_element.at('div'))
209
209
 
210
- changes[1][0].should == '-'
211
- changes[1][1].should == added_element.at('//p[1]')
210
+ expect(changes[1][0]).to eq('-')
211
+ expect(changes[1][1]).to eq(added_element.at('//p[1]'))
212
212
 
213
- changes[2][0].should == '-'
214
- changes[2][1].should == added_element.at('//p[2]')
213
+ expect(changes[2][0]).to eq('-')
214
+ expect(changes[2][1]).to eq(added_element.at('//p[2]'))
215
215
  end
216
216
 
217
217
  it "should ignore when attributes change order" do
@@ -220,47 +220,47 @@ describe "nokogiri/diff" do
220
220
  it "should determine when attributes are removed" do
221
221
  changes = added_attr.at('div').diff(removed_attr.at('div')).to_a
222
222
 
223
- changes.length.should == 4
223
+ expect(changes.length).to eq(4)
224
224
 
225
- changes[0][0].should == ' '
226
- changes[0][1].should == added_attr.at('div')
225
+ expect(changes[0][0]).to eq(' ')
226
+ expect(changes[0][1]).to eq(added_attr.at('div'))
227
227
 
228
- changes[1][0].should == ' '
229
- changes[1][1].should == added_attr.at('p')
228
+ expect(changes[1][0]).to eq(' ')
229
+ expect(changes[1][1]).to eq(added_attr.at('p'))
230
230
 
231
- changes[2][0].should == '-'
232
- changes[2][1].should == added_attr.at('//p/@id')
231
+ expect(changes[2][0]).to eq('-')
232
+ expect(changes[2][1]).to eq(added_attr.at('//p/@id'))
233
233
 
234
- changes[3][0].should == ' '
235
- changes[3][1].should == added_attr.at('//p/text()')
234
+ expect(changes[3][0]).to eq(' ')
235
+ expect(changes[3][1]).to eq(added_attr.at('//p/text()'))
236
236
  end
237
237
 
238
238
  context ":added" do
239
239
  it "should determine only when text nodes are added" do
240
240
  changes = doc.at('div').diff(added_text.at('div'), :added => true).to_a
241
241
 
242
- changes.length.should == 1
242
+ expect(changes.length).to eq(1)
243
243
 
244
- changes[0][0].should == '+'
245
- changes[0][1].should == added_text.at('//div/text()')
244
+ expect(changes[0][0]).to eq('+')
245
+ expect(changes[0][1]).to eq(added_text.at('//div/text()'))
246
246
  end
247
247
 
248
248
  it "should determine only when elements are added" do
249
249
  changes = doc.at('div').diff(added_element.at('div'), :added => true).to_a
250
250
 
251
- changes.length.should == 1
251
+ expect(changes.length).to eq(1)
252
252
 
253
- changes[0][0].should == '+'
254
- changes[0][1].should == added_element.at('//div/p[2]')
253
+ expect(changes[0][0]).to eq('+')
254
+ expect(changes[0][1]).to eq(added_element.at('//div/p[2]'))
255
255
  end
256
256
 
257
257
  it "should determine only when attributes are added" do
258
258
  changes = doc.at('div').diff(added_attr.at('div'), :added => true).to_a
259
259
 
260
- changes.length.should == 1
260
+ expect(changes.length).to eq(1)
261
261
 
262
- changes[0][0].should == '+'
263
- changes[0][1].should == added_attr.at('//p/@id')
262
+ expect(changes[0][0]).to eq('+')
263
+ expect(changes[0][1]).to eq(added_attr.at('//p/@id'))
264
264
  end
265
265
  end
266
266
 
@@ -268,28 +268,28 @@ describe "nokogiri/diff" do
268
268
  it "should determine only when text nodes are removed" do
269
269
  changes = doc.at('div').diff(removed_text.at('div'), :removed => true).to_a
270
270
 
271
- changes.length.should == 1
271
+ expect(changes.length).to eq(1)
272
272
 
273
- changes[0][0].should == '-'
274
- changes[0][1].should == doc.at('//p/text()')
273
+ expect(changes[0][0]).to eq('-')
274
+ expect(changes[0][1]).to eq(doc.at('//p/text()'))
275
275
  end
276
276
 
277
277
  it "should determine only when elements are removed" do
278
278
  changes = doc.at('div').diff(removed_element.at('div'), :removed => true).to_a
279
279
 
280
- changes.length.should == 1
280
+ expect(changes.length).to eq(1)
281
281
 
282
- changes[0][0].should == '-'
283
- changes[0][1].should == doc.at('//div/p')
282
+ expect(changes[0][0]).to eq('-')
283
+ expect(changes[0][1]).to eq(doc.at('//div/p'))
284
284
  end
285
285
 
286
286
  it "should determine only when attributes are removed" do
287
287
  changes = added_attr.at('div').diff(removed_attr.at('div'), :removed => true).to_a
288
288
 
289
- changes.length.should == 1
289
+ expect(changes.length).to eq(1)
290
290
 
291
- changes[0][0].should == '-'
292
- changes[0][1].should == added_attr.at('//p/@id')
291
+ expect(changes[0][0]).to eq('-')
292
+ expect(changes[0][1]).to eq(added_attr.at('//p/@id'))
293
293
  end
294
294
  end
295
295
  end
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1,3 @@
1
- gem 'rspec', '~> 2.4'
2
1
  require 'rspec'
2
+ require 'simplecov'
3
+ SimpleCov.start
metadata CHANGED
@@ -1,102 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogiri-diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Postmodern
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-22 00:00:00.000000000 Z
11
+ date: 2024-01-25 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: tdiff
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: '0.3'
22
- - - ! '>='
23
- - !ruby/object:Gem::Version
24
- version: 0.3.2
19
+ version: '0.4'
25
20
  type: :runtime
26
21
  prerelease: false
27
22
  version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
23
  requirements:
30
- - - ~>
31
- - !ruby/object:Gem::Version
32
- version: '0.3'
33
- - - ! '>='
24
+ - - "~>"
34
25
  - !ruby/object:Gem::Version
35
- version: 0.3.2
26
+ version: '0.4'
36
27
  - !ruby/object:Gem::Dependency
37
28
  name: nokogiri
38
29
  requirement: !ruby/object:Gem::Requirement
39
- none: false
40
30
  requirements:
41
- - - ~>
31
+ - - "~>"
42
32
  - !ruby/object:Gem::Version
43
33
  version: '1.5'
44
34
  type: :runtime
45
35
  prerelease: false
46
36
  version_requirements: !ruby/object:Gem::Requirement
47
- none: false
48
37
  requirements:
49
- - - ~>
38
+ - - "~>"
50
39
  - !ruby/object:Gem::Version
51
40
  version: '1.5'
52
41
  - !ruby/object:Gem::Dependency
53
- name: rubygems-tasks
54
- requirement: !ruby/object:Gem::Requirement
55
- none: false
56
- requirements:
57
- - - ~>
58
- - !ruby/object:Gem::Version
59
- version: '0.1'
60
- type: :development
61
- prerelease: false
62
- version_requirements: !ruby/object:Gem::Requirement
63
- none: false
64
- requirements:
65
- - - ~>
66
- - !ruby/object:Gem::Version
67
- version: '0.1'
68
- - !ruby/object:Gem::Dependency
69
- name: rspec
70
- requirement: !ruby/object:Gem::Requirement
71
- none: false
72
- requirements:
73
- - - ~>
74
- - !ruby/object:Gem::Version
75
- version: '2.4'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- none: false
80
- requirements:
81
- - - ~>
82
- - !ruby/object:Gem::Version
83
- version: '2.4'
84
- - !ruby/object:Gem::Dependency
85
- name: yard
42
+ name: bundler
86
43
  requirement: !ruby/object:Gem::Requirement
87
- none: false
88
44
  requirements:
89
- - - ~>
45
+ - - "~>"
90
46
  - !ruby/object:Gem::Version
91
- version: '0.7'
47
+ version: '2.0'
92
48
  type: :development
93
49
  prerelease: false
94
50
  version_requirements: !ruby/object:Gem::Requirement
95
- none: false
96
51
  requirements:
97
- - - ~>
52
+ - - "~>"
98
53
  - !ruby/object:Gem::Version
99
- version: '0.7'
54
+ version: '2.0'
100
55
  description: Nokogiri::Diff adds the ability to calculate the differences (added or
101
56
  removed nodes) between two XML/HTML documents.
102
57
  email: postmodern.mod3@gmail.com
@@ -107,12 +62,13 @@ extra_rdoc_files:
107
62
  - LICENSE.txt
108
63
  - README.md
109
64
  files:
110
- - .document
111
- - .gemtest
112
- - .gitignore
113
- - .rspec
114
- - .yardopts
65
+ - ".document"
66
+ - ".github/workflows/ruby.yml"
67
+ - ".gitignore"
68
+ - ".rspec"
69
+ - ".yardopts"
115
70
  - ChangeLog.md
71
+ - Gemfile
116
72
  - LICENSE.txt
117
73
  - README.md
118
74
  - Rakefile
@@ -128,26 +84,24 @@ files:
128
84
  homepage: https://github.com/postmodern/nokogiri-diff#readme
129
85
  licenses:
130
86
  - MIT
131
- post_install_message:
87
+ metadata: {}
88
+ post_install_message:
132
89
  rdoc_options: []
133
90
  require_paths:
134
91
  - lib
135
92
  required_ruby_version: !ruby/object:Gem::Requirement
136
- none: false
137
93
  requirements:
138
- - - ! '>='
94
+ - - ">="
139
95
  - !ruby/object:Gem::Version
140
- version: 1.8.7
96
+ version: 2.0.0
141
97
  required_rubygems_version: !ruby/object:Gem::Requirement
142
- none: false
143
98
  requirements:
144
- - - ! '>='
99
+ - - ">="
145
100
  - !ruby/object:Gem::Version
146
101
  version: '0'
147
102
  requirements: []
148
- rubyforge_project:
149
- rubygems_version: 1.8.25
150
- signing_key:
151
- specification_version: 3
103
+ rubygems_version: 3.4.10
104
+ signing_key:
105
+ specification_version: 4
152
106
  summary: Calculate the differences between two XML/HTML documents.
153
107
  test_files: []
data/.gemtest DELETED
File without changes