yt 0.5.9 → 0.5.10

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d97692de42f71338841ff27611f9afb22ab332b1
4
- data.tar.gz: 5377de83540d86ab1d64b4e54ac74b7e0f5b2af1
3
+ metadata.gz: b7f7f8e3686d58c93674547e4aac01644a01d0db
4
+ data.tar.gz: f3739308a1230e14548efe5d68abeb76e66c4422
5
5
  SHA512:
6
- metadata.gz: 180bc01c7f56b32b39445076ab5881bc7d8ff93687c055e50c9e271f3bfc6cb1baf7e67e29dd256a5b53cc08d879bf5743cd7ea5eb36662e22955f78541de606
7
- data.tar.gz: 80b4043b308b060ffac3ec32d55d47040db6f62752049df39f7b92166c8d02c3a8fee1f8c175948c14ceda3bb55ddae94be8ae616570e2f9a74164cd2c1c7dc7
6
+ metadata.gz: 1fb1f949b74acab51e649a863733453dadbce615f5aef848f28ae1c7a25c274cf582d53ac5d3e1d3c7988758cf4561b65d10751607c5cf3dedab43c28dd04e7b
7
+ data.tar.gz: 774e99b48115627b617f5bfbbc57cd66d039db2fefe5b32f83e73ebcb80d1a9874586efcc961114ba758c1cf59ffb42bfc5db00ddaa4c4b3dad48d3d11836b3e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yt (0.5.9)
4
+ yt (0.5.10)
5
5
  activesupport
6
6
 
7
7
  GEM
data/HISTORY.md CHANGED
@@ -15,6 +15,8 @@ v0.5 - 2014/05/16
15
15
  * Rename error classes so they match the corresponding Net::HTTP errors (e.g. Unauthorized)
16
16
  * Separate Error class for 403 Error
17
17
  * Retry once YouTube earning queries that return error 400 "Invalid query. Query did not conform to the expectations"
18
+ * Update RSpec to 3.0 (only required in development/testing)
19
+ * New ContentOwner subclass of Account with access to partnered channels
18
20
 
19
21
  v0.4 - 2014/05/09
20
22
  --------------------
data/README.md CHANGED
@@ -347,7 +347,7 @@ To install on your system, run
347
347
 
348
348
  To use inside a bundled Ruby project, add this line to the Gemfile:
349
349
 
350
- gem 'yt', '~> 0.5.9'
350
+ gem 'yt', '~> 0.5.10'
351
351
 
