bitlyr 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.3
1
+ 0.9.4
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "bitlyr"
8
- s.version = "0.9.3"
8
+ s.version = "0.9.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["jonstorer"]
12
- s.date = "2012-01-17"
12
+ s.date = "2012-01-20"
13
13
  s.description = "A ruby wrapper for version 3 of the bit.ly API\nSupports Login/ApiKey & OAuth authentication\n"
14
14
  s.email = "jonathon.scott.storer@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
35
35
  "lib/bitlyr/missing_url.rb",
36
36
  "lib/bitlyr/realtime_link.rb",
37
37
  "lib/bitlyr/referrer.rb",
38
+ "lib/bitlyr/referring_domain.rb",
38
39
  "lib/bitlyr/response.rb",
39
40
  "lib/bitlyr/strategy/access_token.rb",
40
41
  "lib/bitlyr/strategy/api_key.rb",
@@ -109,6 +110,7 @@ Gem::Specification.new do |s|
109
110
  "test/unit/test_missing.rb",
110
111
  "test/unit/test_realtime_link.rb",
111
112
  "test/unit/test_referrer.rb",
113
+ "test/unit/test_referring_domain.rb",
112
114
  "test/unit/test_response.rb",
113
115
  "test/unit/test_url.rb",
114
116
  "test/unit/test_user.rb"
@@ -27,6 +27,7 @@ require 'bitlyr/error'
27
27
  require 'bitlyr/missing_url'
28
28
  require 'bitlyr/realtime_link'
29
29
  require 'bitlyr/referrer'
30
+ require 'bitlyr/referring_domain'
30
31
  require 'bitlyr/response'
31
32
  require 'bitlyr/url'
32
33
  require 'bitlyr/user'
@@ -82,6 +82,13 @@ module Bitlyr
82
82
  get_single_method(:referrers, input)
83
83
  end
84
84
 
85
+ def referring_domains(link, options={})
86
+ response = get('link/referring_domains', {:link => link}.merge(options))
87
+ response['referring_domains'].map do |referring_domain|
88
+ Bitlyr::ReferringDomain.new(referring_domain)
89
+ end
90
+ end
91
+
85
92
  # Expands either a short link or hash and gets the country data for that link
86
93
  #
87
94
  # This method does not take an array as an input
@@ -2,7 +2,7 @@ module Bitlyr
2
2
  class Referrer
3
3
  attr_reader :clicks, :referrer, :referrer_app, :url
4
4
 
5
- def initialize(options)
5
+ def initialize(options={})
6
6
  @url = options['url']
7
7
  @clicks = options['clicks']
8
8
  @referrer = options['referrer']
@@ -0,0 +1,11 @@
1
+ module Bitlyr
2
+ class ReferringDomain
3
+ attr_reader :clicks, :domain
4
+
5
+ def initialize(options={})
6
+ @clicks = options['clicks']
7
+ @domain = options['domain']
8
+ end
9
+ end
10
+ end
11
+
@@ -18,4 +18,19 @@ class TestClient < Test::Unit::TestCase
18
18
  end
19
19
  end
20
20
  end
21
+ context "#referring_domains" do
22
+ setup do
23
+ strategy = Bitlyr::Strategy::OAuth.new('id', 'secret')
24
+ strategy.set_access_token_from_token!('token')
25
+ strategy.stubs(:request => { "referring_domains" => [ {'domain' => 'direct', 'clicks' => 700} ] } )
26
+ @client = Bitlyr::Client.new(strategy)
27
+ end
28
+ should "return an array" do
29
+ assert @client.referring_domains('http://bit.ly/somelink/').is_a?(Array)
30
+ end
31
+ should "return an array of referring domains" do
32
+ assert_equal 1, @client.referring_domains('http://bit.ly/somelink/').map(&:class).uniq.size
33
+ assert @client.referring_domains('http://bit.ly/somelink/').first.is_a?(Bitlyr::ReferringDomain)
34
+ end
35
+ end
21
36
  end
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ class TestReferringDomain < Test::Unit::TestCase
4
+ context "a referring domain" do
5
+ setup do
6
+ @referring_domain = Bitlyr::ReferringDomain.new
7
+ end
8
+
9
+ [:clicks, :domain].each do |method|
10
+ should "respond to #{method}" do
11
+ assert_respond_to @referring_domain, method
12
+ end
13
+
14
+ should "set #{method} when initializing" do
15
+ referrer = Bitlyr::ReferringDomain.new(method.to_s => 'test')
16
+ assert_equal 'test', referrer.send(method)
17
+ end
18
+ end
19
+ end
20
+ end
21
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitlyr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-17 00:00:00.000000000Z
12
+ date: 2012-01-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
16
- requirement: &70325468890100 !ruby/object:Gem::Requirement
16
+ requirement: &70283798192200 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.7.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70325468890100
24
+ version_requirements: *70283798192200
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: oauth2
27
- requirement: &70325468889540 !ruby/object:Gem::Requirement
27
+ requirement: &70283798191720 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.1.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70325468889540
35
+ version_requirements: *70283798191720
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: shoulda
38
- requirement: &70325468888800 !ruby/object:Gem::Requirement
38
+ requirement: &70283798191080 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70325468888800
46
+ version_requirements: *70283798191080
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &70325468888100 !ruby/object:Gem::Requirement
49
+ requirement: &70283798190400 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.4.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70325468888100
57
+ version_requirements: *70283798190400
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rcov
60
- requirement: &70325468887500 !ruby/object:Gem::Requirement
60
+ requirement: &70283798189660 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70325468887500
68
+ version_requirements: *70283798189660
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: mocha
71
- requirement: &70325468887000 !ruby/object:Gem::Requirement
71
+ requirement: &70283798189180 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.10.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70325468887000
79
+ version_requirements: *70283798189180
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: fakeweb
82
- requirement: &70325468886520 !ruby/object:Gem::Requirement
82
+ requirement: &70283798188580 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: 1.2.8
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70325468886520
90
+ version_requirements: *70283798188580
91
91
  description: ! 'A ruby wrapper for version 3 of the bit.ly API
92
92
 
93
93
  Supports Login/ApiKey & OAuth authentication
@@ -118,6 +118,7 @@ files:
118
118
  - lib/bitlyr/missing_url.rb
119
119
  - lib/bitlyr/realtime_link.rb
120
120
  - lib/bitlyr/referrer.rb
121
+ - lib/bitlyr/referring_domain.rb
121
122
  - lib/bitlyr/response.rb
122
123
  - lib/bitlyr/strategy/access_token.rb
123
124
  - lib/bitlyr/strategy/api_key.rb
@@ -192,6 +193,7 @@ files:
192
193
  - test/unit/test_missing.rb
193
194
  - test/unit/test_realtime_link.rb
194
195
  - test/unit/test_referrer.rb
196
+ - test/unit/test_referring_domain.rb
195
197
  - test/unit/test_response.rb
196
198
  - test/unit/test_url.rb
197
199
  - test/unit/test_user.rb