yt 0.12.1 → 0.12.2
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/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/yt/collections/videos.rb +9 -2
- data/lib/yt/models/video.rb +12 -0
- data/lib/yt/version.rb +1 -1
- data/spec/models/video_spec.rb +14 -0
- data/spec/requests/as_server_app/videos_spec.rb +13 -0
- 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: 9333b4d750412a49e64f7f9cb9630b427aa7c2e3
|
4
|
+
data.tar.gz: 2138e4b1baa893c8655df621e75b6137132385e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f40ff61411c758ecd314b1bf81b1784ef87d90416e0073c7ec58a3cb29434a591d6e3d1a0e8dfc30d67868871991e14976023a43654e183a97f07447b60c1d7
|
7
|
+
data.tar.gz: bda762260ab03d9b85c373e0a6740b245a37ad2d2c629f747e26ef1030074804e038381e418e3c359c86022628fa24aac5cf931046bb54f2b17c751feb79d4d8
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ 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.12.2 - 2014-09-09
|
10
|
+
|
11
|
+
* [ENHANCEMENT] Accept `part` in the `where` clause of Videos, so statistics and content details can be eagerly loaded.
|
12
|
+
|
9
13
|
## 0.12.1 - 2014-09-04
|
10
14
|
|
11
15
|
* [ENHANCEMENT] Add `position` option to add_video (to specify where in a playlist to add a video)
|
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.12.
|
44
|
+
gem 'yt', '~> 0.12.2'
|
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*)
|
@@ -13,8 +13,15 @@ module Yt
|
|
13
13
|
|
14
14
|
def attributes_for_new_item(data)
|
15
15
|
id = use_list_endpoint? ? data['id'] : data['id']['videoId']
|
16
|
-
snippet = data
|
17
|
-
{
|
16
|
+
snippet = data['snippet'].merge includes_tags: false if data['snippet']
|
17
|
+
{}.tap do |attributes|
|
18
|
+
attributes[:id] = id
|
19
|
+
attributes[:snippet] = snippet
|
20
|
+
attributes[:status] = data['status']
|
21
|
+
attributes[:content_details] = data['contentDetails']
|
22
|
+
attributes[:statistics] = data['statistics']
|
23
|
+
attributes[:auth] = @auth
|
24
|
+
end
|
18
25
|
end
|
19
26
|
|
20
27
|
# @return [Hash] the parameters to submit to YouTube to list videos.
|
data/lib/yt/models/video.rb
CHANGED
@@ -67,6 +67,18 @@ module Yt
|
|
67
67
|
delegate :view_count, :like_count, :dislike_count, :favorite_count,
|
68
68
|
:comment_count, to: :statistics_set
|
69
69
|
|
70
|
+
# Override Resource's new to set statistics and content details as well
|
71
|
+
# if the response includes them
|
72
|
+
def initialize(options = {})
|
73
|
+
super options
|
74
|
+
if options[:statistics]
|
75
|
+
@statistics_set = StatisticsSet.new data: options[:statistics]
|
76
|
+
end
|
77
|
+
if options[:content_details]
|
78
|
+
@content_detail = ContentDetail.new data: options[:content_details]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
70
82
|
# Returns the list of keyword tags associated with the video.
|
71
83
|
# Since YouTube API only returns tags on Videos#list, the memoized
|
72
84
|
# @snippet is erased if the video was instantiated through Video#search
|
data/lib/yt/version.rb
CHANGED
data/spec/models/video_spec.rb
CHANGED
@@ -11,6 +11,20 @@ describe Yt::Video do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
describe '#statistics_set' do
|
15
|
+
context 'given fetching a video returns statistics' do
|
16
|
+
let(:attrs) { {statistics: {"viewCount"=>"202"}} }
|
17
|
+
it { expect(video.statistics_set).to be_a Yt::StatisticsSet }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#content_details' do
|
22
|
+
context 'given fetching a video returns content details' do
|
23
|
+
let(:attrs) { {content_details: {"definition"=>"hd"}} }
|
24
|
+
it { expect(video.content_detail).to be_a Yt::ContentDetail }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
14
28
|
describe '#update' do
|
15
29
|
let(:attrs) { {id: 'MESycYJytkU', snippet: {'title'=>'old'}} }
|
16
30
|
before { expect(video).to receive(:do_update).and_yield 'snippet'=>{'title'=>'new'} }
|
@@ -24,4 +24,17 @@ describe Yt::Collections::Videos, :server_app do
|
|
24
24
|
specify 'with a chart parameter, only returns videos of that chart', :ruby2 do
|
25
25
|
expect(videos.where(chart: 'mostPopular').size).to be 200
|
26
26
|
end
|
27
|
+
|
28
|
+
context 'with a list of parts' do
|
29
|
+
let(:video_id) { 'MESycYJytkU' }
|
30
|
+
let(:part) { 'statistics,contentDetails' }
|
31
|
+
let(:video) { videos.where(id: 'MESycYJytkU', part: part).first }
|
32
|
+
|
33
|
+
specify 'load ONLY the specified parts of the videos' do
|
34
|
+
expect(video.instance_variable_defined? :@snippet).to be false
|
35
|
+
expect(video.instance_variable_defined? :@status).to be false
|
36
|
+
expect(video.instance_variable_defined? :@statistics_set).to be true
|
37
|
+
expect(video.instance_variable_defined? :@content_detail).to be true
|
38
|
+
end
|
39
|
+
end
|
27
40
|
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.12.
|
4
|
+
version: 0.12.2
|
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-09-
|
11
|
+
date: 2014-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|