socialcount 0.0.0 → 0.0.1

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.
Files changed (3) hide show
  1. checksums.yaml +15 -0
  2. data/lib/socialcount.rb +9 -2
  3. metadata +11 -10
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NmRjOTI4ZWZjMTc4ODI4ZjAyMzI4NjllMjYxNWQ1MDA4NzljZGVhZQ==
5
+ data.tar.gz: !binary |-
6
+ YmYyNjNkMjY2OTczMTIyNDZjYWE2Mjc1Mjk1OWM1N2IxMWZmYmFkYw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YTg2Mzc4YTJkMjVkMTg0YmEzN2FlYmRmYTRlNzI2OTI3ZDBjMGQ4NDczNWZh
10
+ YjI3ODJiNGI5ZGE1ZDRkNDU4MDM2NzZkNzAwODlkYTBkMzVmN2M1ZWZkZmQ2
11
+ MWU3MTM5NWJiZGQxNWFlNGExNjU5NjhlYTEzZjM2YzY5MjFkMmM=
12
+ data.tar.gz: !binary |-
13
+ NTA1ZmE5YjAwYzNjNWQyMmQxYjQyNGYxMzAzYWY5N2ZmZGRiN2E5ZDdlZWEy
14
+ YzJjNmM5YzMzMjllZGI1ODU3YTgzMGUzYzQ5ZjdlNzZjN2MyMjgwZThkZjQ4
15
+ MDVmY2U2NTc3ODFmZWQ5MWVlMDZkY2Q5NWE2NjVkMGQ3ZGVjMzY=
@@ -6,11 +6,18 @@ class SocialCount
6
6
 
7
7
  API_URL = "http://api.sharedcount.com/?url="
8
8
 
9
+ def initialize(api_key=nil)
10
+ @api_key = api_key
11
+ end
12
+
9
13
  def query(url)
10
- response = Net::HTTP.get_response(URI.parse(API_URL + url))
14
+ query_url = API_URL + url
15
+ query_url = query_url + "&apikey=#{@api_key}" if @api_key
16
+
17
+ response = Net::HTTP.get_response(URI.parse(query_url))
11
18
  stats = JSON.parse(response.body)
12
19
 
13
- raise WebServiceError, "A error occured. This is most likely because you entered a invalid URI." if stats.has_key? "Error"
20
+ raise WebServiceError, stats['Error'] if stats.has_key? "Error"
14
21
 
15
22
  Hash[stats.map { |k,v| [k.downcase,v]}]
16
23
  end
metadata CHANGED
@@ -1,27 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socialcount
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
5
- prerelease:
4
+ version: 0.0.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jake Austwick
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-11-13 00:00:00.000000000Z
11
+ date: 2011-11-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: json
16
- requirement: &70322674444440 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *70322674444440
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  description: ! 'SocialCount is a gem to make it extemely easy for your to find out
26
28
  social statistics about any URI. It returns tweets, diggs, google +1''s and much
27
29
  more '
@@ -33,26 +35,25 @@ files:
33
35
  - lib/socialcount.rb
34
36
  homepage: https://github.com/JakeAustwick/Social-Statistics-Counter-Ruby
35
37
  licenses: []
38
+ metadata: {}
36
39
  post_install_message:
37
40
  rdoc_options: []
38
41
  require_paths:
39
42
  - lib
40
43
  required_ruby_version: !ruby/object:Gem::Requirement
41
- none: false
42
44
  requirements:
43
45
  - - ! '>='
44
46
  - !ruby/object:Gem::Version
45
47
  version: '0'
46
48
  required_rubygems_version: !ruby/object:Gem::Requirement
47
- none: false
48
49
  requirements:
49
50
  - - ! '>='
50
51
  - !ruby/object:Gem::Version
51
52
  version: '0'
52
53
  requirements: []
53
54
  rubyforge_project:
54
- rubygems_version: 1.8.10
55
+ rubygems_version: 2.1.11
55
56
  signing_key:
56
- specification_version: 3
57
+ specification_version: 4
57
58
  summary: A gem to easily retrieve social statistics for any url
58
59
  test_files: []