optical_diff 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/optical_diff/version.rb +1 -1
- data/lib/optical_diff.rb +3 -2
- metadata +4 -4
data/README.md
CHANGED
@@ -23,7 +23,7 @@ Or install it yourself as:
|
|
23
23
|
```ruby
|
24
24
|
html1 = "<html><body>text</body></html>"
|
25
25
|
html2 = "<html><body>text<p class = 'random_text'>qwerty</p></body></html>"
|
26
|
-
diff = OpticalDiff.diff(html1, html2, :ignore =>
|
26
|
+
diff = OpticalDiff.diff(html1, html2, :ignore => %w(p.random_text'))
|
27
27
|
diff.changed? #=> false
|
28
28
|
```
|
29
29
|
|
data/lib/optical_diff/version.rb
CHANGED
data/lib/optical_diff.rb
CHANGED
@@ -7,13 +7,14 @@ class OpticalDiff
|
|
7
7
|
def diff(html1, html2, options = {})
|
8
8
|
options = {
|
9
9
|
:replace => [],
|
10
|
-
:ignore => []
|
10
|
+
:ignore => [],
|
11
|
+
:diff_option => Diffy::Diff.default_options[:diff]
|
11
12
|
}.merge(options)
|
12
13
|
|
13
14
|
replaced_htmls = [html1, html2].map {|html| replace(html, options[:replace]) }
|
14
15
|
parsed_htmls = replaced_htmls.map {|html| Nokogiri::HTML.parse(html) }
|
15
16
|
stripped_htmls = parsed_htmls.map {|html| strip_ignore_elements(html, options[:ignore]) }
|
16
|
-
DiffResult.new(Diffy::Diff.new(
|
17
|
+
DiffResult.new(Diffy::Diff.new(stripped_htmls[0].to_html, stripped_htmls[1].to_html, :diff => options[:diff_option]))
|
17
18
|
end
|
18
19
|
|
19
20
|
def replace(page, patterns = [])
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: optical_diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Yusuke Mito
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-02-
|
18
|
+
date: 2013-02-07 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: diffy
|