sms-htmldiff 0.0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +24 -0
- data/LICENSE +20 -0
- data/README.md +35 -0
- data/Rakefile +54 -0
- data/htmldiff.gemspec +25 -0
- data/lib/htmldiff/diff_builder.rb +156 -0
- data/lib/htmldiff/list_of_words.rb +182 -0
- data/lib/htmldiff/match.rb +17 -0
- data/lib/htmldiff/match_finder.rb +238 -0
- data/lib/htmldiff/operation.rb +38 -0
- data/lib/htmldiff/word.rb +57 -0
- data/lib/htmldiff.rb +14 -0
- data/spec/diffing_output/block_tag_spec.rb +11 -0
- data/spec/diffing_output/iframes_spec.rb +33 -0
- data/spec/diffing_output/img_tags_spec.rb +49 -0
- data/spec/diffing_output/paragraph_tags_spec.rb +60 -0
- data/spec/diffing_output/tables_spec.rb +47 -0
- data/spec/diffing_output/text_spec.rb +48 -0
- data/spec/list_of_words_spec.rb +53 -0
- data/spec/operation_spec.rb +45 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/word_spec.rb +31 -0
- metadata +93 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HTMLDiff::Operation do
|
4
|
+
describe 'same_tag?' do
|
5
|
+
let(:old_words) { HTMLDiff::ListOfWords.new old_tag }
|
6
|
+
let(:new_words) { HTMLDiff::ListOfWords.new new_tag }
|
7
|
+
let(:operation) { HTMLDiff::Operation.new :equal, old_words, new_words }
|
8
|
+
|
9
|
+
context 'with identical tags' do
|
10
|
+
let(:old_tag) { '<p>' }
|
11
|
+
let(:new_tag) { '<p>' }
|
12
|
+
|
13
|
+
it 'returns true for identical simple tags' do
|
14
|
+
expect(operation.same_tag?).to be_true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with the same tag that has a new attribute' do
|
19
|
+
let(:old_tag) { '<p>' }
|
20
|
+
let(:new_tag) { '<p style="margin: 2px;">' }
|
21
|
+
|
22
|
+
it 'returns true for one simple and one complex tag' do
|
23
|
+
expect(operation.same_tag?).to be_true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'with two different tags' do
|
28
|
+
let(:old_tag) { '<p>' }
|
29
|
+
let(:new_tag) { '<b>' }
|
30
|
+
|
31
|
+
it 'returns false for non matching simple tags' do
|
32
|
+
expect(operation.same_tag?).to be_false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'with two identical bits of text' do
|
37
|
+
let(:old_tag) { 'blah' }
|
38
|
+
let(:new_tag) { 'blah' }
|
39
|
+
|
40
|
+
it 'should return false for random text' do
|
41
|
+
expect(operation.same_tag?).to be_false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/spec/word_spec.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe HTMLDiff::Word do
|
4
|
+
describe 'opening_tag?' do
|
5
|
+
it 'returns true for <p>' do
|
6
|
+
expect(described_class.new('<p>').opening_tag?).to be_true
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'returns true for <p> with spaces' do
|
10
|
+
expect(described_class.new(' <p> ').opening_tag?).to be_true
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'returns true for a tag with a url' do
|
14
|
+
a_tag = '<a href="http://google.com">'
|
15
|
+
expect(described_class.new(a_tag).opening_tag?).to be_true
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'returns false for </p>' do
|
19
|
+
expect(described_class.new('</p>').opening_tag?).to be_false
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns false for </p> with spaces' do
|
23
|
+
expect(described_class.new(' </p> ').opening_tag?).to be_false
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns false for internal del tags' do
|
27
|
+
del_tag = '<del class="diffdel">More</del>'
|
28
|
+
expect(described_class.new(del_tag).opening_tag?).to be_false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sms-htmldiff
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nathan Herald
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2008-11-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.6.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.6.5
|
27
|
+
description:
|
28
|
+
email: nathan@myobie.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.md
|
33
|
+
- LICENSE
|
34
|
+
files:
|
35
|
+
- Gemfile
|
36
|
+
- Gemfile.lock
|
37
|
+
- LICENSE
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- htmldiff.gemspec
|
41
|
+
- lib/htmldiff.rb
|
42
|
+
- lib/htmldiff/diff_builder.rb
|
43
|
+
- lib/htmldiff/list_of_words.rb
|
44
|
+
- lib/htmldiff/match.rb
|
45
|
+
- lib/htmldiff/match_finder.rb
|
46
|
+
- lib/htmldiff/operation.rb
|
47
|
+
- lib/htmldiff/word.rb
|
48
|
+
- spec/diffing_output/block_tag_spec.rb
|
49
|
+
- spec/diffing_output/iframes_spec.rb
|
50
|
+
- spec/diffing_output/img_tags_spec.rb
|
51
|
+
- spec/diffing_output/paragraph_tags_spec.rb
|
52
|
+
- spec/diffing_output/tables_spec.rb
|
53
|
+
- spec/diffing_output/text_spec.rb
|
54
|
+
- spec/list_of_words_spec.rb
|
55
|
+
- spec/operation_spec.rb
|
56
|
+
- spec/spec_helper.rb
|
57
|
+
- spec/word_spec.rb
|
58
|
+
homepage: http://github.com/stackmystack/htmldiff
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options:
|
64
|
+
- "--main"
|
65
|
+
- README.md
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubygems_version: 3.3.7
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: HTML diffs of text (borrowed from a wiki software I no longer remember)
|
83
|
+
test_files:
|
84
|
+
- spec/diffing_output/block_tag_spec.rb
|
85
|
+
- spec/diffing_output/iframes_spec.rb
|
86
|
+
- spec/diffing_output/img_tags_spec.rb
|
87
|
+
- spec/diffing_output/paragraph_tags_spec.rb
|
88
|
+
- spec/diffing_output/tables_spec.rb
|
89
|
+
- spec/diffing_output/text_spec.rb
|
90
|
+
- spec/list_of_words_spec.rb
|
91
|
+
- spec/operation_spec.rb
|
92
|
+
- spec/spec_helper.rb
|
93
|
+
- spec/word_spec.rb
|