yt 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82e7f06077dbcb70fc043948d27f297d26583085
4
- data.tar.gz: 6b0d5b8bca60d7ce6595105ec076942675b1d448
3
+ metadata.gz: 3ea681e778798edadb759fbe8e533454b280d1cf
4
+ data.tar.gz: 929e6afec24259b7c63fc948e26087ebd969f50c
5
5
  SHA512:
6
- metadata.gz: 311d30cd632fcdbbee8887fa4e834afc0be54640522530152bc758b0423ea3c852ee1a0b7fefee0a4bbd6f7f6b8ce77005422172dafaecd99463cedffe8f21cb
7
- data.tar.gz: 89a54825dfb15fe1d94b4f2aec38395355d8cd51d2d336ce98184557e41ec99e9fe31eb87a8e9349e4f92cff5cff3fb5504f10714dd774332d382ebca71469c4
6
+ metadata.gz: 7a13eaef87573b314a7970958206d46c6ec47b435c617e10d5e74a12153d8c9b1857b2012a6eef1fdadf447b7745a9696d6a3c0ac27e2494d7aeb4f61d8583a9
7
+ data.tar.gz: 5cb78dd502013771cf64cda608784f2b39c59210ad51e2bf64226bd012b8ed535558b4af86d0d77b283f03ef33ad48f17bd2225aaaf6477d6604549516a4b629
data/.travis.yml CHANGED
@@ -24,3 +24,7 @@ env:
24
24
  - secure: ZUx5v/wHW/TENg8NfFINiiMoe2D031ntDTiuIBdf88c/bMClkEtRRgomtK9RBkFonEyGEOkXxUm2SLzRf340V3eIXWQhil7ab1lcYs8X59aVS/NK/GqChH8Nia17gc3OTQ9k6rYvj4Lp60Dh9WG1cijLPd4/OvPmf6qX9uYfJMw=
25
25
  - secure: DumQVO01Y3Ki1skuOYOZzosDb6jS0XyG1O8Agy3mVxXGJzQE+s1z2UFz4gMpsU9o/gmiNMddp7I6+RtbZjo9hN3H7vlRRwEeB7tuUMiDyomSx1FlHcCFfPdTmhxGg8X78SErMWqNC6eReGrCTgBdIq1ho7dIu53qJNxTEFqx7eI=
26
26
  - secure: UCceSRqPe5Y8WCM85qj0i8wlB5gJRSegJZfVj5jnwyermcOc1ZucwDZwTzkYVbLfDGTqTqzqW6M322a1tWm74xeIbxuHG7fw3Waoxk4zh3tg1CmNkzeDZFnl6V10uOMT6pn5E3kfhLzqOzftJN6fTMCgYMdkwJcfdrMX+z1cxwM=
27
+ - secure: QIOy4cACShEuU96BRBC4IdFFbi9Dr58wdFF25q3Tb1FXHQCxeOINF6tGuHsEBa04dNVLsZFCIbP+1mP2li8W40eSxg0PXd5r61mhR106dhBzN1ROX+EIP+mbecGCHgWIYVAtollSkCgHo9UBKUQOHavPnrvt1bTuV0eYvWiCZtc=
28
+ - secure: WICaR3cq/6SS4855tAJSZx0H/EkovfZZsxHY66y/lQ20p+DYJ0l6Jc6CRaZNvDPtj6Zp9Lu72CB2v6J2AO1WkrAvVBiMEj5zkPtVHwCcHxH0FasQCTFaLWy/zvcQeEIvidcBqABMsq1Pqv8p7UD8BRoQq22Vfe2LEjT/X2/eJwY=
29
+ - secure: E1ZoB5XyFxn3b9RVnXgt/JY+ikKLw57+CGcim0us8SdIwKctH8IWv0U7MggWATw2KtLgxEt1YU5MRFBxdO3nWY7XkvsYVCbLpmyFFzSDGZLNaaSLRZqon/N1lwias1pvOFL8cN2yLFXj6qMH67dBCyuQ1Q9LhejlWiGRBiLjfF8=
30
+ - secure: TnQ7HnvTM7pTwO0G7gYj+UjxxhPd0TOYAgHiafExrfr2nG+mkv1tc2OY/f1iB6kNp3+KEw+sNuyVZd1M9pFL93ARhla6FKqi/JoYFR0E2CxiVzAbLcabdtglqb8Jxw9a73YG7zFABZBWdTo5eR0TvpIK+rdTneUaEyCNU+Plh1E=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yt (0.8.1)
4
+ yt (0.8.2)
5
5
  activesupport
