yt 0.20.0 → 0.21.0

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: 5fe27d147e90b10dde52f153efedf061043b9788
4
- data.tar.gz: fb07f986240215dba34f01d78762503471cf61a5
3
+ metadata.gz: a257c84e731d03c889aba6d840ae8945bff703c3
4
+ data.tar.gz: acddd55c13ed4013e4e8acae7c303e864bbd114b
5
5
  SHA512:
6
- metadata.gz: 0c20df4b1ad2ac9420d3bd183e04892f9cffaaefb3989330794ce8004de7f06c8ce6b52260980582f2cc22e5239871c24aa868156d27bd488465184dd8940da3
7
- data.tar.gz: b4ec8a79ced4d3e5535a68daa4ae56f593d70e8bd86d20c0c3ef041ca85c88266b77f2f787a7fe1bf08fd04b61b4738ffc02ab3b93d5cce8699ba60c3c7d701b
6
+ metadata.gz: 0c82294cbdb20eebf4208eacf95c370afa8044121bf20e8b76514979a3a4d981d2e4a46fdf82cb2915f701c983aeba9802d03405203adee27726b24a83d76a86
7
+ data.tar.gz: 469b86367d016835333f6a16c06a7f5463246eb4d5c53155d12e5f8274947ec85115cd891db6cda289f138075f3b05b0b156ba384e31e4d1f62207204bbf4741
@@ -6,6 +6,16 @@ For more information about changelogs, check
6
6
  [Keep a Changelog](http://keepachangelog.com) and
7
7
  [Vandamme](http://tech-angels.github.io/vandamme).
8
8
 
9
+ ## 0.21.0 - 2015-04-30
10
+
11
+ **How to upgrade**
12
+
13
+ If your code doesn’t use `PolicyRule#ACTIONS`, then you are good to go.
14
+ If it does, then you should redefine the constant in your own app.
15
+
16
+ * [REMOVAL] Remove `PolicyRule#ACTIONS` (was `%q(block monetize takedown track)`).
17
+ * [BUGFIX] Make `account.playlists` and `account.channel.playlists` behave the same.
18
+
9
19
  ## 0.20.0 - 2015-04-29
10
20
 
11
21
  **How to upgrade**
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.20.0'
44
+ gem 'yt', '~> 0.21.0'
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*)
@@ -74,7 +74,7 @@ account.channel #=> #<Yt::Models::Channel @id=...>
74
74
  account.videos.count #=> 12
75
75
  account.videos.first #=> #<Yt::Models::Video @id=...>
76
76
 
77
- account.upload_video 'my_video.mp4', title: 'My new video', privacy_status: 'private', category_id: 17
77
+ account.upload_video 'my_video.mp4', title: 'My new video', privacy_status: 'private', category_id: '17'
78
78
  account.upload_video 'http://example.com/remote.m4v', title: 'My other video', tags: ['music']
79
79
 
80
80
  account.create_playlist title: 'New playlist', privacy_status: 'unlisted' #=> true
@@ -370,7 +370,7 @@ client = # new client initialized with either OAuth or AuthSub
370
370
  client.video_upload(File.open("test.mov"), :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test])
371
371
  # with yt
372
372
  account = Yt::Account.new access_token: 'access_token'
373
- account.upload_video 'test.mov', title: 'test', description: 'some description', category_id: 22, tags: %w(cool blah test)
373
+ account.upload_video 'test.mov', title: 'test', description: 'some description', category_id: '22', tags: %w(cool blah test)
374
374
  ```
375
375
 
376
376
  Upload remote video:
@@ -381,7 +381,7 @@ client = # new client initialized with either OAuth or AuthSub
381
381
  client.video_upload("http://url/myvideo.mp4", :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test])
382
382
  # with yt
383
383
  account = Yt::Account.new access_token: 'access_token'
384
- account.upload_video 'http://url/myvideo.mp4', title: 'test', description: 'some description', category_id: 22, tags: %w(cool blah test)
384
+ account.upload_video 'http://url/myvideo.mp4', title: 'test', description: 'some description', category_id: '22', tags: %w(cool blah test)
385
385
  ```
386
386
 
387
387
  Upload video with a developer tag:
@@ -401,7 +401,7 @@ client = # new client initialized with either OAuth or AuthSub
401
401
  client.video_upload("http://media.railscasts.com/assets/episodes/videos/412-fast-rails-commands.mp4", :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test])
402
402
  # with yt
