share_checker 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -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"] = "Mozilla/5.0 (X11; Linux i686; rv:2.0.1) Gecko/20100101 Firefox/6.0.0"
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
@@ -1,3 +1,3 @@
1
1
  module ShareChecker
2
- VERSION = "0.1.5".freeze
2
+ VERSION = "0.1.6".freeze
3
3
  end
@@ -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: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 5
10
- version: 0.1.5
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-10-24 00:00:00 +03:00
19
+ date: 2011-11-02 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency