yt 0.4.9 → 0.4.10

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: f25c54b1f1004f4f077834c4363e122ddc0fe605
4
- data.tar.gz: dac600c6f7846186cd83993a857de02c750946ad
3
+ metadata.gz: b768b3bf2f8df33d6464c3e5576d216eb56a40b6
4
+ data.tar.gz: 5d9157b38126cdae31aed2bd15192978a1656339
5
5
  SHA512:
6
- metadata.gz: f2d6a9d99f716a34d3ec647ccb1ef117fa7cfdabbea3aa4fe28c379c72a1f607bbf12f230ebd07ea85abec14a54554ad0ef13b80b49572a66b262f53a6748de6
7
- data.tar.gz: c9cdf87a2f003dca6d3b99e66d57bff636ce64aec589a27263ddd7d8838118462083b0e45af8291bf2601c9b504d82877c9e367e333034b032cc20097f70ac50
6
+ metadata.gz: 536cbae00ed870974c980366668f9a87f0bc7c8e0f8d1cf506fe077b307a5fb1fcb1d49486e7d444f40af1fff1d86c30719c22934a338cc8fb45891c213193ba
7
+ data.tar.gz: f8df59e9464f5f771266136789fa73bd2faa6649422a183aaba54e4987b1ca12b1fe5fa79daaeb5b8af3bbb360691292269c90814caaddb09afd3a52db665a53
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yt (0.4.9)
4
+ yt (0.4.10)
5
5
  activesupport
6
6
 
7
7
  GEM
data/HISTORY.md CHANGED
@@ -8,6 +8,7 @@ v0.4 - 2014/05/09
8
8
  * Fix delegating tags from resources to snippets
9
9
  * Two options to add videos to a playlist: fail or not if a video is missing or its account terminated
10
10
  * Allow to configure Yt credentials through environment variables
11
+ * When updating a playlist, only changes the specified attributes
11
12
 
12
13
  v0.3.0 - 2014/04/16
13
14
  --------------------
data/README.md CHANGED
@@ -302,7 +302,7 @@ To install on your system, run
302
302
 
303
303
  To use inside a bundled Ruby project, add this line to the Gemfile:
304
304
 
305
- gem 'yt', '~> 0.4.9'
305
+ gem 'yt', '~> 0.4.10'
306
306
 
307
307
  Since the gem follows [Semantic Versioning](http://semver.org),
308
308
  indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
@@ -53,9 +53,12 @@ module Yt
53
53
  end
54
54
 
55
55
  def list_params
56
+ path = "/youtube/v3/#{self.class.to_s.demodulize.camelize :lower}"
57
+
56
58
  Request.default_params.tap do |params|
57
59
  params[:method] = :get
58
60
  params[:auth] = @auth
61
+ params[:path] = path
59
62
  end
60
63
  end
61
64
  end
@@ -1,9 +1,9 @@
1
- require 'yt/collections/resources'
1
+ require 'yt/collections/base'
2
2
  require 'yt/models/annotation'
3
3
 
4
4
  module Yt
5
5
  module Collections
6
- class Annotations < Resources
6
+ class Annotations < Base
7
7
 
8
8
  private
9
9
 
@@ -8,6 +8,15 @@ module Yt
8
8
  include Actions::DeleteAll
9
9
  include Actions::Insert
10
10
  include Actions::List
11
+
12
+ def initialize(options = {})
13
+ @parent = options[:parent]
14
+ @auth = options[:auth]
15
+ end
16
+
17
+ def self.of(parent)
18
+ new parent: parent, auth: parent.auth
19
+ end
11
20
  end
12
21
  end
13
22
  end
@@ -1,9 +1,9 @@
1
- require 'yt/collections/resources'
1
+ require 'yt/collections/base'
2
2
  require 'yt/models/channel'
3
3
 
4
4
  module Yt
5
5
  module Collections
6
- class Channels < Resources
6
+ class Channels < Base
7
7
 
8
8
  private
9
9
 
@@ -14,8 +14,6 @@ module Yt
14
14
  def list_params
15
15
  super.tap do |params|
16
16
  params[:params] = {maxResults: 50, part: 'snippet', mine: true}
17
- params[:scope] = 'https://www.googleapis.com/auth/youtube'
18
- params[:path] = '/youtube/v3/channels'
19
17
  end
20
18
  end
21
19
  end
@@ -1,9 +1,9 @@
1
- require 'yt/collections/resources'
1
+ require 'yt/collections/base'
2
2
  require 'yt/models/details_set'
3
3
 
4
4
  module Yt
5
5
  module Collections
6
- class DetailsSets < Resources
6
+ class DetailsSets < Base
7
7
 
8
8
  private
9
9
 
@@ -1,9 +1,9 @@
1
- require 'yt/collections/resources'
1
+ require 'yt/collections/base'
2
2
  require 'yt/models/playlist_item'
3
3
 
4
4
  module Yt
5
5
  module Collections
6
- class PlaylistItems < Resources
6
+ class PlaylistItems < Base
7
7
 
8
8
  # attrs are id and kind
9
9
  def insert(attrs = {}, options = {}) #
@@ -29,7 +29,6 @@ module Yt
29
29
  super.tap do |params|
30
30
  params[:params] = {maxResults: 50, part: 'snippet,status', playlistId: @parent.id}
31
31
  params[:scope] = 'https://www.googleapis.com/auth/youtube.readonly'
32
- params[:path] = '/youtube/v3/playlistItems'
33
32
  end
34
33
  end
35
34
 
@@ -1,9 +1,9 @@
1
- require 'yt/collections/resources'
1
+ require 'yt/collections/base'
2
2
  require 'yt/models/playlist'
3
3
 
4
4
  module Yt
5
5
  module Collections
6
- class Playlists < Resources
6
+ class Playlists < Base
7
7
 
8
8
  # Valid body (no defaults) are: title (string), description (string), privacy_status (string),
9
9
  # tags (array of strings)
@@ -33,7 +33,6 @@ module Yt
33
33
  super.tap do |params|
34
34
  params[:params] = {maxResults: 50, part: 'snippet,status', channelId: @parent.id}
35
35
  params[:scope] = 'https://www.googleapis.com/auth/youtube.readonly'
36
- params[:path] = '/youtube/v3/playlists'
37
36
  end
38
37
  end
39
38
 
@@ -1,9 +1,9 @@
1
- require 'yt/collections/resources'
1
+ require 'yt/collections/base'
2
2
  require 'yt/models/rating'
3
3
 
4
4
  module Yt
5
5
  module Collections
6
- class Ratings < Resources
6
+ class Ratings < Base
7
7
 
8
8
  private
9
9
 
@@ -15,7 +15,6 @@ module Yt
15
15
  super.tap do |params|
16
16
  params[:path] = '/youtube/v3/videos/getRating'
17
17
  params[:params] = {id: @parent.id}
18
- params[:scope] = 'https://www.googleapis.com/auth/youtube'
19
18
  end
20
19
  end
21
20
  end
@@ -1,9 +1,9 @@
1
- require 'yt/collections/resources'
1
+ require 'yt/collections/base'
2
2
  require 'yt/models/snippet'
3
3
 
4
4
  module Yt
5
5
  module Collections
6
- class Snippets < Resources
6
+ class Snippets < Base
7
7
 
8
8
  private
9
9
 
@@ -3,7 +3,7 @@ require 'yt/models/subscription'
3
3
 
4
4
  module Yt
5
5
  module Collections
6
- class Subscriptions < Resources
6
+ class Subscriptions < Base
7
7
 
8
8
  def insert(options = {})
9
9
  throttle
@@ -43,8 +43,6 @@ module Yt
43
43
  def list_params
44
44
  super.tap do |params|
45
45
  params[:params] = {maxResults: 50, forChannelId: @parent.id, mine: true, part: 'snippet'}
46
- params[:scope] = 'https://www.googleapis.com/auth/youtube'
47
- params[:path] = '/youtube/v3/subscriptions'
48
46
  end
49
47
  end
50
48
 
@@ -1,9 +1,9 @@
1
- require 'yt/collections/resources'
1
+ require 'yt/collections/base'
2
2
  require 'yt/models/user_info'
3
3
 
4
4
  module Yt
5
5
  module Collections
6
- class UserInfos < Resources
6
+ class UserInfos < Base
7
7
 
8
8
  private
9
9
 
@@ -1,9 +1,9 @@
1
- require 'yt/collections/resources'
1
+ require 'yt/collections/base'
2
2
  require 'yt/models/video'
3
3
 
4
4
  module Yt
5
5
  module Collections
6
- class Videos < Resources
6
+ class Videos < Base
7
7
 
8
8
  private
9
9
 
@@ -9,21 +9,17 @@ module Yt
9
9
  !exists?
10
10
  end
11
11
 
12
- # Valid body (no defaults) are: title (string), description (string), privacy_status (string),
13
- # tags (array of strings) - since title is required, we set it again if it's not passed
14
12
  def update(options = {})
15
- parts, body = [], {id: @id}
16
-
17
13
  options[:title] ||= title
18
- parts << :snippet
19
- body[:snippet] = options.slice :title, :description, :tags
14
+ options[:description] ||= description
15
+ options[:tags] ||= tags
16
+ options[:privacy_status] ||= privacy_status
20
17
 
21
- if status = options[:privacy_status]
22
- parts << :status
23
- body[:status] = {privacyStatus: status}
24
- end
18
+ snippet = options.slice :title, :description, :tags
19
+ status = {privacyStatus: privacy_status}
20
+ body = {id: @id, snippet: snippet, status: status}
21
+ params = {params: {part: 'snippet,status'}, body: body}
25
22
 
26
- params = {params: {part: parts.join(',')}, body: body}
27
23
  do_update(params, expect: Net::HTTPOK) do |data|
28
24
  @id = data['id']
29
25
  @snippet = Snippet.new data: data['snippet'] if data['snippet']
@@ -21,7 +21,6 @@ module Yt
21
21
  params[:method] = :post
22
22
  params[:path] = '/youtube/v3/videos/rate'
23
23
  params[:params] = {id: @video_id}
24
- params[:scope] = 'https://www.googleapis.com/auth/youtube'
25
24
  end
26
25
  end
27
26
  end
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.4.9'
2
+ VERSION = '0.4.10'
3
3
  end
@@ -3,9 +3,13 @@ require 'yt/associations/playlists'
3
3
 
4
4
  describe Yt::Associations::Playlists, scenario: :device_app do
5
5
  let(:account) { Yt.configuration.account }
6
+ let(:title) { 'Yt Test title' }
7
+ let(:description) { 'Yt Test description' }
8
+ let(:tags) { ['Yt Test Tag 1', 'Yt Test Tag 2'] }
9
+ let(:privacy_status) { 'unlisted' }
10
+ let(:params) { {title: title, description: description, tags: tags, privacy_status: privacy_status} }
6
11
 
7
- describe '#playlists' do
8
- let(:params) { {title: "Yt Test Playlists" } }
12
+ describe 'playlists' do
9
13
  before { account.create_playlist params }
10
14
  after { account.delete_playlists params }
11
15
 
@@ -13,16 +17,22 @@ describe Yt::Associations::Playlists, scenario: :device_app do
13
17
  it { expect(account.playlists.first).to be_a Yt::Playlist }
14
18
  end
15
19
 
16
- describe '#create_playlist' do
17
- let(:params) { {title: "Yt Test Create Playlist" } }
20
+ describe 'create a playlist' do
18
21
  after { account.delete_playlists params }
19
22
 
20
23
  it { expect(account.create_playlist params).to be_a Yt::Playlist }
21
24
  it { expect{account.create_playlist params}.to change{account.playlists.count}.by(1) }
22
25
  end
23
26
 
24
- describe '#delete_playlists' do
25
- let(:params) { {title: "Yt Test Delete Playlist #{rand}" } }
27
+ describe 'delete a playlist' do
28
+ let(:title) { "Yt Test Delete Playlist #{rand}" }
29
+ before { @playlist = account.create_playlist params }
30
+
31
+ it { expect(@playlist.delete).to be true }
32
+ end
33
+
34
+ describe 'delete a set of playlists' do
35
+ let(:title) { "Yt Test Delete All Playlists #{rand}" }
26
36
  before { account.create_playlist params }
27
37
 
28
38
  it { expect(account.delete_playlists title: %r{#{params[:title]}}).to eq [true] }
@@ -31,13 +41,22 @@ describe Yt::Associations::Playlists, scenario: :device_app do
31
41
  end
32
42
 
33
43
  describe 'update a playlist' do
34
- let(:old_title) { "Yt Test Before Update Playlist" }
35
- let(:new_title) { "Yt Test After Update Playlist" }
36
- before { @playlist = account.create_playlist title: old_title }
44
+ before { @playlist = account.create_playlist params }
37
45
  after { @playlist.delete }
38
46
 
39
- it { expect(@playlist.update title: new_title).to eq true }
40
- it { expect{@playlist.update title: new_title}.to change{@playlist.title} }
41
- it { expect{@playlist.update privacy_status: 'unlisted'}.to change{@playlist.privacy_status} }
47
+ context 'changes the attributes that are specified to be updated' do
48
+ let(:new_attrs) { {title: "Yt Test Update Playlist #{rand}"} }
49
+ it { expect(@playlist.update new_attrs).to eq true }
50
+ it { expect{@playlist.update new_attrs}.to change{@playlist.title} }
51
+ end
52
+
53
+ context 'does not changes the attributes that are not specified to be updated' do
54
+ let(:new_attrs) { {} }
55
+ it { expect(@playlist.update new_attrs).to eq true }
56
+ it { expect{@playlist.update new_attrs}.not_to change{@playlist.title} }
57
+ it { expect{@playlist.update new_attrs}.not_to change{@playlist.description} }
58
+ it { expect{@playlist.update new_attrs}.not_to change{@playlist.tags} }
59
+ it { expect{@playlist.update new_attrs}.not_to change{@playlist.privacy_status} }
60
+ end
42
61
  end
43
- end
62
+ end
@@ -4,7 +4,8 @@ describe Yt::Configuration do
4
4
  subject(:config) { Yt::Configuration.new }
5
5
 
6
6
  describe '#scenario' do
7
- context 'by default' do
7
+ context 'without an environment variable YT_CLIENT_SCENARIO' do
8
+ before { ENV['YT_CLIENT_SCENARIO'] = nil }
8
9
  it {expect(config.scenario).to be :web_app }
9
10
  end
10
11
 
@@ -20,7 +21,8 @@ describe Yt::Configuration do
20
21
  end
21
22
 
22
23
  describe '#client_id' do
23
- context 'by default' do
24
+ context 'without an environment variable YT_CLIENT_ID' do
25
+ before { ENV['YT_CLIENT_ID'] = nil }
24
26
  it {expect(config.client_id).to be_nil }
25
27
  end
26
28
 
@@ -32,7 +34,8 @@ describe Yt::Configuration do
32
34
  end
33
35
 
34
36
  describe '#client_secret' do
35
- context 'by default' do
37
+ context 'without an environment variable YT_CLIENT_SECRET' do
38
+ before { ENV['YT_CLIENT_SECRET'] = nil }
36
39
  it {expect(config.client_secret).to be_nil }
37
40
  end
38
41
 
@@ -44,7 +47,8 @@ describe Yt::Configuration do
44
47
  end
45
48
 
46
49
  describe '#api_key' do
47
- context 'by default' do
50
+ context 'without an environment variable YT_API_KEY' do
51
+ before { ENV['YT_API_KEY'] = nil }
48
52
  it {expect(config.api_key).to be_nil }
49
53
  end
50
54
 
@@ -31,8 +31,7 @@ describe Yt::Playlist do
31
31
  end
32
32
 
33
33
  describe '#update' do
34
- # TODO: separate stubs to show options translate into do_insert params
35
- let(:attrs) { {id: 'PLSWYkYzOr', snippet: {'title'=>'old'}} }
34
+ let(:attrs) { {id: 'PLSWYkYzOr', snippet: {'title'=>'old'}, status: {"privacyStatus"=>"public"}} }
36
35
  before { playlist.stub(:do_update).and_yield 'snippet'=>{'title'=>'new'} }
37
36
 
38
37
  it { expect(playlist.update title: 'new').to be_true }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9
4
+ version: 0.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
@@ -143,7 +143,6 @@ files:
143
143
  - lib/yt/collections/playlist_items.rb
144
144
  - lib/yt/collections/playlists.rb
145
145
  - lib/yt/collections/ratings.rb
146
- - lib/yt/collections/resources.rb
147
146
  - lib/yt/collections/snippets.rb
148
147
  - lib/yt/collections/subscriptions.rb
149
148
  - lib/yt/collections/user_infos.rb
@@ -1,16 +0,0 @@
1
- require 'yt/collections/base'
2
-
3
- module Yt
4
- module Collections
5
- class Resources < Base
6
- def initialize(options = {})
7
- @parent = options[:parent]
8
- @auth = options[:auth]
9
- end
10
-
11
- def self.of(parent)
12
- new parent: parent, auth: parent.auth
13
- end
14
- end
15
- end
16
- end