403
403
  account = Yt::Account.new access_token: 'access_token'
404
- account.upload_video 'http://media.railscasts.com/assets/episodes/videos/412-fast-rails-commands.mp4', title: 'test', description: 'some description', category_id: 22, tags: %w(cool blah test)
404
+ account.upload_video 'http://media.railscasts.com/assets/episodes/videos/412-fast-rails-commands.mp4', title: 'test', description: 'some description', category_id: '22', tags: %w(cool blah test)
405
405
  ```
406
406
 
407
407
  Upload private video:
@@ -412,7 +412,7 @@ client = # new client initialized with either OAuth or AuthSub
412
412
  client.video_upload(File.open("test.mov"), :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test], :private => true)
413
413
  # with yt
414
414
  account = Yt::Account.new access_token: 'access_token'
415
- account.upload_video 'test.mov', privacy_status: :private, title: 'test', description: 'some description', category_id: 22, tags: %w(cool blah test)
415
+ account.upload_video 'test.mov', privacy_status: :private, title: 'test', description: 'some description', category_id: '22', tags: %w(cool blah test)
416
416
  ```
417
417
 
418
418
  Update video:
@@ -6,47 +6,60 @@ module Yt
6
6
  # Provides methods to interact with YouTube accounts.
7
7
  # @see https://developers.google.com/youtube/v3/guides/authentication
8
8
  class Account < Base
9
- # @!attribute [r] channel
10
- # @return [Yt::Models::Channel] the account’s channel.
11
- has_one :channel
12
- delegate :playlists, :delete_playlists,
13
- :subscribed_channels, to: :channel
14
9
 
15
- # @!attribute [r] user_info
16
- # @return [Yt::Models::UserInfo] the account’s profile information.
10
+ ### USER INFO ###
11
+
17
12
  has_one :user_info
18
- delegate :id, :email, :has_verified_email?, :gender, :name, :given_name,
19
- :family_name, :profile_url, :avatar_url, :locale, :hd, to: :user_info
20
13
 
21
- # @!attribute [r] videos
22
- # @return [Yt::Collections::Videos] the videos owned by the account.
23
- has_many :videos
14
+ # @!attribute [r] id
15
+ # @return [String] the (Google+) account’s ID.
16
+ delegate :id, to: :user_info
24
17
 
25
- # @!attribute [r] subscribers
26
- # @return [Yt::Collections::Subscribers] the channels subscribed to the account.
27
- has_many :subscribers
18
+ # @!attribute [r] email
19
+ # @return [String] the account’s email address.
20
+ delegate :email, to: :user_info
28
21
 
29
- # @return [String] name of the CMS account, if the account is partnered.
30
- # @return [nil] if the account is not a partnered content owner.
31
- attr_reader :owner_name
22
+ # @return [Boolean] whether the email address is verified.
23
+ def has_verified_email?
24
+ user_info.verified_email
25
+ end
32
26
 
33
- has_authentication
27
+ # @!attribute [r] name
28
+ # @return [String] the account’s full name.
29
+ delegate :name, to: :user_info
34
30
 
35
- # @!attribute [r] resumable_sessions
36
- # @return [Yt::Collections::ResumableSessions] the sessions used to
37
- # upload videos using the resumable upload protocol.
38
- has_many :resumable_sessions
31
+ # @!attribute [r] given_name
32
+ # @return [String] the user’s given (first) name.
33
+ delegate :given_name, to: :user_info
39
34
 
40
- # @!attribute [r] content_owners
41
- # @return [Yt::Collections::ContentOwners] the content_owners accessible
42
- # by the account.
43
- has_many :content_owners
35
+ # @!attribute [r] family_name
36
+ # @return [String] the user’s family (last) name.
37
+ delegate :family_name, to: :user_info
44
38
 
45
- # @!attribute [r] playlists
46
- # @return [Yt::Collections::Playlists] the account’s playlists.
47
- has_many :playlists
39
+ # @return [String] the URL of the account’s (Google +) profile page.
40
+ def profile_url
41
+ user_info.link
42
+ end
43
+
44
+ # @return [String] the URL of the account’s (Google +) profile picture.
45
+ def avatar_url
46
+ user_info.picture
47
+ end
48
+
49
+ # @return [String] the account’s gender. Possible values include, but
50
+ # are not limited to, +'male'+, +'female'+, +'other'+.
51
+ delegate :gender, to: :user_info
48
52
 
