comparateur 1.0.1 → 1.0.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
  SHA1:
3
- metadata.gz: c7daf8b8b81254e0980c4688f78a2d661d20d7d1
4
- data.tar.gz: ff6f186dd3785d367d4aceea8cddd93cd9cf6c54
3
+ metadata.gz: 29c929d2e8f2a89a4a4a36bcd412819a0feaf171
4
+ data.tar.gz: 4287a132f615bb35cff1c4e49da0697387aae91d
5
5
  SHA512:
6
- metadata.gz: 8567a368084d611620db6a2c7a69a4e5a3b4eec73150e50929e7dc8e56fe3dd7c57a0b7f5a8989230aadf414b093719ca6d8e7ea1d14deb7342a315b4311dfde
7
- data.tar.gz: f22964f04e29338ad38ccc11e476702460efc5994d46d0cb310eff02e127099fa260ff3cc8157872f4984f7e74ef71b146cd2171069b9574de9bd4826540eb8d
6
+ metadata.gz: ad03801f73f44f3e89d95d9591f569f7eb7a82f3e89f3512e6d88d00a3a8b3aaefdd1a4721a1514e583ea38e9300bb183225f766d9380d70541a93c638a14950
7
+ data.tar.gz: 883479951d98d6409d6637e05141f8c078c42dc9f766c20a9408bfd80758c2c493ce37f941d754fbca607d0c0d80e52de6bc08b6ba2443efb1982d00d6d1d00d
data/README.md CHANGED
@@ -26,7 +26,11 @@ exp = Le::Comparateur.new
26
26
  a = "<html><body></body></html>"
27
27
  b = "<html><body><h1></h1></body></html>"
28
28
 
29
- p exp.calculate_similarity(a, b) * 100
29
+ c = Nokogiri::HTML("<html><body></body></html>")
30
+ d = a
31
+
32
+ p exp.calculate_similarity(a, b) * 100 # in %
33
+ p exp.calculate_similarity(c, d)
30
34
  ```
31
35
 
32
36
  ## Contributing
data/a.rb ADDED
@@ -0,0 +1,11 @@
1
+ load "lib/comparateur.rb"
2
+
3
+ exp = Le::Comparateur.new
4
+
5
+ #site1 = Nokogiri::HTML("<html><body><h1></h1><h2></h2></body></html>")
6
+
7
+
8
+ site1 = ["html", "body"]
9
+ site2 = Nokogiri::HTML("<html><body></body></html>")
10
+
11
+ p exp.calculate_similarity(site1, site2)
@@ -1,3 +1,3 @@
1
1
  module Comparateur
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
data/lib/comparateur.rb CHANGED
@@ -6,11 +6,11 @@ module Le
6
6
  class Comparateur
7
7
 
8
8
  def calculate_similarity site1, site2
9
- nok_site1 = Nokogiri::HTML(site1)
10
- nok_site2 = Nokogiri::HTML(site2)
9
+ site1 = Nokogiri::HTML(site1) unless site1.is_a?(Nokogiri::HTML::Document)
10
+ site2 = Nokogiri::HTML(site2) unless site2.is_a?(Nokogiri::HTML::Document)
11
11
 
12
- arr_site1 = nok_site1.search('*').map(&:name)
13
- arr_site2 = nok_site2.search('*').map(&:name)
12
+ arr_site1 = site1.search('*').map(&:name)
13
+ arr_site2 = site2.search('*').map(&:name)
14
14
  lcs = Diff::LCS.LCS(arr_site1, arr_site2)
15
15
 
16
16
  return (2.0 * lcs.length.to_f) / (arr_site1.length.to_f + arr_site2.length.to_f)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comparateur
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Radu-Bogdan Croitoru
@@ -78,6 +78,7 @@ files:
78
78
  - LICENSE.txt
79
79
  - README.md
80
80
  - Rakefile
81
+ - a.rb
81
82
  - comparateur.gemspec
82
83
  - lib/comparateur.rb
83
84
  - lib/comparateur/version.rb