yt 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/Gemfile.lock +1 -1
- data/HISTORY.md +1 -0
- data/README.md +11 -11
- data/lib/yt/associations/playlist_items.rb +8 -0
- data/lib/yt/collections/playlist_items.rb +6 -4
- data/lib/yt/version.rb +1 -1
- data/spec/associations/device_auth/playlist_items_spec.rb +36 -9
- data/yt.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe40139d2888a20c31bda3e4a1fecd43ddebe6d6
|
4
|
+
data.tar.gz: b4f3a450be5b5ac46206fa3365109ee44f42be16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfeb6a2919c6eec4fdbf5e1b13aba3dd267b02ab1b727a1a236c1bce6848bf3327f3ce93b153413b6553cf0078e2cef0fb049cb5f90478036ba09fc1e6d25510
|
7
|
+
data.tar.gz: 0917d9c6dab13d21710165497bf5f5f03124bfa6ba8394e18e7ba6e7b68a39c8aa7972e0c74be8f1fd51441884f6a4707a0cad9cb285841d4ea2b9252460081a
|
data/.travis.yml
CHANGED
@@ -6,11 +6,11 @@ matrix:
|
|
6
6
|
- rvm: 1.9.3
|
7
7
|
gemfile: gemfiles/Gemfile.activesupport-3.x
|
8
8
|
env:
|
9
|
-
- secure:
|
9
|
+
- secure: LuOkhCrHJomwu/Y/l/DIJjKn4zLMRDjtTThJxlANeY4w4S5sac5eGHMD1xxPeWLI7HI8ZIzdqcfOIaVpxts0jeHLLsPCErFl9gWxADCOeC1YSn/07vPhi7KxMEjkR1KbXk1coY4KFZqCByRGYi3s2DnH1HSAKks3ZVs12yhdn6A=
|
10
10
|
- rvm: 2.0.0
|
11
11
|
gemfile: gemfiles/Gemfile.activesupport-4.x
|
12
12
|
env:
|
13
|
-
- secure:
|
13
|
+
- secure: XfoZvb34Vma3tCI5EuV/Pw0V8ISD/QQt9Rda4nTmSRYYSoqjPgrgJhAywnfDTR24ydEpoWJB9jlBq4kk1EywO9jHYoZ/gydzmAoBZ1riDqGvD1muK15gyHLsQu1KMk9jZTtTQ/qpi91rA4qrBWtARfcbhxayTyYjl9zcI8lPmzI=
|
14
14
|
env:
|
15
15
|
global:
|
16
16
|
- secure: KFozlRmcSFzZIl8nXPZ5HIf+MAvgK4I7FYsTYyAMW7LsRJJ4NAJJCHAbWZUfmbqygUN188zj2y0TbQUu47lEf7v2XvJu6DFCYw+e4sk6lSW8V5jRzWl1f6DOKb1z+FBpUgJHj9OKykqjdtm3zVLWr56xm3fhB+ULDj8XVOVxyLk=
|
data/Gemfile.lock
CHANGED
data/HISTORY.md
CHANGED
@@ -6,6 +6,7 @@ v0.4 - 2014/05/09
|
|
6
6
|
* Supports also ActiveSupport 3 and Ruby 1.9.3 (not just AS4 + Ruby 2)
|
7
7
|
* Fix parsing annotation and timestamps longer than 1 hour
|
8
8
|
* Fix delegating tags from resources to snippets
|
9
|
+
* Two options to add videos to a playlist: fail or not if a video is missing
|
9
10
|
|
10
11
|
v0.3.0 - 2014/04/16
|
11
12
|
--------------------
|
data/README.md
CHANGED
@@ -4,10 +4,10 @@ Yt
|
|
4
4
|
Yt helps you write apps that need to interact with the YouTube API V3.
|
5
5
|
|
6
6
|
[![Gem Version](https://badge.fury.io/rb/yt.svg)](http://badge.fury.io/rb/yt)
|
7
|
-
[![Dependency Status](https://gemnasium.com/
|
8
|
-
[![Build Status](https://travis-ci.org/
|
9
|
-
[![Coverage Status](https://coveralls.io/repos/
|
10
|
-
[![Code Climate](https://codeclimate.com/github/
|
7
|
+
[![Dependency Status](https://gemnasium.com/Fullscreen/yt.png)](https://gemnasium.com/Fullscreen/yt)
|
8
|
+
[![Build Status](https://travis-ci.org/Fullscreen/yt.png?branch=master)](https://travis-ci.org/Fullscreen/yt)
|
9
|
+
[![Coverage Status](https://coveralls.io/repos/Fullscreen/yt/badge.png?)](https://coveralls.io/r/Fullscreen/yt)
|
10
|
+
[![Code Climate](https://codeclimate.com/github/Fullscreen/yt.png)](https://codeclimate.com/github/Fullscreen/yt)
|
11
11
|
|
12
12
|
After [registering your app](#registering-your-app), you can run commands like:
|
13
13
|
|
@@ -25,7 +25,7 @@ video.duration #=> 86
|
|
25
25
|
video.annotations.count #=> 1
|
26
26
|
```
|
27
27
|
|
28
|
-
The **full documentation** is available at [rubydoc.info](http://rubydoc.info/github/
|
28
|
+
The **full documentation** is available at [rubydoc.info](http://rubydoc.info/github/Fullscreen/yt/master/frames).
|
29
29
|
|
30
30
|
Available resources
|
31
31
|
===================
|
@@ -33,7 +33,7 @@ Available resources
|
|
33
33
|
Yt::Account
|
34
34
|
-----------
|
35
35
|
|
36
|
-
Use [Yt::Account](http://rubydoc.info/github/
|
36
|
+
Use [Yt::Account](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Account) to:
|
37
37
|
|
38
38
|
* authenticate as a YouTube account
|
39
39
|
* read attributes of the account
|
@@ -52,7 +52,7 @@ account.channel #=> #<Yt::Channel @id=...>
|
|
52
52
|
Yt::Channel
|
53
53
|
-----------
|
54
54
|
|
55
|
-
Use [Yt::Channel](http://rubydoc.info/github/
|
55
|
+
Use [Yt::Channel](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Channel) to:
|
56
56
|
|
57
57
|
* read attributes of a channel
|
58
58
|
* access the videos of a channel
|
@@ -85,7 +85,7 @@ channel.delete_playlists title: 'New playlist' #=> [true]
|
|
85
85
|
Yt::Video
|
86
86
|
-----------
|
87
87
|
|
88
|
-
Use [Yt::Video](http://rubydoc.info/github/
|
88
|
+
Use [Yt::Video](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Video) to:
|
89
89
|
|
90
90
|
* read attributes of a video
|
91
91
|
* access the annotations of a video
|
@@ -110,7 +110,7 @@ video.like #=> true
|
|
110
110
|
Yt::Playlist
|
111
111
|
------------
|
112
112
|
|
113
|
-
Use [Yt::Playlist](http://rubydoc.info/github/
|
113
|
+
Use [Yt::Playlist](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Playlist) to:
|
114
114
|
|
115
115
|
* read attributes of a playlist
|
116
116
|
* access the items of a playlist
|
@@ -139,7 +139,7 @@ playlist.delete_playlist_items title: 'Fullscreen Creator Platform' #=> [true]
|
|
139
139
|
Yt::Annotation
|
140
140
|
--------------
|
141
141
|
|
142
|
-
Use [Yt::Annotation](http://rubydoc.info/github/
|
142
|
+
Use [Yt::Annotation](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Annotation) to:
|
143
143
|
|
144
144
|
* read attributes of an annotation
|
145
145
|
|
@@ -276,7 +276,7 @@ To install on your system, run
|
|
276
276
|
|
277
277
|
To use inside a bundled Ruby project, add this line to the Gemfile:
|
278
278
|
|
279
|
-
gem 'yt', '~> 0.4.
|
279
|
+
gem 'yt', '~> 0.4.7'
|
280
280
|
|
281
281
|
Since the gem follows [Semantic Versioning](http://semver.org),
|
282
282
|
indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
|
@@ -11,6 +11,10 @@ module Yt
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def add_video(video_id)
|
14
|
+
playlist_items.insert({id: video_id, kind: :video}, ignore_not_found: true)
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_video!(video_id)
|
14
18
|
playlist_items.insert id: video_id, kind: :video
|
15
19
|
end
|
16
20
|
|
@@ -18,6 +22,10 @@ module Yt
|
|
18
22
|
video_ids.map{|video_id| add_video video_id}
|
19
23
|
end
|
20
24
|
|
25
|
+
def add_videos!(video_ids = [])
|
26
|
+
video_ids.map{|video_id| add_video! video_id}
|
27
|
+
end
|
28
|
+
|
21
29
|
def delete_playlist_items(attrs = {})
|
22
30
|
playlist_items.delete_all attrs
|
23
31
|
end
|
@@ -5,12 +5,14 @@ module Yt
|
|
5
5
|
module Collections
|
6
6
|
class PlaylistItems < Resources
|
7
7
|
|
8
|
-
#
|
9
|
-
def insert(options = {}) #
|
10
|
-
resource = {kind: "youtube##{
|
11
|
-
resource["#{
|
8
|
+
# attrs are id and kind
|
9
|
+
def insert(attrs = {}, options = {}) #
|
10
|
+
resource = {kind: "youtube##{attrs[:kind]}"}
|
11
|
+
resource["#{attrs[:kind]}Id"] = attrs[:id]
|
12
12
|
snippet = {playlistId: @parent.id, resourceId: resource}
|
13
13
|
do_insert body: {snippet: snippet}, params: {part: 'snippet,status'}
|
14
|
+
rescue Yt::RequestError => error
|
15
|
+
raise error unless options[:ignore_not_found] && error.reasons.include?('videoNotFound')
|
14
16
|
end
|
15
17
|
|
16
18
|
def delete_all(params = {})
|
data/lib/yt/version.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'yt/associations/playlist_items'
|
3
3
|
|
4
|
+
# TODO: Delete playlist item after tests that create them
|
5
|
+
|
4
6
|
describe Yt::Associations::PlaylistItems, scenario: :device_app do
|
5
7
|
before :all do
|
6
8
|
account = Yt.configuration.account
|
@@ -11,26 +13,51 @@ describe Yt::Associations::PlaylistItems, scenario: :device_app do
|
|
11
13
|
describe '#playlist_items' do
|
12
14
|
let(:video_id) { 'MESycYJytkU' }
|
13
15
|
before { @playlist.add_video video_id }
|
14
|
-
# TODO: after, delete playlist item
|
15
16
|
|
16
17
|
it { expect(@playlist.playlist_items.count).to be > 0 }
|
17
18
|
it { expect(@playlist.playlist_items.first).to be_a Yt::PlaylistItem }
|
18
19
|
end
|
19
20
|
|
20
21
|
describe '#add_video' do
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
context 'given an existing video' do
|
23
|
+
let(:video_id) { 'MESycYJytkU' }
|
24
|
+
it { expect(@playlist.add_video video_id).to be_a Yt::PlaylistItem }
|
25
|
+
it { expect{@playlist.add_video video_id}.to change{@playlist.playlist_items.count}.by(1) }
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'given an unknown video' do
|
29
|
+
let(:video_id) { 'not-a-video' }
|
30
|
+
it { expect(@playlist.add_video video_id).to be_nil }
|
31
|
+
it { expect{@playlist.add_video video_id}.not_to change{@playlist.playlist_items.count} }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#add_video!' do
|
36
|
+
context 'given an existing video' do
|
37
|
+
let(:video_id) { 'MESycYJytkU' }
|
38
|
+
it { expect(@playlist.add_video video_id).to be_a Yt::PlaylistItem }
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'given an unknown video' do
|
42
|
+
let(:video_id) { 'not-a-video' }
|
43
|
+
it { expect{@playlist.add_video! video_id}.to raise_error Yt::RequestError }
|
44
|
+
end
|
25
45
|
end
|
26
46
|
|
27
47
|
describe '#add_videos' do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
48
|
+
context 'given one existing and one unknown video' do
|
49
|
+
let(:video_ids) { ['MESycYJytkU', 'not-a-video'] }
|
50
|
+
it { expect(@playlist.add_videos video_ids).to have(2).items }
|
51
|
+
it { expect{@playlist.add_videos video_ids}.to change{@playlist.playlist_items.count}.by(1) }
|
52
|
+
end
|
32
53
|
end
|
33
54
|
|
55
|
+
describe '#add_videos!' do
|
56
|
+
context 'given one existing and one unknown video' do
|
57
|
+
let(:video_ids) { ['MESycYJytkU', 'not-a-video'] }
|
58
|
+
it { expect{@playlist.add_videos! video_ids}.to raise_error Yt::RequestError }
|
59
|
+
end
|
60
|
+
end
|
34
61
|
|
35
62
|
describe '#delete_playlist_items' do
|
36
63
|
let(:video_id) { 'MESycYJytkU' }
|
data/yt.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.description = %q{Youtube V3 API client.}
|
12
12
|
spec.summary = %q{Yt makes it easy to interact with Youtube V3 API by
|
13
13
|
providing a modular, intuitive and tested Ruby-style API.}
|
14
|
-
spec.homepage = "http://github.com/
|
14
|
+
spec.homepage = "http://github.com/Fullscreen/yt"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.required_ruby_version = '>= 1.9.3'
|
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.4.
|
4
|
+
version: 0.4.7
|
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-05-
|
11
|
+
date: 2014-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -211,7 +211,7 @@ files:
|
|
211
211
|
- spec/support/device_app.rb
|
212
212
|
- spec/support/server_app.rb
|
213
213
|
- yt.gemspec
|
214
|
-
homepage: http://github.com/
|
214
|
+
homepage: http://github.com/Fullscreen/yt
|
215
215
|
licenses:
|
216
216
|
- MIT
|
217
217
|
metadata: {}
|