49
- # Uploads a video using resumable sessions
53
+ # @return [String] the account’s preferred locale.
54
+ delegate :locale, to: :user_info
55
+
56
+ # @return [String] the hosted domain name for the user’s Google Apps
57
+ # account. For instance, example.com.
58
+ delegate :hd, to: :user_info
59
+
60
+ ### ACTIONS ###
61
+
62
+ # Uploads a video to the account’s channel.
50
63
  # @param [String] path_or_url the video to upload. Can either be the
51
64
  # path of a local file or the URL of a remote file.
52
65
  # @param [Hash] params the metadata to add to the uploaded video.
@@ -64,10 +77,94 @@ module Yt
64
77
  end
65
78
  end
66
79
 
80
+ # Creates a playlist in the account’s channel.
81
+ # @return [Yt::Models::Playlist] the newly created playlist.
82
+ # @param [Hash] params the attributes of the playlist.
83
+ # @option params [String] :title The new playlist’s title.
84
+ # Cannot have more than 100 characters. Can include the characters
85
+ # < and >, which are replaced to ‹ › in order to be accepted by YouTube.
86
+ # @option params [String] :description The new playlist’s description.
87
+ # Cannot have more than 5000 bytes. Can include the characters
88
+ # < and >, which are replaced to ‹ › in order to be accepted by YouTube.
89
+ # @option params [Array<String>] :tags The new playlist’s tags.
90
+ # Cannot have more than 500 characters. Can include the characters
91
+ # < and >, which are replaced to ‹ › in order to be accepted by YouTube.
92
+ # @option params [String] :privacy_status The new playlist’s privacy
93
+ # status. Must be one of: private, unscheduled, public.
94
+ # @example Create a playlist titled "My favorites".
95
+ # account.create_playlist title: 'My favorites'
67
96
  def create_playlist(params = {})
68
97
  playlists.insert params
69
98
  end
70
99
 
100
+ # Deletes the account’s playlists matching all the given attributes.
101
+ # @return [Array<Boolean>] whether each playlist matching the given
102
+ # attributes was deleted.
103
+ # @param [Hash] attributes the attributes to match the playlists by.
104
+ # @option attributes [<String, Regexp>] :title The playlist’s title.
105
+ # Pass a String for perfect match or a Regexp for advanced match.
106
+ # @option attributes [<String, Regexp>] :description The playlist’s
107
+ # description. Pass a String (perfect match) or a Regexp (advanced).
108
+ # @option attributes [Array<String>] :tags The playlist’s tags.
109
+ # All tags must match exactly.
110
+ # @option attributes [String] :privacy_status The playlist’s privacy
111
+ # status.
112
+ delegate :delete_playlists, to: :channel
113
+
114
+ ### CONTENT OWNERS ###
115
+
116
+ # @!attribute [r] content_owners
117
+ # @return [Yt::Collections::ContentOwners] the content owners that
118
+ # the account can manage.
119
+ has_many :content_owners
120
+
121
+ # @return [String] name of the CMS account, if the account is partnered.
122
+ # @return [nil] if the account is not a partnered content owner.
123
+ attr_reader :owner_name
124
+
125
+ ### ASSOCIATIONS ###
126
+
127
+ # @!attribute [r] channel
128
+ # @return [Yt::Model::Channel] the YouTube channel of the account.
129
+ has_one :channel
130
+
131
+ # @!attribute [r] playlists
132
+ # @return [Yt::Collections::Playlists] the playlists owned by the account.
133
+ delegate :playlists, to: :channel
134
+
135
+ # @!attribute [r] subscribed_channels
136
+ # @return [Yt::Collections::SubscribedChannels] the channels that the
137
+ # account is subscribed to.
138
+ delegate :subscribed_channels, to: :channel
139
+
140
+ # @!attribute [r] videos
141
+ # @return [Yt::Collections::Videos] the videos owned by the account.
142
+ has_many :videos
143
+
144
+ # @!attribute [r] subscribers
145
+ # @return [Yt::Collections::Subscribers] the channels subscribed to
146
+ # the account’s channel.
147
+ has_many :subscribers
148
+
149
+ # @private
150
+ # @!attribute [r] resumable_sessions
151
+ # @return [Yt::Collections::ResumableSessions] the sessions used to
152
+ # upload videos using the resumable upload protocol.
153
+ has_many :resumable_sessions
154
+
155
+ ### PRIVATE API ###
156
+
157
+ has_authentication
158
+
159
+ # @private
160
+ # Initialize user info if included in the response
161
+ def initialize(options = {})
162
+ super options
163
+ if options[:user_info]
164
+ @user_info = UserInfo.new data: options[:user_info]
165
+ end
166
+ end
167
+
71
168
  # @private