352
352
  Since the gem follows [Semantic Versioning](http://semver.org),
353
353
  indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
data/lib/yt.rb CHANGED
@@ -1,2 +1,3 @@
1
1
  require 'yt/config'
2
- require 'yt/models/account'
2
+ require 'yt/models/account'
3
+ require 'yt/models/content_owner'
@@ -56,7 +56,7 @@ module Yt
56
56
  end
57
57
 
58
58
  def list_params
59
- path = "/youtube/v3/#{self.class.to_s.demodulize.camelize :lower}"
59
+ path = "/youtube/v3/#{list_resources.to_s.demodulize.camelize :lower}"
60
60
 
61
61
  {}.tap do |params|
62
62
  params[:method] = :get
@@ -69,6 +69,10 @@ module Yt
69
69
  def items_key
70
70
  'items'
71
71
  end
72
+
73
+ def list_resources
74
+ self.class
75
+ end
72
76
  end
73
77
  end
74
78
  end
@@ -16,6 +16,7 @@ module Yt
16
16
  autoload :DetailsSets
17
17
  autoload :Earnings
18
18
  autoload :Ids
19
+ autoload :PartneredChannels
19
20
  autoload :PlaylistItems
20
21
  autoload :Playlists
21
22
  autoload :Ratings
@@ -0,0 +1,14 @@
1
+ require 'yt/collections/partnered_channels'
2
+
3
+ module Yt
4
+ module Associations
5
+ # Provides the `has_many :partnered_channels` method to YouTube resources,
6
+ # which allows to access to partnered channel-specific methods.
7
+ # YouTube resources with a channel are: content owners.
8
+ module PartneredChannels
9
+ def partnered_channels
10
+ @partnered_channels ||= Collections::PartneredChannels.of self
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ require 'yt/collections/channels'
2
+
3
+ module Yt
4
+ module Collections
5
+ class PartneredChannels < Channels
6
+
7
+ private
8
+
9
+ def list_params
10
+ super.tap do |params|
11
+ params[:params].delete :mine
12
+ params[:params][:managedByMe] = true
13
+ params[:params][:onBehalfOfContentOwner] = @parent.owner_name
14
+ end
15
+ end
16
+
17
+ def list_resources
18
+ self.class.superclass
19
+ end
20
+ end
21
+ end
22
+ end
@@ -7,7 +7,6 @@ module Yt
7
7
  has_one :channel, delegate: [:videos, :playlists, :create_playlist, :delete_playlists, :update_playlists]
8
8
  has_one :user_info, delegate: [:id, :email, :has_verified_email?, :gender, :name, :given_name, :family_name, :profile_url, :avatar_url, :locale, :hd]
9
9
  has_one :authentication, delegate: [:access_token, :refresh_token, :expires_at]
10
- attr_reader :owner_name
11
10
 
12
11
  def initialize(options = {})
13
12
  @access_token = options[:access_token]
@@ -16,7 +15,6 @@ module Yt
16
15
  @authorization_code = options[:authorization_code]
17
16
  @redirect_uri = options[:redirect_uri]
18
17
  @scopes = options[:scopes]
19
- @owner_name = options[:owner_name]
20
18
  end
21
19
 
22
20
  def auth
@@ -0,0 +1,16 @@
1
+ require 'yt/models/account'
2
+
3
+ module Yt
4
+ module Models
5
+ # Provides methods to access a YouTube content owner.
6
+ class ContentOwner < Account
7
+ has_many :partnered_channels
8
+ attr_reader :owner_name
9
+
10
+ def initialize(options = {})
11
+ super options
12
+ @owner_name = options[:owner_name]
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.5.9'
2
+ VERSION = '0.5.10'
3
3
  end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Yt::Associations::PartneredChannels, :partner do
4
+ describe '#partnered_channels' do
5
+ let(:partnered_channels) { content_owner.partnered_channels }
6
+
7
+ context 'given a content owner with partnered channels' do
8
+ let(:content_owner) { $content_owner }
9
+
10
+ it { expect(partnered_channels.count).to be > 0 }
11
+ it { expect(partnered_channels.first).to be_a Yt::Channel }
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,6 @@
1
1
  require 'yt/config'
2
2
  require 'yt/models/account'
3
+ require 'yt/models/content_owner'
3
4
 
4
5
  RSpec.configure do |config|
5
6
  # Create one global test account to avoid having to refresh the access token
@@ -39,6 +40,6 @@ RSpec.configure do |config|
39
40
  # Create one Youtube Partner channel, authenticated as the content owner
40
41
  attrs = {refresh_token: ENV['YT_TEST_CONTENT_OWNER_REFRESH_TOKEN']}
41
42
  attrs[:owner_name] = ENV['YT_TEST_CONTENT_OWNER_NAME']
42
- $content_owner = Yt::Account.new attrs
43
+ $content_owner = Yt::ContentOwner.new attrs
43
44
  end
44
45
  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.5.9
4
+ version: 0.5.10
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-06-02 00:00:00.000000000 Z
11
+ date: 2014-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -129,6 +129,7 @@ files:
129
129
  - lib/yt/associations/details_sets.rb
130
130
  - lib/yt/associations/earnings.rb
131
131
  - lib/yt/associations/ids.rb
132
+ - lib/yt/associations/partnered_channels.rb
132
133
  - lib/yt/associations/playlist_items.rb
133
134
  - lib/yt/associations/playlists.rb
134
135
  - lib/yt/associations/ratings.rb
@@ -144,6 +145,7 @@ files:
144
145
  - lib/yt/collections/details_sets.rb
145
146
  - lib/yt/collections/earnings.rb
146
147
  - lib/yt/collections/ids.rb
148
+ - lib/yt/collections/partnered_channels.rb
147
149
  - lib/yt/collections/playlist_items.rb
148
150
  - lib/yt/collections/playlists.rb
149
151
  - lib/yt/collections/ratings.rb
@@ -163,6 +165,7 @@ files:
163
165
  - lib/yt/models/base.rb
164
166
  - lib/yt/models/channel.rb
165
167
  - lib/yt/models/configuration.rb
168
+ - lib/yt/models/content_owner.rb
166
169
  - lib/yt/models/description.rb
167
170
  - lib/yt/models/details_set.rb
168
171
  - lib/yt/models/id.rb
@@ -183,6 +186,7 @@ files:
183
186
  - spec/associations/device_auth/details_sets_spec.rb
184
187
  - spec/associations/device_auth/earnings_spec.rb
185
188
  - spec/associations/device_auth/ids_spec.rb
189
+ - spec/associations/device_auth/partnered_channels_spec.rb
186
190
  - spec/associations/device_auth/playlist_items_spec.rb
187
191
  - spec/associations/device_auth/playlists_spec.rb
188
192
  - spec/associations/device_auth/ratings_spec.rb
@@ -267,6 +271,7 @@ test_files:
267
271
  - spec/associations/device_auth/details_sets_spec.rb
268
272
  - spec/associations/device_auth/earnings_spec.rb
269
273
  - spec/associations/device_auth/ids_spec.rb
274
+ - spec/associations/device_auth/partnered_channels_spec.rb
270
275
  - spec/associations/device_auth/playlist_items_spec.rb
271
276
  - spec/associations/device_auth/playlists_spec.rb
272
277
  - spec/associations/device_auth/ratings_spec.rb