share_checker 0.1.5 → 0.1.6
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/README.rdoc +4 -1
- data/lib/share_checker/config.rb +4 -0
- data/lib/share_checker/provider.rb +4 -1
- data/lib/share_checker/version.rb +1 -1
- data/spec/share_checker_spec.rb +5 -0
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -9,7 +9,10 @@ The easiest way to check how many times a URL has been shared on Twitter, Facebo
|
|
9
9
|
== Configure
|
10
10
|
|
11
11
|
ShareChecker.setup do |config|
|
12
|
-
config.vkontakte = { :app_id => 00000 }
|
12
|
+
config.vkontakte = { :app_id => 00000 }
|
13
|
+
|
14
|
+
config.timeout = 30
|
15
|
+
config.user_agent = 'ShareChecker Robot'
|
13
16
|
end
|
14
17
|
|
15
18
|
== Usage
|
data/lib/share_checker/config.rb
CHANGED
@@ -26,10 +26,14 @@ module ShareChecker
|
|
26
26
|
end
|
27
27
|
|
28
28
|
hash_accessor *Providers.avariable
|
29
|
+
hash_accessor :timeout, :user_agent
|
29
30
|
|
30
31
|
def initialize(other = {})
|
31
32
|
merge!(other)
|
32
33
|
|
34
|
+
self[:timeout] ||= 30
|
35
|
+
self[:user_agent] ||= "ShareChecker Robot"
|
36
|
+
|
33
37
|
Providers.avariable.each do |provider|
|
34
38
|
self[provider] ||= {}
|
35
39
|
end
|
@@ -59,8 +59,11 @@ module ShareChecker
|
|
59
59
|
class << self
|
60
60
|
def get(url)
|
61
61
|
c = Curl::Easy.new(url) do |curl|
|
62
|
-
curl.headers["User-Agent"] =
|
62
|
+
curl.headers["User-Agent"] = ShareChecker.config.user_agent
|
63
|
+
curl.timeout = ShareChecker.config.timeout
|
63
64
|
curl.verbose = false
|
65
|
+
curl.follow_location = true
|
66
|
+
curl.max_redirects = 2
|
64
67
|
end
|
65
68
|
|
66
69
|
c.perform
|
data/spec/share_checker_spec.rb
CHANGED
@@ -14,6 +14,11 @@ describe ShareChecker do
|
|
14
14
|
it "should return full list of avariable providers" do
|
15
15
|
ShareChecker::Providers.avariable.should == [:facebook, :odnoklassniki, :tweetracker, :twitter, :vkontakte]
|
16
16
|
end
|
17
|
+
|
18
|
+
it "should get google search page" do
|
19
|
+
body = ShareChecker::Provider.get("http://www.google.com/")
|
20
|
+
body.should include("<title>Google</title>")
|
21
|
+
end
|
17
22
|
end
|
18
23
|
|
19
24
|
context "setup" do
|
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: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Igor Galeta
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-11-02 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|