tdiff 0.3.4 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +28 -0
- data/ChangeLog.md +5 -0
- data/Gemfile +2 -1
- data/LICENSE.txt +1 -1
- data/README.md +41 -35
- data/gemspec.yml +9 -2
- data/lib/tdiff/tdiff.rb +2 -0
- data/lib/tdiff/unordered.rb +3 -1
- data/lib/tdiff/version.rb +3 -1
- data/lib/tdiff.rb +5 -3
- data/tdiff.gemspec +1 -4
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6d61fc5d074be499bc2ae185b6449d10354fe3dfd2dfda2ad1529f246dc1cb39
|
4
|
+
data.tar.gz: 4496f53bef15c4e46d195434458ded3a6f13b65afda56a755d5d3128a3b94463
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ab9b88ebc51c447c49c19b8823849d3b8b25f7d3c981bda20c74743415dd8e6062371a67493245160a6d31f004a3e06cf97357c57576c981b6f2a93da7af60d
|
7
|
+
data.tar.gz: 461c9fcc0bd2ad6d48a7801f6f847baadbabe6e55c4b75d3dd50e86400fdab477ecb910a70a8972cd6460261e149c639ae64af3d3b2a111d363cea5a6130a599
|
@@ -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/ChangeLog.md
CHANGED
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
* [Source](https://github.com/postmodern/tdiff)
|
4
4
|
* [Issues](https://github.com/postmodern/tdiff/issues)
|
5
|
-
*
|
5
|
+
* [Documentation](https://rubydoc.info/gems/tdiff)
|
6
6
|
|
7
7
|
## Description
|
8
8
|
|
@@ -22,56 +22,62 @@ module.
|
|
22
22
|
|
23
23
|
Diff two HTML documents:
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
```ruby
|
26
|
+
require 'nokogiri'
|
27
|
+
require 'tdiff'
|
27
28
|
|
28
|
-
|
29
|
+
class Nokogiri::XML::Node
|
29
30
|
|
30
|
-
|
31
|
+
include TDiff
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
33
|
+
def tdiff_equal(node)
|
34
|
+
if (self.text? && node.text?)
|
35
|
+
self.text == node.text
|
36
|
+
elsif (self.respond_to?(:root) && node.respond_to?(:root))
|
37
|
+
self.root.tdiff_equal(node.root)
|
38
|
+
elsif (self.respond_to?(:name) && node.respond_to?(:name))
|
39
|
+
self.name == node.name
|
40
|
+
else
|
41
|
+
false
|
42
|
+
end
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
def tdiff_each_child(node,&block)
|
46
|
+
node.children.each(&block)
|
47
|
+
end
|
47
48
|
|
48
|
-
|
49
|
+
end
|
49
50
|
|
50
|
-
|
51
|
-
|
51
|
+
doc1 = Nokogiri::HTML('<div><p>one</p> <p>three</p></div>')
|
52
|
+
doc2 = Nokogiri::HTML('<div><p>one</p> <p>two</p> <p>three</p></div>')
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
doc1.at('div').tdiff(doc2.at('div')) do |change,node|
|
55
|
+
puts "#{change} #{node.to_html}".ljust(30) + node.parent.path
|
56
|
+
end
|
57
|
+
```
|
56
58
|
|
57
59
|
### Output
|
58
60
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
61
|
+
```
|
62
|
+
+ <p>one</p> /html/body/div
|
63
|
+
+ /html/body/div
|
64
|
+
<p>one</p> /html/body/div
|
65
|
+
/html/body/div
|
66
|
+
<p>three</p> /html/body/div
|
67
|
+
- one /html/body/div/p[1]
|
68
|
+
+ two /html/body/div/p[2]
|
69
|
+
three /html/body/div/p[2]
|
70
|
+
```
|
67
71
|
|
68
72
|
## Requirements
|
69
73
|
|
70
|
-
* [ruby](http://www.ruby-lang.org/) >=
|
74
|
+
* [ruby](http://www.ruby-lang.org/) >= 2.0.0
|
71
75
|
|
72
76
|
## Install
|
73
77
|
|
74
|
-
|
78
|
+
```shell
|
79
|
+
$ gem install tdiff
|
80
|
+
```
|
75
81
|
|
76
82
|
## Copyright
|
77
83
|
|
data/gemspec.yml
CHANGED
@@ -10,7 +10,14 @@ email: postmodern.mod3@gmail.com
|
|
10
10
|
homepage: https://github.com/postmodern/tdiff#readme
|
11
11
|
has_yard: true
|
12
12
|
|
13
|
-
|
13
|
+
metadata:
|
14
|
+
documentation_uri: https://rubydoc.info/gems/tdiff
|
15
|
+
source_code_uri: https://github.com/postmodern/tdiff
|
16
|
+
bug_tracker_uri: https://github.com/postmodern/tdiff/issues
|
17
|
+
changelog_uri: https://github.com/postmodern/tdiff/blob/main/ChangeLog.md
|
18
|
+
rubygems_mfa_required: 'true'
|
19
|
+
|
20
|
+
required_ruby_version: ">= 2.0.0"
|
14
21
|
|
15
22
|
development_dependencies:
|
16
|
-
bundler: ~>
|
23
|
+
bundler: ~> 2.0
|
data/lib/tdiff/tdiff.rb
CHANGED
data/lib/tdiff/unordered.rb
CHANGED
data/lib/tdiff/version.rb
CHANGED
data/lib/tdiff.rb
CHANGED
data/tdiff.gemspec
CHANGED
@@ -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
|
-
|
11
|
-
$LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
|
12
|
-
|
13
|
-
require 'tdiff/version'
|
10
|
+
require_relative 'lib/tdiff/version'
|
14
11
|
TDiff::VERSION
|
15
12
|
end
|
16
13
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tdiff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Postmodern
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
description: Calculates the differences between two tree-like structures. Similar
|
28
28
|
to Rubys built-in TSort module.
|
29
29
|
email: postmodern.mod3@gmail.com
|
@@ -36,6 +36,7 @@ extra_rdoc_files:
|
|
36
36
|
files:
|
37
37
|
- ".document"
|
38
38
|
- ".gemtest"
|
39
|
+
- ".github/workflows/ruby.yml"
|
39
40
|
- ".gitignore"
|
40
41
|
- ".rspec"
|
41
42
|
- ".yardopts"
|
@@ -60,7 +61,7 @@ homepage: https://github.com/postmodern/tdiff#readme
|
|
60
61
|
licenses:
|
61
62
|
- MIT
|
62
63
|
metadata: {}
|
63
|
-
post_install_message:
|
64
|
+
post_install_message:
|
64
65
|
rdoc_options: []
|
65
66
|
require_paths:
|
66
67
|
- lib
|
@@ -68,16 +69,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
68
69
|
requirements:
|
69
70
|
- - ">="
|
70
71
|
- !ruby/object:Gem::Version
|
71
|
-
version:
|
72
|
+
version: 2.0.0
|
72
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
74
|
requirements:
|
74
75
|
- - ">="
|
75
76
|
- !ruby/object:Gem::Version
|
76
77
|
version: '0'
|
77
78
|
requirements: []
|
78
|
-
|
79
|
-
|
80
|
-
signing_key:
|
79
|
+
rubygems_version: 3.4.10
|
80
|
+
signing_key:
|
81
81
|
specification_version: 4
|
82
82
|
summary: Calculates the differences between two tree-like structures.
|
83
83
|
test_files: []
|