72
169
  # Tells `has_many :videos` that account.videos should return all the
73
170
  # videos *owned by* the account (public, private, unlisted).
@@ -52,6 +52,30 @@ module Yt
52
52
  !exists?
53
53
  end
54
54
 
55
+ # Updates the attributes of a playlist.
56
+ # @return [Boolean] whether the playlist was successfully updated.
57
+ # @raise [Yt::Errors::Unauthorized] if {Resource#auth auth} is not an
58
+ # authenticated Yt::Account with permissions to update the playlist.
59
+ # @param [Hash] attributes the attributes to update.
60
+ # @option attributes [String] :title The new playlist’s title.
61
+ # Cannot have more than 100 characters. Can include the characters
62
+ # < and >, which are replaced to ‹ › in order to be accepted by YouTube.
63
+ # @option attributes [String] :description The new playlist’s description.
64
+ # Cannot have more than 5000 bytes. Can include the characters
65
+ # < and >, which are replaced to ‹ › in order to be accepted by YouTube.
66
+ # @option attributes [Array<String>] :tags The new playlist’s tags.
67
+ # Cannot have more than 500 characters. Can include the characters
68
+ # < and >, which are replaced to ‹ › in order to be accepted by YouTube.
69
+ # @option attributes [String] :privacy_status The new playlist’s privacy
70
+ # status. Must be one of: private, unscheduled, public.
71
+ # @example Update title and description of a playlist.
72
+ # playlist.update title: 'New title', description: 'New description'
73
+ # @example Update tags and status of a playlist.
74
+ # playlist.update tags: ['new', 'tags'], privacy_status: 'public'
75
+ def update(attributes = {})
76
+ super
77
+ end
78
+
55
79
  # Adds a video to the playlist.
56
80
  # Unlike {#add_video!}, does not raise an error if video can’t be added.
57
81
  # @param [String] video_id the video to add to the playlist.
@@ -63,6 +63,17 @@ module Yt
63
63
  !exists?
64
64
  end
65
65
 
66
+ # Updates the attributes of a playlist item.
67
+ # @return [Boolean] whether the item was successfully updated.
68
+ # @raise [Yt::Errors::Unauthorized] if {Resource#auth auth} is not an
69
+ # authenticated Yt::Account with permissions to update the item.
70
+ # @param [Hash] attributes the attributes to update.
71
+ # @option attributes [Integer] the order in which the item should appear
72
+ # in a playlist. The value is zero-based, so the first position of 0.
73
+ def update(attributes = {})
74
+ super
75
+ end
76
+
66
77
  ### ASSOCIATIONS ###
67
78
 
68
79
  # @return [Yt::Models::Video] the video referred by the item.
@@ -11,8 +11,6 @@ module Yt
11
11
  @data = options[:data]
12
12
  end
13
13
 
14
- ACTIONS = %q(block monetize takedown track)
15
-
16
14
  # Return the policy that YouTube should enforce if the rule’s conditions
17
15
  # are all valid for an asset or for an attempt to view that asset on
18
16
  # YouTube. Possible values are: +'block'+, +'monetize'+, +'takedown'+,
@@ -38,8 +38,6 @@ module Yt
38
38
  end
39
39
 
40
40
  has_one :snippet
41
- delegate :title, :description, :thumbnail_url, :published_at,
42
- to: :snippet
43
41
 
44
42
  def initialize(options = {})
45
43
  @url = URL.new(options[:url]) if options[:url]
@@ -2,7 +2,7 @@ require 'yt/models/description'
2
2
 
3
3
  module Yt
4
4
  module Models
5
- # Provides methods to interact with the snippet YouTube resources.
5
+ # Provides methods to interact with the snippet of YouTube resources.
6
6
  # @see https://developers.google.com/youtube/v3/docs/channels#resource
7
7
  # @see https://developers.google.com/youtube/v3/docs/videos#resource
8
8
  # @see https://developers.google.com/youtube/v3/docs/playlists#resource
@@ -18,8 +18,6 @@ module Yt
18
18
  @data = options[:data]
19
19
  end
20
20
 
