share_checker 0.1.3 → 0.1.4
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.
- data/Gemfile +1 -0
- data/lib/share_checker/providers/facebook.rb +5 -2
- data/lib/share_checker/version.rb +1 -1
- data/spec/providers/facebook_spec.rb +2 -14
- metadata +18 -4
data/Gemfile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
1
3
|
module ShareChecker
|
2
4
|
module Providers
|
3
5
|
class Facebook < Provider
|
@@ -18,8 +20,9 @@ module ShareChecker
|
|
18
20
|
# </links_getStats_response>
|
19
21
|
#
|
20
22
|
def parse(response)
|
21
|
-
doc =
|
22
|
-
|
23
|
+
doc = ::Nokogiri::XML(response)
|
24
|
+
node = doc.at("like_count")
|
25
|
+
node.nil? ? 0 : node.content.to_i
|
23
26
|
end
|
24
27
|
|
25
28
|
def url
|
@@ -6,20 +6,8 @@ describe ShareChecker::Providers::Facebook do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should parse response from facebook" do
|
9
|
-
response = '<links_getStats_response list="true">
|
10
|
-
<link_stat>
|
11
|
-
<url>http://www.mcdonaldseurokids2012.com.ua/challenges/1/works/98</url>
|
12
|
-
<normalized_url>http://www.mcdonaldseurokids2012.com.ua/challenges/1/works/98</normalized_url>
|
13
|
-
<share_count>36</share_count>
|
14
|
-
<like_count>406</like_count>
|
15
|
-
<comment_count>0</comment_count>
|
16
|
-
<total_count>442</total_count>
|
17
|
-
<click_count>0</click_count>
|
18
|
-
<comments_fbid>10150218116270823</comments_fbid>
|
19
|
-
<commentsbox_count>0</commentsbox_count>
|
20
|
-
</link_stat>
|
21
|
-
</links_getStats_response>'
|
9
|
+
response = '<links_getStats_response xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true"><link_stat><url>http://www.mcdonaldseurokids2012.com.ua/works/570</url><normalized_url>http://www.mcdonaldseurokids2012.com.ua/works/570</normalized_url><share_count>0</share_count><like_count>16</like_count><comment_count>0</comment_count><total_count>16</total_count><click_count>0</click_count><comments_fbid>10150408802277464</comments_fbid><commentsbox_count>0</commentsbox_count></link_stat></links_getStats_response>'
|
22
10
|
|
23
|
-
@provider.parse(response).should ==
|
11
|
+
@provider.parse(response).should == 16
|
24
12
|
end
|
25
13
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: share_checker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Igor Galeta
|
@@ -47,7 +47,7 @@ dependencies:
|
|
47
47
|
type: :runtime
|
48
48
|
version_requirements: *id002
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
|
-
name:
|
50
|
+
name: nokogiri
|
51
51
|
prerelease: false
|
52
52
|
requirement: &id003 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
@@ -60,6 +60,20 @@ dependencies:
|
|
60
60
|
version: "0"
|
61
61
|
type: :runtime
|
62
62
|
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: curb
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
type: :runtime
|
76
|
+
version_requirements: *id004
|
63
77
|
description: Insert ShareChecker description.
|
64
78
|
email: galeta.igor@gmail.com
|
65
79
|
executables: []
|