6
6
 
7
7
  GEM
data/HISTORY.md CHANGED
@@ -3,6 +3,8 @@ v0.8 - 2014/07/18
3
3
 
4
4
  * [breaking change] channel.subscribe returns nil (not raise an error) when trying to subscribe to your own channel
5
5
  * Add all the status fields to Video (upload status, failure reason, rejection reason, scheduled time, license, embeddable, public stats viewable)
6
+ * Add content_owner.claims to list the claims administered by a content owner.
7
+ * Allow content_owner.claims to be chained with .where, such as in account.videos.where(q: 'query')
6
8
 
7
9
  v0.7 - 2014/06/18
8
10
  -----------------
data/README.md CHANGED
@@ -41,7 +41,7 @@ To install on your system, run
41
41
 
42
42
  To use inside a bundled Ruby project, add this line to the Gemfile:
43
43
 
44
- gem 'yt', '~> 0.8.1'
44
+ gem 'yt', '~> 0.8.2'
45
45
 
46
46
  Since the gem follows [Semantic Versioning](http://semver.org),
47
47
  indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
@@ -85,6 +85,7 @@ Use [Yt::ContentOwner](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Models
85
85
 
86
86
  * authenticate as a YouTube content owner
87
87
  * list the channels partnered with a YouTube content owner
88
+ * list the claims administered by the content owner
88
89
 
89
90
  ```ruby
90
91
  # Content owners can be initialized with access token, refresh token or an authorization code
@@ -92,6 +93,9 @@ content_owner = Yt::ContentOwner.new owner_name: 'CMSname', access_token: 'ya29.
92
93
 
93
94
  content_owner.partnered_channels.count #=> 12
94
95
  content_owner.partnered_channels.first #=> #<Yt::Models::Channel @id=...>
96
+
97
+ content_owner.claims.where(q: 'Fullscreen').count #=> 24
98
+ content_owner.claims.first #=> #<Yt::Models::Claim @id=...>
95
99
  ```
96
100
 
97
101
  *All the above methods require authentication (see below).*
@@ -110,7 +114,8 @@ Use [Yt::Channel](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Models/Chan
110
114
  * retrieve the viewer percentage of a channel by gender and age group
111
115
 
112
116
  ```ruby
113
- channel = Yt::Channel.new id: 'UCxO1tY8h1AhOz0T4ENwmpow'
117
+ # Channels can be initialized with ID or URL
118
+ channel = Yt::Channel.new url: 'youtube.com/fullscreen'
114
119
 
115
120
  channel.title #=> "Fullscreen"
116
121
  channel.description #=> "The first media company for the connected generation."
@@ -194,7 +199,8 @@ Use [Yt::Video](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Models/Video)
194
199
  * retrieve the viewer percentage of a video by gender and age group
195
200
 
196
201
  ```ruby
197
- video = Yt::Video.new id: 'MESycYJytkU'
202
+ # Videos can be initialized with ID or URL
203
+ video = Yt::Video.new url: 'http://youtu.be/MESycYJytkU'
198
204
 
199
205
  video.title #=> "Fullscreen Creator Platform"
200
206
  video.description #=> "The new Fullscreen Creator Platform gives creators and brands a suite..."
@@ -305,7 +311,8 @@ Use [Yt::Playlist](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Models/Pla
305
311
  * delete items from a playlist
306
312
 
307
313
  ```ruby
308
- playlist = Yt::Playlist.new id: 'PLSWYkYzOrPMRCK6j0UgryI8E0NHhoVdRc'
314
+ # Playlists can be initialized with ID or URL
315
+ playlist = Yt::Playlist.new url: 'youtube.com/playlist?list=PLSWYkYzOrPMRCK6j0UgryI8E0NHhoVdRc'
309
316
 
310
317
  playlist.title #=> "Fullscreen Features"
311
318
  playlist.description #=> "You send us your best videos and we feature our favorite ones..."
@@ -0,0 +1,46 @@
1
+ require 'yt/collections/base'
2
+ require 'yt/models/claim'
3
+
4
+ module Yt
5
+ module Collections
6
+ # Provides methods to interact with a collection of Content ID claims.
7
+ #
8
+ # Resources with claims are: {Yt::Models::ContentOwner content owners}.
9
+ class Claims < Base
10
+
11
+ private
12
+
13
+ def new_item(data)
14
+ Yt::Claim.new data: data
15
+ end
16
+
17
+ # @return [Hash] the parameters to submit to YouTube to list claims
18
+ # administered by the content owner.
19
+ # @see https://developers.google.com/youtube/partner/docs/v1/claims/list
20
+ # @see https://developers.google.com/youtube/partner/docs/v1/claimSearch/list
21
+ def list_params
22
+
23
+ super.tap do |params|
24
+ params[:params] = claims_params
25
+ params[:path] = claims_path
26
+ end
27
+ end
28
+
29
+ def claims_params
30
+ {onBehalfOfContentOwner: @parent.owner_name}.tap do |params|
31
+ (@extra_params ||= {}).each do |key, value|
32
+ params[key.to_s.camelize :lower] = value
33
+ end
34
+ end
35
+ end
36
+
37
+ def claims_path
38
+ if @extra_params.empty? || @extra_params.key?(:id)
39
+ '/youtube/partner/v1/claims'
40
+ else
41
+ '/youtube/partner/v1/claimSearch'
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,122 @@
1
+ require 'yt/models/base'
2
+
3
+ module Yt
4
+ module Models
5
+ # Provides methods to interact with YouTube ContentID claims.
6
+ # @see https://developers.google.com/youtube/partner/docs/v1/claims
7
+ class Claim < Base
8
+ def initialize(options = {})
9
+ @data = options[:data]
10
+ end
11
+
12
+ # @return [String] the ID that YouTube assigns and uses to uniquely
13
+ # identify the claim.
14
+ def id
15
+ @id ||= @data['id']
16
+ end
17
+
18
+ # @return [String] the unique YouTube asset ID that identifies the asset
19
+ # associated with the claim.
20
+ def asset_id
21
+ @asset_id ||= @data["assetId"]
22
+ end
23
+
24
+ # @return [String] the unique YouTube video ID that identifies the video
25
+ # associated with the claim.
26
+ def video_id
27
+ @video_id ||= @data["videoId"]
28
+ end
29
+
30
+ # @return [String] the claim’s status. Valid values are: active,
31
+ # appealed, disputed, inactive, pending, potential, takedown, unknown.
32
+ # @note When updating a claim, you can update its status from active to
33
+ # inactive to effectively release the claim, but the API does not
34
+ # support other updates to a claim’s status.
35
+ def status
36
+ @status ||= @data["status"]
37
+ end
38
+
39
+ # @return [Boolean] whether the claim is active.
40
+ def active?
41
+ status == 'active'
42
+ end
43
+
44
+ # @return [Boolean] whether the claim is appealed.
45
+ def appealed?
46
+ status == 'appealed'
47
+ end
48
+
49
+ # @return [Boolean] whether the claim is disputed.
50
+ def disputed?
51
+ status == 'disputed'
52
+ end
53
+
54
+ # @return [Boolean] whether the claim is inactive.
55
+ def inactive?
56
+ status == 'inactive'
57
+ end
58
+
59
+ # @return [Boolean] whether the claim is pending.
60
+ def pending?
61
+ status == 'pending'
62
+ end
63
+
64
+ # @return [Boolean] whether the claim is potential.
65
+ def potential?
66
+ status == 'potential'
67
+ end
68
+
69
+ # @return [Boolean] whether the claim is takedown.
70
+ def takedown?
71
+ status == 'takedown'
72
+ end
73
+
74
+ # @return [Boolean] whether the claim status is unknown.
75
+ def has_unknown_status?
76
+ status == 'unknown'
77
+ end
78
+
79
+ # @return [String] whether the claim covers the audio, video, or
80
+ # audiovisual portion of the claimed content. Valid values are: audio,
81
+ # audiovisual, video.
82
+ def content_type
83
+ @content_type ||= @data["contentType"]
84
+ end
85
+
86
+ # @return [Boolean] whether the covers the audio of the content.
87
+ def audio?
88
+ content_type == 'audio'
89
+ end
90
+
91
+ # @return [Boolean] whether the covers the video of the content.
92
+ def video?
93
+ content_type == 'video'
94
+ end
95
+
96
+ # @return [Boolean] whether the covers the audiovisual of the content.
97
+ def audiovisual?
98
+ content_type == 'audiovisual'
99
+ end
100
+
101
+ # @return [Time] the date and time that the claim was created.
102
+ def created_at
103
+ @created_at ||= Time.parse @data["timeCreated"]
104
+ end
105
+
106
+ # Return whether the video should be blocked where not explicitly owned.
107
+ # @return [Boolean] whether the claimed video should be blocked anywhere
108
+ # it is not explicitly owned. For example, if you upload a video for an
109
+ # asset that you own in the United States and Canada, and you claim the
110
+ # video with a usage policy to monetize the video everywhere. Since the
111
+ # policy is only applied in countries where you own the asset, YouTube
112
+ # will actually monetize the video in the United States and Canada.
113
+ # By default, the video will still be viewable in other countries even
114
+ # though it will not be monetized in those countries. However, if you
115
+ # set this property to true, then the video will be monetized in the
116
+ # United States and Canada and blocked in all other countries.
117
+ def block_outside_ownership?
118
+ @block_outside_ownership ||= @data["blockOutsideOwnership"]
119
+ end
120
+ end
121
+ end
122
+ end
@@ -11,6 +11,10 @@ module Yt
11
11
  # @return [Yt::Collection::PartneredChannels] the channels managed by the CMS account.
12
12
  has_many :partnered_channels
13
13
 
14
+ # @!attribute [r] claims
15
+ # @return [Yt::Collection::Claims] the claims administered by the content owner.
16
+ has_many :claims
17
+
14
18
  def initialize(options = {})
15
19
  super options
16
20
  @owner_name = options[:owner_name]
data/lib/yt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.8.1'
2
+ VERSION = '0.8.2'
3
3
  end
data/lib/yt.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'yt/config'
2
2
  require 'yt/models/account'
3
3
  require 'yt/models/channel'
4
+ require 'yt/models/claim'
4
5
  require 'yt/models/content_owner'
5
6
  require 'yt/models/playlist'
6
7
  require 'yt/models/playlist_item'
@@ -0,0 +1,192 @@
1
+ require 'spec_helper'
2
+ require 'yt/models/claim'
3
+
4
+ describe Yt::Claim do
5
+ subject(:claim) { Yt::Claim.new data: data }
6
+
7
+ describe '#id' do
8
+ context 'given fetching a claim returns an id' do
9
+ let(:data) { {"id"=>"aBcD1EfGHIk"} }
10
+ it { expect(claim.id).to eq 'aBcD1EfGHIk' }
11
+ end
12
+ end
13
+
14
+ describe '#asset_id' do
15
+ context 'given fetching a claim returns an assetId' do
16
+ let(:data) { {"assetId"=>"A123456789012601"} }
17
+ it { expect(claim.asset_id).to eq 'A123456789012601' }
18
+ end
19
+ end
20
+
21
+ describe '#video_id' do
22
+ context 'given fetching a claim returns an videoId' do
23
+ let(:data) { {"videoId"=>"MESycYJytkU"} }
24
+ it { expect(claim.video_id).to eq 'MESycYJytkU' }
25
+ end
26
+ end
27
+
28
+ describe '#status' do
29
+ context 'given fetching a claim returns a status' do
30
+ let(:data) { {"status"=>"active"} }
31
+ it { expect(claim.status).to eq 'active' }
32
+ end
33
+ end
34
+
35
+ describe '#active?' do
36
+ context 'given fetching a claim returns an active status' do
37
+ let(:data) { {"status"=>"active"} }
38
+ it { expect(claim).to be_active }
39
+ end
40
+
41
+ context 'given fetching a claim does not return an active status' do
42
+ let(:data) { {"status"=>"unknown"} }
43
+ it { expect(claim).not_to be_active }
44
+ end
45
+ end
46
+
47
+ describe '#appealed?' do
48
+ context 'given fetching a claim returns an appealed status' do
49
+ let(:data) { {"status"=>"appealed"} }
50
+ it { expect(claim).to be_appealed }
51
+ end
52
+
53
+ context 'given fetching a claim does not return an appealed status' do
54
+ let(:data) { {"status"=>"unknown"} }
55
+ it { expect(claim).not_to be_appealed }
56
+ end
57
+ end
58
+
59
+ describe '#disputed?' do
60
+ context 'given fetching a claim returns an disputed status' do
61
+ let(:data) { {"status"=>"disputed"} }
62
+ it { expect(claim).to be_disputed }
63
+ end
64
+
65
+ context 'given fetching a claim does not return an disputed status' do
66
+ let(:data) { {"status"=>"unknown"} }
67
+ it { expect(claim).not_to be_disputed }
68
+ end
69
+ end
70
+
71
+ describe '#inactive?' do
72
+ context 'given fetching a claim returns an inactive status' do
73
+ let(:data) { {"status"=>"inactive"} }
74
+ it { expect(claim).to be_inactive }
75
+ end
76
+
77
+ context 'given fetching a claim does not return an inactive status' do
78
+ let(:data) { {"status"=>"unknown"} }
79
+ it { expect(claim).not_to be_inactive }
80
+ end
81
+ end
82
+
83
+ describe '#pending?' do
84
+ context 'given fetching a claim returns an pending status' do
85
+ let(:data) { {"status"=>"pending"} }
86
+ it { expect(claim).to be_pending }
87
+ end
88
+
89
+ context 'given fetching a claim does not return an pending status' do
90
+ let(:data) { {"status"=>"unknown"} }
91
+ it { expect(claim).not_to be_pending }
92
+ end
93
+ end
94
+
95
+ describe '#potential?' do
96
+ context 'given fetching a claim returns an potential status' do
97
+ let(:data) { {"status"=>"potential"} }
98
+ it { expect(claim).to be_potential }
99
+ end
100
+
101
+ context 'given fetching a claim does not return an potential status' do
102
+ let(:data) { {"status"=>"unknown"} }
103
+ it { expect(claim).not_to be_potential }
104
+ end
105
+ end
106
+
107
+ describe '#takedown?' do
108
+ context 'given fetching a claim returns an takedown status' do
109
+ let(:data) { {"status"=>"takedown"} }
110
+ it { expect(claim).to be_takedown }
111
+ end
112
+
113
+ context 'given fetching a claim does not return an takedown status' do
114
+ let(:data) { {"status"=>"unknown"} }
115
+ it { expect(claim).not_to be_takedown }
116
+ end
117
+ end
118
+
119
+ describe '#has_unknown_status?' do
120
+ context 'given fetching a claim returns an unknown status' do
121
+ let(:data) { {"status"=>"unknown"} }
122
+ it { expect(claim).to have_unknown_status }
123
+ end
124
+
125
+ context 'given fetching a claim does not return an unknown status' do
126
+ let(:data) { {"status"=>"active"} }
127
+ it { expect(claim).not_to have_unknown_status }
128
+ end
129
+ end
130
+
131
+ describe '#content_type' do
132
+ context 'given fetching a claim returns a content type' do
133
+ let(:data) { {"contentType"=>"audio"} }
134
+ it { expect(claim.content_type).to eq 'audio' }
135
+ end
136
+ end
137
+
138
+ describe '#audio?' do
139
+ context 'given fetching a claim returns an audio content type' do
140
+ let(:data) { {"contentType"=>"audio"} }
141
+ it { expect(claim).to be_audio }
142
+ end
143
+
144
+ context 'given fetching a claim does not return an audio content type' do
145
+ let(:data) { {"contentType"=>"audiovisual"} }
146
+ it { expect(claim).not_to be_audio }
147
+ end
148
+ end
149
+
150
+ describe '#video?' do
151
+ context 'given fetching a claim returns an video content type' do
152
+ let(:data) { {"contentType"=>"video"} }
153
+ it { expect(claim).to be_video }
154
+ end
155
+
156
+ context 'given fetching a claim does not return an video content type' do
157
+ let(:data) { {"contentType"=>"audiovisual"} }
158
+ it { expect(claim).not_to be_video }
159
+ end
160
+ end
161
+
162
+ describe '#audiovisual?' do
163
+ context 'given fetching a claim returns an audiovisual content type' do
164
+ let(:data) { {"contentType"=>"audiovisual"} }
165
+ it { expect(claim).to be_audiovisual }
166
+ end
167
+
168
+ context 'given fetching a claim does not return an audiovisual content type' do
169
+ let(:data) { {"contentType"=>"audio"} }
170
+ it { expect(claim).not_to be_audiovisual }
171
+ end
172
+ end
173
+
174
+ describe '#created_at' do
175
+ context 'given fetching a claim returns a creation timestamp' do
176
+ let(:data) { {"timeCreated"=>"2014-04-22T19:14:49.000Z"} }
177
+ it { expect(claim.created_at.year).to be 2014 }
178
+ end
179
+ end
180
+
181
+ describe '#block_outside_ownership?' do
182
+ context 'given fetching a claim returns blockOutsideOwnership true' do
183
+ let(:data) { {"blockOutsideOwnership"=>true} }
184
+ it { expect(claim.block_outside_ownership?).to be true }
185
+ end
186
+
187
+ context 'given fetching a claim returns blockOutsideOwnership false' do
188
+ let(:data) { {"blockOutsideOwnership"=>false} }
189
+ it { expect(claim.block_outside_ownership?).to be false }
190
+ end
191
+ end
192
+ end
@@ -2,7 +2,87 @@ require 'spec_helper'
2
2
  require 'yt/models/content_owner'
3
3
 
4
4
  describe Yt::ContentOwner, :partner do
5
- # NOTE: Uncomment once size does not runs through *all* the pages
6
- # it { expect($content_owner.partnered_channels.size).to be > 0 }
7
- it { expect($content_owner.partnered_channels.first).to be_a Yt::Channel }
5
+ describe '.partnered_channels' do
6
+ # NOTE: Uncomment once size does not runs through *all* the pages
7
+ # it { expect($content_owner.partnered_channels.size).to be > 0 }
8
+ it { expect($content_owner.partnered_channels.first).to be_a Yt::Channel }
9
+ end
10
+
11
+ describe '.claims' do
12
+ it { expect($content_owner.claims.first).to be_a Yt::Claim }
13
+
14
+ describe '.where(id: claim_id)' do
15
+ let(:count) { $content_owner.claims.where(id: claim_id).count }
16
+
17
+ context 'given the ID of a claim administered by the content owner' do
18
+ let(:claim_id) { ENV['YT_TEST_PARTNER_CLAIM_ID'] }
19
+ it { expect(count).to be > 0 }
20
+ end
21
+
22
+ context 'given an unknown claim ID' do
23
+ let(:claim_id) { '--not-a-matching-claim-id--' }
24
+ it { expect(count).to be_zero }
25
+ end
26
+ end
27
+
28
+ describe '.where(asset_id: asset_id)' do
29
+ let(:count) { $content_owner.claims.where(asset_id: asset_id).count }
30
+
31
+ context 'given the asset ID of a claim administered by the content owner' do
32
+ let(:asset_id) { ENV['YT_TEST_PARTNER_ASSET_ID'] }
33
+ it { expect(count).to be > 0 }
34
+ end
35
+
36
+ context 'given an unknown asset ID' do
37
+ let(:asset_id) { 'A123456789012345' }
38
+ it { expect(count).to be_zero }
39
+ end
40
+ end
41
+
42
+ describe '.where(video_id: video_id)' do
43
+ let(:count) { $content_owner.claims.where(video_id: video_id).count }
44
+
45
+ context 'given the video ID of a claim administered by the content owner' do
46
+ let(:video_id) { ENV['YT_TEST_PARTNER_VIDEO_ID'] }
47
+ it { expect(count).to be > 0 }
48
+ end
49
+
50
+ context 'given an unknown video ID' do
51
+ let(:video_id) { '--not-a-matching-video-id--' }
52
+ it { expect(count).to be_zero }
53
+ end
54
+ end
55
+
56
+ describe '.where(q: query)' do
57
+ let(:first) { $content_owner.claims.where(params).first }
58
+
59
+ context 'given a query matching the title of a video of a claim administered by the content owner' do
60
+ let(:query) { ENV['YT_TEST_PARTNER_Q'] }
61
+
62
+ context 'given no optional filters' do
63
+ let(:params) { {q: query} }
64
+ it { expect(first).to be }
65
+ end
66
+
67
+ context 'given an optional filter that does not include that video' do
68
+ let(:remote_date) { '2008-01-01T00:00:00.000Z' }
69
+
70
+ describe 'applies the filter if the filter name is under_scored' do
71
+ let(:params) { {q: query, created_before: remote_date} }
72
+ it { expect(first).not_to be }
73
+ end
74
+
75
+ describe 'applies the filter if the filter name is camelCased' do
76
+ let(:params) { {q: query, createdBefore: remote_date} }
77
+ it { expect(first).not_to be }
78
+ end
79
+ end
80
+ end
81
+
82
+ context 'given an unknown video ID' do
83
+ let(:params) { {q: '--not-a-matching-query--'} }
84
+ it { expect(first).not_to be }
85
+ end
86
+ end
87
+ end
8
88
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-22 00:00:00.000000000 Z
11
+ date: 2014-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -132,6 +132,7 @@ files:
132
132
  - lib/yt/collections/authentications.rb
133
133
  - lib/yt/collections/base.rb
134
134
  - lib/yt/collections/channels.rb
135
+ - lib/yt/collections/claims.rb
135
136
  - lib/yt/collections/content_details.rb
136
137
  - lib/yt/collections/device_flows.rb
137
138
  - lib/yt/collections/ids.rb
@@ -161,6 +162,7 @@ files:
161
162
  - lib/yt/models/authentication.rb
162
163
  - lib/yt/models/base.rb
163
164
  - lib/yt/models/channel.rb
165
+ - lib/yt/models/claim.rb
164
166
  - lib/yt/models/configuration.rb
165
167
  - lib/yt/models/content_detail.rb
166
168
  - lib/yt/models/content_owner.rb
@@ -198,6 +200,7 @@ files:
198
200
  - spec/models/account_spec.rb
199
201
  - spec/models/annotation_spec.rb
200
202
  - spec/models/channel_spec.rb
203
+ - spec/models/claim_spec.rb
201
204
  - spec/models/configuration_spec.rb
202
205
  - spec/models/content_detail_spec.rb
203
206
  - spec/models/description_spec.rb
@@ -277,6 +280,7 @@ test_files:
277
280
  - spec/models/account_spec.rb
278
281
  - spec/models/annotation_spec.rb
279
282
  - spec/models/channel_spec.rb
283
+ - spec/models/claim_spec.rb
280
284
  - spec/models/configuration_spec.rb
281
285
  - spec/models/content_detail_spec.rb
282
286
  - spec/models/description_spec.rb