21
- # Privacy status
22
-
23
21
  has_attribute :privacy_status
24
22
  has_attribute :upload_status
25
23
  has_attribute :failure_reason
@@ -9,40 +9,17 @@ module Yt
9
9
  @data = options[:data]
10
10
  end
11
11
 
12
- # @return [String] the user’s ID.
13
12
  has_attribute :id, default: ''
14
-
15
- # @return [String] the user’s email address.
16
13
  has_attribute :email, default: ''
17
-
18
- # @return [Boolean] whether the email address is verified.
19
- has_attribute :has_verified_email?, from: :verified_email, default: false, camelize: false
20
-
21
- # @return [String] the user's full name.
14
+ has_attribute :verified_email, default: false, camelize: false
22
15
  has_attribute :name, default: ''
23
-
24
- # @return [String] the user’s given (first) name.
25
16
  has_attribute :given_name, default: '', camelize: false
26
-
27
- # @return [String] the user’s family (last) name.
28
17
  has_attribute :family_name, default: '', camelize: false
29
-
30
- # @return [String] the URL of the user’s profile page.
31
- has_attribute :profile_url, from: :link, default: ''
32
-
33
- # @return [String] the URL of the user’s profile picture.
34
- has_attribute :avatar_url, from: :picture, default: ''
35
-
36
- # @return [String] the person’s gender. Possible values include, but
37
- # are not limited to, +'male'+, +'female'+, +'other'+.
18
+ has_attribute :link, default: ''
19
+ has_attribute :picture, default: ''
38
20
  has_attribute :gender, default: ''
39
-
40
- # @return [String] the user’s preferred locale.
41
21
  has_attribute :locale, default: ''
42
-
43
- # @return [String] the hosted domain name for the user’s Google Apps
44
- # account. For instance, example.com.
45
22
  has_attribute :hd, default: ''
46
23
  end
47
24
  end
48
- end
25
+ end
@@ -312,7 +312,6 @@ module Yt
312
312
  video_category.title
313
313
  end
314
314
 
315
-
316
315
  ### ADVERTISING OPTIONS ###
317
316
 
318
317
  has_one :advertising_options_set
@@ -324,7 +323,6 @@ module Yt
324
323
  # +'trueview_instream'+.
325
324
  delegate :ad_formats, to: :advertising_options_set
326
325
 
327
-
328
326
  ### LIVE STREAMING DETAILS ###
329
327
 
330
328
  has_one :live_streaming_detail
@@ -370,6 +368,8 @@ module Yt
370
368
  # @return [Yt::Collections::Annotations] the video’s annotations.
371
369
  has_many :annotations
372
370
 
371
+ has_many :resumable_sessions
372
+
373
373
  ### ANALYTICS ###
374
374
 
375
375
  # @macro report_by_video_dimensions
@@ -468,8 +468,6 @@ module Yt
468
468
 
469
469
  ### ACTIONS (UPLOAD, UPDATE, DELETE) ###
470
470
 
471
- has_many :resumable_sessions
472
-
473
471
  # Uploads a thumbnail
474
472
  # @param [String] path_or_url the image to upload. Can either be the
475
473
  # path of a local file or the URL of a remote file.
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.20.0'
2
+ VERSION = '0.21.0'
3
3
  end
