yt 0.8.4 → 0.8.5
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 +4 -4
- data/Gemfile.lock +1 -1
- data/HISTORY.md +1 -0
- data/README.md +4 -1
- data/lib/yt/models/video.rb +16 -0
- data/lib/yt/version.rb +1 -1
- data/spec/models/video_spec.rb +11 -0
- data/spec/requests/as_account/account_spec.rb +1 -0
- data/spec/requests/as_account/video_spec.rb +9 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c17db6aef4c0edb7def2fd1e9ed2df2a62875997
|
4
|
+
data.tar.gz: 2d635557654f38100344a7c965e249cf1d6249f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35c16b3ac604255ee93caac360b58e47574188d0b08815793e20c3d6af39334a20f632cdab2b95e2713d0dcb8218ac67791fbc4edc1c2e35196593b3e2dfc9aa
|
7
|
+
data.tar.gz: 4ebcbb074447f0fa7e8d5dc71795a7787e0b5643f6dd6a4134133bbaf7d93fcc6fded89c51918fdeb039c54d3198529602e9121aec37ae879eecc3d7f0d24737
|
data/Gemfile.lock
CHANGED
data/HISTORY.md
CHANGED
@@ -6,6 +6,7 @@ v0.8 - 2014/07/18
|
|
6
6
|
* Add content_owner.claims to list the claims administered by a content owner.
|
7
7
|
* Allow content_owner.claims to be chained with .where, such as in account.videos.where(q: 'query')
|
8
8
|
* Add account.content_owners to list content owners associated with an account
|
9
|
+
* Add video.delete
|
9
10
|
|
10
11
|
v0.7 - 2014/06/18
|
11
12
|
-----------------
|
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.
|
44
|
+
gem 'yt', '~> 0.8.5'
|
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*)
|
@@ -203,6 +203,7 @@ Use [Yt::Video](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Models/Video)
|
|
203
203
|
* read the attributes of a video
|
204
204
|
* update the attributes of a video
|
205
205
|
* access the annotations of a video
|
206
|
+
* delete a video
|
206
207
|
* like and dislike a video
|
207
208
|
* retrieve the daily earnings, views, comments, likes, dislikes, shares and impressions of a video
|
208
209
|
* retrieve the viewer percentage of a video by gender and age group
|
@@ -286,6 +287,8 @@ video.shares since: 7.days.ago, until: 7.days.ago #=> {Wed, 28 May 2014 => 3.0}
|
|
286
287
|
|
287
288
|
video.viewer_percentages #=> {female: {'18-24' => 12.12, '25-34' => 16.16,…}…}
|
288
289
|
video.viewer_percentage(gender: :female) #=> 49.12
|
290
|
+
|
291
|
+
video.delete #=> true
|
289
292
|
```
|
290
293
|
|
291
294
|
*The methods above require to be authenticated as the video’s owner (see below).*
|
data/lib/yt/models/video.rb
CHANGED
@@ -61,6 +61,22 @@ module Yt
|
|
61
61
|
delegate :view_count, :like_count, :dislike_count, :favorite_count,
|
62
62
|
:comment_count, to: :statistics_set
|
63
63
|
|
64
|
+
# Deletes the video.
|
65
|
+
#
|
66
|
+
# This method requires {Resource#auth auth} to return an authenticated
|
67
|
+
# instance of {Yt::Account} with permissions to delete the video.
|
68
|
+
# @raise [Yt::Errors::Unauthorized] if {Resource#auth auth} does not
|
69
|
+
# return an account with permissions to delete the video.
|
70
|
+
# @return [Boolean] whether the video does not exist anymore.
|
71
|
+
def delete(options = {})
|
72
|
+
do_delete {@id = nil}
|
73
|
+
!exists?
|
74
|
+
end
|
75
|
+
|
76
|
+
def exists?
|
77
|
+
!@id.nil?
|
78
|
+
end
|
79
|
+
|
64
80
|
# @todo Update the status, not just the snippet. This requires some
|
65
81
|
# caution, as the whole status object needs to be updated, not just
|
66
82
|
# privacyStatus, but also embeddable, license, publicStatsViewable,
|
data/lib/yt/version.rb
CHANGED
data/spec/models/video_spec.rb
CHANGED
@@ -18,4 +18,15 @@ describe Yt::Video do
|
|
18
18
|
it { expect(video.update title: 'new').to be true }
|
19
19
|
it { expect{video.update title: 'new'}.to change{video.title} }
|
20
20
|
end
|
21
|
+
|
22
|
+
describe '#delete' do
|
23
|
+
let(:attrs) { {id: 'video-id'} }
|
24
|
+
|
25
|
+
context 'given an existing video' do
|
26
|
+
before { expect(video).to receive(:do_delete).and_yield }
|
27
|
+
|
28
|
+
it { expect(video.delete).to be true }
|
29
|
+
it { expect{video.delete}.to change{video.exists?} }
|
30
|
+
end
|
31
|
+
end
|
21
32
|
end
|
@@ -32,6 +32,7 @@ describe Yt::Account, :device_app do
|
|
32
32
|
describe '.upload_video' do
|
33
33
|
let(:video_params) { {title: 'Test Yt upload', privacy_status: 'private'} }
|
34
34
|
let(:video) { $account.upload_video path_or_url, video_params }
|
35
|
+
after { video.delete }
|
35
36
|
|
36
37
|
context 'given the path to a local video file' do
|
37
38
|
let(:path_or_url) { File.expand_path '../video.mp4', __FILE__ }
|
@@ -61,6 +61,7 @@ describe Yt::Video, :device_app do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
it { expect{video.update}.to fail }
|
64
|
+
it { expect{video.delete}.to fail.with 'forbidden' }
|
64
65
|
|
65
66
|
context 'that I like' do
|
66
67
|
before { video.like }
|
@@ -91,7 +92,14 @@ describe Yt::Video, :device_app do
|
|
91
92
|
it { expect{video.statistics_set}.to raise_error Yt::Errors::NoItems }
|
92
93
|
end
|
93
94
|
|
94
|
-
context 'given one of my own videos' do
|
95
|
+
context 'given one of my own videos that I want to delete' do
|
96
|
+
before(:all) { @tmp_video = $account.upload_video 'https://bit.ly/yt_test', title: "Yt Test Delete Video #{rand}" }
|
97
|
+
let(:id) { @tmp_video.id }
|
98
|
+
|
99
|
+
it { expect(video.delete).to be true }
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'given one of my own videos that I want to update' do
|
95
103
|
let(:id) { $account.videos.first.id }
|
96
104
|
|
97
105
|
describe 'updates the attributes that I specify explicitly' do
|
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.
|
4
|
+
version: 0.8.5
|
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-
|
11
|
+
date: 2014-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|