bitly-oauth 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -74,6 +74,16 @@ module BitlyOAuth
74
74
  @referrers
75
75
  end
76
76
 
77
+ # If the url already has referring_domains data, return it.
78
+ # IF there is no referring_domains or <tt>:force => true</tt> is passed,
79
+ # updates the referring_domains and returns them
80
+ def referring_domains(options={})
81
+ if @referring_domains.nil? || options[:force]
82
+ @referring_domains = @client.referring_domains(@short_url)
83
+ end
84
+ @referring_domains
85
+ end
86
+
77
87
  # If the url already has country data, return it.
78
88
  # IF there is no country or <tt>:force => true</tt> is passed,
79
89
  # updates the countries and returns them
@@ -5,6 +5,7 @@ module BitlyOAuth
5
5
  # client = BitlyOAuth::Client.new(consumer_token, consumer_secret)
6
6
  # client.authorize_url(redirect_url)
7
7
  # #=> "https://bitly.com/oauth/authorize?client_id=id&type=code&redirect_uri=http%3A%2F%2Ftest.local%2Fbitly-oauth%2Fauth"
8
+ #
8
9
  # Redirect your users to this url, when they authorize your application
9
10
  # they will be redirected to the url you provided with a code parameter.
10
11
  # Use that parameter, and the exact same redirect url as follows:
@@ -20,6 +20,7 @@ class TestUrl < Test::Unit::TestCase
20
20
  :title,
21
21
  :created_by,
22
22
  :referrers,
23
+ :referring_domains,
23
24
  :countries,
24
25
  :clicks_by_minute,
25
26
  :clicks_by_day].each do |method|
@@ -102,6 +103,24 @@ class TestUrl < Test::Unit::TestCase
102
103
  assert_equal 63, @url.referrers(:force => true).first.clicks
103
104
  end
104
105
  end
106
+ context "getting referring_domains" do
107
+ should 'get referring_domains when called' do
108
+ @client.stubs(:referring_domains => [ BitlyOAuth::ReferringDomain.new( {'domain' => 'direct', 'clicks' => 62} ) ] )
109
+ url = BitlyOAuth::Url.new(@client, 'hash' => 'djZ9g4')
110
+ assert_instance_of Array, url.referring_domains
111
+ assert_instance_of BitlyOAuth::ReferringDomain, url.referring_domains.first
112
+ assert_equal 'direct', url.referring_domains.first.domain
113
+ assert_equal 62, url.referring_domains.first.clicks
114
+ end
115
+ should 'force update when told to' do
116
+ @client.stubs(:referring_domains => [ BitlyOAuth::ReferringDomain.new( {'domain' => 'direct', 'clicks' => 62} ) ] )
117
+ url = BitlyOAuth::Url.new(@client, 'hash' => 'djZ9g4')
118
+ assert_equal 62, url.referring_domains.first.clicks
119
+ url.instance_eval{ @client.stubs(:referring_domains => [ BitlyOAuth::ReferringDomain.new( {'domain' => 'direct', 'clicks' => 63} ) ] ) }
120
+ assert_equal 62, url.referring_domains.first.clicks
121
+ assert_equal 63, url.referring_domains(:force => true).first.clicks
122
+ end
123
+ end
105
124
  context "getting countries" do
106
125
  setup do
107
126
  stub_get("https://api-ssl.bit.ly/v3/countries?hash=djZ9g4&access_token=token", ['country_hash.json', 'country_hash2.json'])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitly-oauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
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-21 00:00:00.000000000Z
12
+ date: 2012-01-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
16
- requirement: &70324210549840 !ruby/object:Gem::Requirement
16
+ requirement: &70144093311940 !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: *70324210549840
24
+ version_requirements: *70144093311940
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: oauth2
27
- requirement: &70324210549300 !ruby/object:Gem::Requirement
27
+ requirement: &70144093311400 !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: *70324210549300
35
+ version_requirements: *70144093311400
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: shoulda
38
- requirement: &70324210548740 !ruby/object:Gem::Requirement
38
+ requirement: &70144093310880 !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: *70324210548740
46
+ version_requirements: *70144093310880
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &70324210548180 !ruby/object:Gem::Requirement
49
+ requirement: &70144093310300 !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: *70324210548180
57
+ version_requirements: *70144093310300
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rcov
60
- requirement: &70324210547460 !ruby/object:Gem::Requirement
60
+ requirement: &70144093309660 !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: *70324210547460
68
+ version_requirements: *70144093309660
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: mocha
71
- requirement: &70324210545740 !ruby/object:Gem::Requirement
71
+ requirement: &70144093307840 !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: *70324210545740
79
+ version_requirements: *70144093307840
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: fakeweb
82
- requirement: &70324210545260 !ruby/object:Gem::Requirement
82
+ requirement: &70144093307360 !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: *70324210545260
90
+ version_requirements: *70144093307360
91
91
  description: ! 'A ruby wrapper for version 3 of the bit.ly API
92
92
 
93
93
  Supports OAuth authentication