@@ -0,0 +1,138 @@
1
+ require 'spec_helper'
2
+ require 'yt/models/account'
3
+
4
+ describe Yt::Video do
5
+ subject(:account) { Yt::Account.new attrs }
6
+
7
+ describe '#id' do
8
+ context 'given a user info with an ID' do
9
+ let(:attrs) { {user_info: {"id"=>"103024385"}} }
10
+ it { expect(account.id).to eq '103024385' }
11
+ end
12
+
13
+ context 'given a user info without an ID' do
14
+ let(:attrs) { {user_info: {}} }
15
+ it { expect(account.id).to eq '' }
16
+ end
17
+ end
18
+
19
+ describe '#email' do
20
+ context 'given a user info with an email' do
21
+ let(:attrs) { {user_info: {"email"=>"user@example.com"}} }
22
+ it { expect(account.email).to eq 'user@example.com' }
23
+ end
24
+
25
+ context 'given a user info without an email' do
26
+ let(:attrs) { {user_info: {}} }
27
+ it { expect(account.email).to eq '' }
28
+ end
29
+ end
30
+
31
+ describe '#has_verified_email?' do
32
+ context 'given a user info with a verified email' do
33
+ let(:attrs) { {user_info: {"verified_email"=>true}} }
34
+ it { expect(account).to have_verified_email }
35
+ end
36
+
37
+ context 'given a user info without a verified email' do
38
+ let(:attrs) { {user_info: {"verified_email"=>false}} }
39
+ it { expect(account).not_to have_verified_email }
40
+ end
41
+ end
42
+
43
+ describe '#name' do
44
+ context 'given a user info with a name' do
45
+ let(:attrs) { {user_info: {"name"=>"User Example"}} }
46
+ it { expect(account.name).to eq 'User Example' }
47
+ end
48
+
49
+ context 'given a user info without a name' do
50
+ let(:attrs) { {user_info: {}} }
51
+ it { expect(account.name).to eq '' }
52
+ end
53
+ end
54
+
55
+ describe '#given_name' do
56
+ context 'given a user info with a given name' do
57
+ let(:attrs) { {user_info: {"given_name"=>"User"}} }
58
+ it { expect(account.given_name).to eq 'User' }
59
+ end
60
+
61
+ context 'given a user info without a given name' do
62
+ let(:attrs) { {user_info: {}} }
63
+ it { expect(account.given_name).to eq '' }
64
+ end
65
+ end
66
+
67
+ describe '#family_name' do
68
+ context 'given a user info with a family name' do
69
+ let(:attrs) { {user_info: {"family_name"=>"Example"}} }
70
+ it { expect(account.family_name).to eq 'Example' }
71
+ end
72
+
73
+ context 'given a user info without a family name' do
74
+ let(:attrs) { {user_info: {}} }
75
+ it { expect(account.family_name).to eq '' }
76
+ end
77
+ end
78
+
79
+ describe '#profile_url' do
80
+ context 'given a user info with a link' do
81
+ let(:attrs) { {user_info: {"link"=>"https://plus.google.com/1234"}} }
82
+ it { expect(account.profile_url).to eq 'https://plus.google.com/1234' }
83
+ end
84
+
85
+ context 'given a user info without a link' do
86
+ let(:attrs) { {user_info: {}} }
87
+ it { expect(account.profile_url).to eq '' }
88
+ end
89
+ end
90
+
91
+ describe '#avatar_url' do
92
+ context 'given a user info with a picture' do
93
+ let(:attrs) { {user_info: {"picture"=>"https://lh3.googleusercontent.com/photo.jpg"}} }
94
+ it { expect(account.avatar_url).to eq 'https://lh3.googleusercontent.com/photo.jpg' }
95
+ end
96
+
97
+ context 'given a user info without a picture' do
98
+ let(:attrs) { {user_info: {}} }
99
+ it { expect(account.avatar_url).to eq '' }
100
+ end
101
+ end
102
+
103
+ describe '#gender' do
104
+ context 'given a user info with a gender' do
105
+ let(:attrs) { {user_info: {"gender"=>"male"}} }
106
+ it { expect(account.gender).to eq 'male' }
107
+ end
108
+
109
+ context 'given a user info without a gender' do
110
+ let(:attrs) { {user_info: {}} }
111
+ it { expect(account.gender).to eq '' }
112
+ end
113
+ end
114
+
115
+ describe '#locale' do
116
+ context 'given a user info with a locale' do
117
+ let(:attrs) { {user_info: {"locale"=>"en"}} }
118
+ it { expect(account.locale).to eq 'en' }
119
+ end
120
+
121
+ context 'given a user info without a locale' do
122
+ let(:attrs) { {user_info: {}} }
123
+ it { expect(account.locale).to eq '' }
124
+ end
125
+ end
126
+
127
+ describe '#hd' do
128
+ context 'given a user info with a Google App domain' do
129
+ let(:attrs) { {user_info: {"hd"=>"example.com"}} }
130
+ it { expect(account.hd).to eq 'example.com' }
131
+ end
132
+
133
+ context 'given a user info without a Google App domain' do
134
+ let(:attrs) { {user_info: {}} }
135
+ it { expect(account.hd).to eq '' }
136
+ end
137
+ end
138
+ end
@@ -10,13 +10,10 @@ describe Yt::Account, :device_app do
10
10
  after { @playlist.delete }
11
11
  end
12
12
 
13
- describe '.channel' do
14
- it { expect($account.channel).to be_a Yt::Channel }
15
- end
16
-
17
- describe '.user_info' do
18
- it { expect($account.user_info).to be_a Yt::UserInfo }
19
- end
13
+ it { expect($account.channel).to be_a Yt::Channel }
14
+ it { expect($account.playlists.first).to be_a Yt::Playlist }
15
+ it { expect($account.subscribed_channels.first).to be_a Yt::Channel }
16
+ it { expect($account.user_info).to be_a Yt::UserInfo }
20
17
 
21
18
  describe '.videos' do
22
19
  let(:video) { $account.videos.where(order: 'viewCount').first }
@@ -210,7 +210,7 @@ describe Yt::ContentOwner, :partner do
210
210
  expect(policy.id).to be_a String
211
211
  expect(policy.name).to be_a String
212
212
  expect(policy.updated_at).to be_a Time
213
- expect(rule.action).to be_in Yt::PolicyRule::ACTIONS
213
+ expect(rule.action).to be_a String
214
214
  expect(rule.included_territories).to be_an Array
215
215
  expect(rule.excluded_territories).to be_an Array
216
216
  expect(rule.match_duration).to be_an Array
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.20.0
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-29 00:00:00.000000000 Z
11
+ date: 2015-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -259,7 +259,6 @@ files:
259
259
  - spec/models/status_spec.rb
260
260
  - spec/models/subscription_spec.rb
261
261
  - spec/models/url_spec.rb
262
- - spec/models/user_info_spec.rb
263
262
  - spec/models/video_category_spec.rb
264
263
  - spec/models/video_spec.rb
265
264
  - spec/requests/as_account/account_spec.rb
@@ -362,7 +361,6 @@ test_files:
362
361
  - spec/models/status_spec.rb
363
362
  - spec/models/subscription_spec.rb
364
363
  - spec/models/url_spec.rb
365
- - spec/models/user_info_spec.rb
366
364
  - spec/models/video_category_spec.rb
367
365
  - spec/models/video_spec.rb
368
366
  - spec/requests/as_account/account_spec.rb
@@ -1,69 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/user_info'
3
- require 'yt/models/account'
4
-
5
- describe Yt::UserInfo do
6
- describe 'given fetching a user info returns' do
7
- subject(:user_info) { Yt::UserInfo.new data: data }
8
-
9
- context 'an id' do
10
- let(:data) { {"id"=>"103024385"} }
11
- it { expect(user_info.id).to eq '103024385' }
12
- end
13
-
14
- context 'an email' do
15
- let(:data) { {"email"=>"user@example.com"} }
16
- it { expect(user_info.email).to eq 'user@example.com' }
17
- end
18
-
19
- context 'a verified email field set to true' do
20
- let(:data) { {"verified_email"=>true} }
21
- it { expect(user_info).to have_verified_email }
22
- end
23
-
24
- context 'a verified email field set to false' do
25
- let(:data) { {"verified_email"=>false} }
26
- it { expect(user_info).not_to have_verified_email }
27
- end
28
-
29
- context 'a name' do
30
- let(:data) { {"name"=>"User Example"} }
31
- it { expect(user_info.name).to eq 'User Example'}
32
- end
33
-
34
- context 'a given name' do
35
- let(:data) { {"given_name"=>"User"} }
36
- it { expect(user_info.given_name).to eq 'User' }
37
- end
38
-
39
- context 'a family name' do
40
- let(:data) { {"family_name"=>"Example"} }
41
- it { expect(user_info.family_name).to eq 'Example' }
42
- end
43
-
44
- context 'a link' do
45
- let(:data) { {"link"=>"https://plus.google.com/1234"} }
46
- it { expect(user_info.profile_url).to eq 'https://plus.google.com/1234' }
47
- end
48
-
49
- context 'a picture' do
50
- let(:data) { {"picture"=>"https://lh3.googleusercontent.com/photo.jpg"} }
51
- it { expect(user_info.avatar_url).to eq 'https://lh3.googleusercontent.com/photo.jpg' }
52
- end
53
-
54
- context 'a gender' do
55
- let(:data) { {"gender"=>"male"} }
56
- it { expect(user_info.gender).to eq 'male' }
57
- end
58
-
59
- context 'a locale' do
60
- let(:data) { {"locale"=>"en"} }
61
- it { expect(user_info.locale).to eq 'en' }
62
- end
63
-
64
- context 'a Google App domain' do
65
- let(:data) { {"hd"=>"example.com"} }
66
- it { expect(user_info.hd).to eq 'example.com' }
67
- end
68
- end
69
- end