yt 0.6.6 → 0.7.0
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 +7 -0
- data/README.md +12 -2
- data/bin/yt +11 -0
- data/lib/yt/collections/content_details.rb +27 -0
- data/lib/yt/collections/statistics_sets.rb +27 -0
- data/lib/yt/models/channel.rb +7 -0
- data/lib/yt/models/{details_set.rb → content_detail.rb} +1 -1
- data/lib/yt/models/statistics_set.rb +56 -0
- data/lib/yt/models/video.rb +11 -4
- data/lib/yt/version.rb +2 -2
- data/spec/associations/device_auth/channel_spec.rb +10 -0
- data/spec/associations/device_auth/video_spec.rb +4 -2
- data/spec/associations/server_auth/channel_spec.rb +10 -0
- data/spec/associations/server_auth/video_spec.rb +4 -2
- data/spec/collections/content_details_spec.rb +6 -0
- data/spec/models/{details_set_spec.rb → content_detail_spec.rb} +19 -19
- data/spec/models/statistics_set_spec.rb +68 -0
- metadata +11 -7
- data/lib/yt/collections/details_sets.rb +0 -22
- data/spec/collections/details_sets_spec.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a5cb2545b6f99eea1e0198c6109efd72a30c3eb
|
4
|
+
data.tar.gz: 9c1782a564c0705ce405d867d4f4b0d29f1b7b34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f10cbdd0d96b4cc395064814b0aa4cb85b6769ee71981415092797bb9d5931ce35e856560592c3960602e007798894a206df96e4454e60128f86216e7cc61a9
|
7
|
+
data.tar.gz: 9966a633b35554e6716245eb7da8d786bd9f3d79cdf29c77c1bc09101b26348d5031f856e2a33e194ae8d64c9a600bbd131f1c88b44afc1ea2aeabc7f5300aaa
|
data/Gemfile.lock
CHANGED
data/HISTORY.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
v0.7 - 2014/06/18
|
2
|
+
-----------------
|
3
|
+
|
4
|
+
* [breaking change] Rename DetailsSet to ContentDetail
|
5
|
+
* Add statistics_set to Video (views, likes, dislikes, favorites, comments)
|
6
|
+
* Add statistics_set to Channel (views, comments, videos, subscribers)
|
7
|
+
|
1
8
|
v0.6 - 2014/06/05
|
2
9
|
-----------------
|
3
10
|
|
data/README.md
CHANGED
@@ -19,13 +19,23 @@ channel = Yt::Channel.new id: 'UCxO1tY8h1AhOz0T4ENwmpow'
|
|
19
19
|
channel.title #=> "Fullscreen"
|
20
20
|
channel.description #=> "The first media company for the connected generation."
|
21
21
|
channel.public? #=> true
|
22
|
-
channel.
|
22
|
+
channel.view_count #=> 421619
|
23
|
+
channel.comment_count #=> 773
|
24
|
+
channel.video_count #=> 13
|
25
|
+
channel.subscriber_count #=> 136925
|
26
|
+
channel.subscriber_count_visible? #=> true
|
27
|
+
channel.videos.count #=> 13
|
23
28
|
```
|
24
29
|
|
25
30
|
```ruby
|
26
31
|
video = Yt::Video.new id: 'MESycYJytkU'
|
27
32
|
video.title #=> "Fullscreen Creator Platform"
|
28
33
|
video.public? #=> true
|
34
|
+
video.view_count #=> 55843
|
35
|
+
video.comment_count #=> 308
|
36
|
+
video.like_count #=> 556
|
37
|
+
video.dislike_count #=> 78
|
38
|
+
video.favorite_count #=> 0
|
29
39
|
video.duration #=> 86
|
30
40
|
video.hd? #=> true
|
31
41
|
video.stereoscopic? #=> false
|
@@ -336,7 +346,7 @@ To install on your system, run
|
|
336
346
|
|
337
347
|
To use inside a bundled Ruby project, add this line to the Gemfile:
|
338
348
|
|
339
|
-
gem 'yt', '~> 0.
|
349
|
+
gem 'yt', '~> 0.7.0'
|
340
350
|
|
341
351
|
Since the gem follows [Semantic Versioning](http://semver.org),
|
342
352
|
indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
|
data/bin/yt
CHANGED
@@ -15,6 +15,12 @@ puts "Title: #{channel.title}"
|
|
15
15
|
puts "Description: #{channel.description}"
|
16
16
|
puts "Thumbnail: #{channel.thumbnail_url}"
|
17
17
|
puts "Public? #{channel.public?}"
|
18
|
+
puts "Views: #{channel.view_count}"
|
19
|
+
puts "Comments: #{channel.comment_count}"
|
20
|
+
puts "Videos: #{channel.video_count}"
|
21
|
+
puts "Subscribers: #{channel.subscriber_count}"
|
22
|
+
puts "Subscribers are visible? #{channel.subscriber_count_visible?}"
|
23
|
+
|
18
24
|
puts "Videos: "
|
19
25
|
channel.videos.each do |video|
|
20
26
|
puts " Annotations: #{video.annotations.count}"
|
@@ -23,6 +29,11 @@ channel.videos.each do |video|
|
|
23
29
|
puts " Description: #{video.description}"
|
24
30
|
puts " Thumbnail: #{video.thumbnail_url}"
|
25
31
|
puts " Public? #{video.public?}"
|
32
|
+
puts " Views: #{video.view_count}"
|
33
|
+
puts " Comments: #{video.comment_count}"
|
34
|
+
puts " Likes: #{video.like_count}"
|
35
|
+
puts " Dislikes: #{video.dislike_count}"
|
36
|
+
puts " Favorites: #{video.favorite_count}"
|
26
37
|
puts " hd? #{video.hd?}"
|
27
38
|
puts " stereoscopic? #{video.stereoscopic?}"
|
28
39
|
puts " captioned? #{video.captioned?}"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'yt/collections/base'
|
2
|
+
require 'yt/models/content_detail'
|
3
|
+
|
4
|
+
module Yt
|
5
|
+
module Collections
|
6
|
+
class ContentDetails < Base
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
# @return [Yt::Models::ContentDetail] a new content detail initialized
|
11
|
+
# with one of the items returned by asking YouTube for a list of them.
|
12
|
+
def new_item(data)
|
13
|
+
Yt::ContentDetail.new data: data['contentDetails']
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [Hash] the parameters to submit to YouTube to get the
|
17
|
+
# content detail of a resource, for instance a video.
|
18
|
+
# @see https://developers.google.com/youtube/v3/docs/videos#resource
|
19
|
+
def list_params
|
20
|
+
super.tap do |params|
|
21
|
+
params[:params] = {maxResults: 50, part: 'contentDetails', id: @parent.id}
|
22
|
+
params[:path] = '/youtube/v3/videos'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'yt/collections/base'
|
2
|
+
require 'yt/models/statistics_set'
|
3
|
+
|
4
|
+
module Yt
|
5
|
+
module Collections
|
6
|
+
class StatisticsSets < Base
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
# @return [Yt::Models::StatisticsSet] a new statistics set initialized
|
11
|
+
# with one of the items returned by asking YouTube for a list of them.
|
12
|
+
def new_item(data)
|
13
|
+
Yt::StatisticsSet.new data: data['statistics']
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [Hash] the parameters to submit to YouTube to get the
|
17
|
+
# statistics of a resource, for instance a video.
|
18
|
+
# @see https://developers.google.com/youtube/v3/docs/videos#resource
|
19
|
+
def list_params
|
20
|
+
super.tap do |params|
|
21
|
+
params[:params] = {maxResults: 50, part: 'statistics', id: @parent.id}
|
22
|
+
params[:path] = "/youtube/v3/#{@parent.kind.pluralize}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/yt/models/channel.rb
CHANGED
@@ -22,6 +22,13 @@ module Yt
|
|
22
22
|
# @return [Yt::Collections::Playlists] the channel’s playlists.
|
23
23
|
has_many :playlists
|
24
24
|
|
25
|
+
|
26
|
+
# @!attribute [r] statistics_set
|
27
|
+
# @return [Yt::Models::StatisticsSet] the statistics for the video.
|
28
|
+
has_one :statistics_set
|
29
|
+
delegate :view_count, :comment_count, :video_count, :subscriber_count,
|
30
|
+
:subscriber_count_visible?, to: :statistics_set
|
31
|
+
|
25
32
|
# Returns whether the authenticated account is subscribed to the channel.
|
26
33
|
#
|
27
34
|
# This method requires {Resource#auth auth} to return an
|
@@ -5,7 +5,7 @@ module Yt
|
|
5
5
|
# Encapsulates information about the video content, including the length
|
6
6
|
# of the video and an indication of whether captions are available.
|
7
7
|
# @see https://developers.google.com/youtube/v3/docs/videos#resource
|
8
|
-
class
|
8
|
+
class ContentDetail < Base
|
9
9
|
|
10
10
|
def initialize(options = {})
|
11
11
|
@data = options[:data]
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'yt/models/base'
|
2
|
+
|
3
|
+
module Yt
|
4
|
+
module Models
|
5
|
+
# Encapsulates statistics about the resource, such as the number of times
|
6
|
+
# the resource has been viewed or liked.
|
7
|
+
# @see https://developers.google.com/youtube/v3/docs/videos#resource
|
8
|
+
class StatisticsSet < Base
|
9
|
+
|
10
|
+
def initialize(options = {})
|
11
|
+
@data = options[:data]
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [Integer] the number of times the resource has been viewed.
|
15
|
+
def view_count
|
16
|
+
@view_count ||= @data['viewCount'].to_i
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Integer] the number of comments for the resource.
|
20
|
+
def comment_count
|
21
|
+
@comment_count ||= @data['commentCount'].to_i
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [Integer] the number of users who liked the resource.
|
25
|
+
def like_count
|
26
|
+
@like_count ||= @data['likeCount'].to_i
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Integer] the number of users who disliked the resource.
|
30
|
+
def dislike_count
|
31
|
+
@dislike_count ||= @data['dislikeCount'].to_i
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [Integer] the number of users who currently have the resource
|
35
|
+
# marked as a favorite resource.
|
36
|
+
def favorite_count
|
37
|
+
@favorite_count ||= @data['favoriteCount'].to_i
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [Integer] the number of videos updated to the resource.
|
41
|
+
def video_count
|
42
|
+
@video_count ||= @data['videoCount'].to_i
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [Integer] the number of subscriber the resource has.
|
46
|
+
def subscriber_count
|
47
|
+
@subscriber_count ||= @data['subscriberCount'].to_i
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [Boolean] whether the number of subscribers is publicly visible.
|
51
|
+
def subscriber_count_visible?
|
52
|
+
@subscriber_count_visible ||= @data['hiddenSubscriberCount'] == false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/yt/models/video.rb
CHANGED
@@ -5,10 +5,11 @@ module Yt
|
|
5
5
|
# Provides methods to interact with YouTube videos.
|
6
6
|
# @see https://developers.google.com/youtube/v3/docs/videos
|
7
7
|
class Video < Resource
|
8
|
-
# @!attribute [r]
|
9
|
-
# @return [Yt::Models::
|
10
|
-
has_one :
|
11
|
-
delegate :duration, :hd?, :stereoscopic?, :captioned?, :licensed?,
|
8
|
+
# @!attribute [r] content_detail
|
9
|
+
# @return [Yt::Models::ContentDetail] the video’s content details.
|
10
|
+
has_one :content_detail
|
11
|
+
delegate :duration, :hd?, :stereoscopic?, :captioned?, :licensed?,
|
12
|
+
to: :content_detail
|
12
13
|
|
13
14
|
# @!attribute [r] rating
|
14
15
|
# @return [Yt::Models::Rating] the video’s rating.
|
@@ -18,6 +19,12 @@ module Yt
|
|
18
19
|
# @return [Yt::Collections::Annotations] the video’s annotations.
|
19
20
|
has_many :annotations
|
20
21
|
|
22
|
+
# @!attribute [r] statistics_set
|
23
|
+
# @return [Yt::Models::StatisticsSet] the statistics for the video.
|
24
|
+
has_one :statistics_set
|
25
|
+
delegate :view_count, :like_count, :dislike_count, :favorite_count,
|
26
|
+
:comment_count, to: :statistics_set
|
27
|
+
|
21
28
|
# Returns whether the authenticated account likes the video.
|
22
29
|
#
|
23
30
|
# This method requires {Resource#auth auth} to return an
|
data/lib/yt/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Yt
|
2
|
-
VERSION = '0.
|
3
|
-
end
|
2
|
+
VERSION = '0.7.0'
|
3
|
+
end
|
@@ -16,6 +16,16 @@ describe Yt::Channel, :device_app do
|
|
16
16
|
it { expect{channel.snippet}.to raise_error Yt::Errors::NoItems }
|
17
17
|
end
|
18
18
|
|
19
|
+
describe '.statistics_set of existing channel' do
|
20
|
+
let(:id) { 'UCxO1tY8h1AhOz0T4ENwmpow' }
|
21
|
+
it { expect(channel.statistics_set).to be_a Yt::StatisticsSet }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.statistics_set of unknown channel' do
|
25
|
+
let(:id) { 'not-a-channel-id' }
|
26
|
+
it { expect{channel.statistics_set}.to raise_error Yt::Errors::NoItems }
|
27
|
+
end
|
28
|
+
|
19
29
|
describe '.status of existing channel' do
|
20
30
|
let(:id) { 'UCxO1tY8h1AhOz0T4ENwmpow' }
|
21
31
|
it { expect(channel.status).to be_a Yt::Status }
|
@@ -7,10 +7,11 @@ describe Yt::Video, :device_app do
|
|
7
7
|
context 'given an existing video' do
|
8
8
|
let(:id) { 'MESycYJytkU' }
|
9
9
|
|
10
|
-
it { expect(video.
|
10
|
+
it { expect(video.content_detail).to be_a Yt::ContentDetail }
|
11
11
|
it { expect(video.snippet).to be_a Yt::Snippet }
|
12
12
|
it { expect(video.rating).to be_a Yt::Rating }
|
13
13
|
it { expect(video.status).to be_a Yt::Status }
|
14
|
+
it { expect(video.statistics_set).to be_a Yt::StatisticsSet }
|
14
15
|
|
15
16
|
context 'that I like' do
|
16
17
|
before { video.like }
|
@@ -34,9 +35,10 @@ describe Yt::Video, :device_app do
|
|
34
35
|
context 'given an unknown video' do
|
35
36
|
let(:id) { 'not-a-video-id' }
|
36
37
|
|
37
|
-
it { expect{video.
|
38
|
+
it { expect{video.content_detail}.to raise_error Yt::Errors::NoItems }
|
38
39
|
it { expect{video.snippet}.to raise_error Yt::Errors::NoItems }
|
39
40
|
it { expect{video.rating}.to raise_error Yt::Errors::NoItems }
|
40
41
|
it { expect{video.status}.to raise_error Yt::Errors::NoItems }
|
42
|
+
it { expect{video.statistics_set}.to raise_error Yt::Errors::NoItems }
|
41
43
|
end
|
42
44
|
end
|
@@ -16,6 +16,16 @@ describe Yt::Channel, :server_app do
|
|
16
16
|
it { expect{channel.snippet}.to raise_error Yt::Errors::NoItems }
|
17
17
|
end
|
18
18
|
|
19
|
+
describe '.statistics_set of existing channel' do
|
20
|
+
let(:id) { 'UCxO1tY8h1AhOz0T4ENwmpow' }
|
21
|
+
it { expect(channel.statistics_set).to be_a Yt::StatisticsSet }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.statistics_set of unknown channel' do
|
25
|
+
let(:id) { 'not-a-channel-id' }
|
26
|
+
it { expect{channel.statistics_set}.to raise_error Yt::Errors::NoItems }
|
27
|
+
end
|
28
|
+
|
19
29
|
describe '.status of existing channel' do
|
20
30
|
let(:id) { 'UCxO1tY8h1AhOz0T4ENwmpow' }
|
21
31
|
it { expect(channel.status).to be_a Yt::Status }
|
@@ -7,16 +7,18 @@ describe Yt::Video, :server_app do
|
|
7
7
|
context 'given an existing video' do
|
8
8
|
let(:id) { 'MESycYJytkU' }
|
9
9
|
|
10
|
-
it { expect(video.
|
10
|
+
it { expect(video.content_detail).to be_a Yt::ContentDetail }
|
11
11
|
it { expect(video.snippet).to be_a Yt::Snippet }
|
12
12
|
it { expect(video.status).to be_a Yt::Status }
|
13
|
+
it { expect(video.statistics_set).to be_a Yt::StatisticsSet }
|
13
14
|
end
|
14
15
|
|
15
16
|
context 'given an unknown video' do
|
16
17
|
let(:id) { 'not-a-video-id' }
|
17
18
|
|
18
|
-
it { expect{video.
|
19
|
+
it { expect{video.content_detail}.to raise_error Yt::Errors::NoItems }
|
19
20
|
it { expect{video.snippet}.to raise_error Yt::Errors::NoItems }
|
20
21
|
it { expect{video.status}.to raise_error Yt::Errors::NoItems }
|
22
|
+
it { expect{video.statistics_set}.to raise_error Yt::Errors::NoItems }
|
21
23
|
end
|
22
24
|
end
|
@@ -1,76 +1,76 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'yt/models/
|
2
|
+
require 'yt/models/content_detail'
|
3
3
|
|
4
|
-
describe Yt::
|
5
|
-
subject(:
|
4
|
+
describe Yt::ContentDetail do
|
5
|
+
subject(:content_detail) { Yt::ContentDetail.new data: data }
|
6
6
|
|
7
7
|
describe '#duration' do
|
8
|
-
context 'given a
|
8
|
+
context 'given a content_detail with duration in hours, minutes, seconds' do
|
9
9
|
let(:data) { {"duration"=>"PT1H18M52S"} }
|
10
|
-
it { expect(
|
10
|
+
it { expect(content_detail.duration).to eq 4732 }
|
11
11
|
end
|
12
12
|
|
13
|
-
context 'given a
|
13
|
+
context 'given a content_detail with duration in minutes and seconds' do
|
14
14
|
let(:data) { {"duration"=>"PT2M51S"} }
|
15
|
-
it { expect(
|
15
|
+
it { expect(content_detail.duration).to eq 171 }
|
16
16
|
end
|
17
17
|
|
18
|
-
context 'given a
|
18
|
+
context 'given a content_detail with duration in minutes' do
|
19
19
|
let(:data) { {"duration"=>"PT2M"} }
|
20
|
-
it { expect(
|
20
|
+
it { expect(content_detail.duration).to eq 120 }
|
21
21
|
end
|
22
22
|
|
23
|
-
context 'given a
|
23
|
+
context 'given a content_detail with duration in seconds' do
|
24
24
|
let(:data) { {"duration"=>"PT51S"} }
|
25
|
-
it { expect(
|
25
|
+
it { expect(content_detail.duration).to eq 51 }
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
describe '#stereoscopic?' do
|
30
30
|
context 'given a 3D video' do
|
31
31
|
let(:data) { {"dimension"=>"3d"} }
|
32
|
-
it { expect(
|
32
|
+
it { expect(content_detail).to be_stereoscopic }
|
33
33
|
end
|
34
34
|
|
35
35
|
context 'given a 2D video' do
|
36
36
|
let(:data) { {"dimension"=>"2d"} }
|
37
|
-
it { expect(
|
37
|
+
it { expect(content_detail).not_to be_stereoscopic }
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
describe '#hd?' do
|
42
42
|
context 'given a high-definition video' do
|
43
43
|
let(:data) { {"definition"=>"hd"} }
|
44
|
-
it { expect(
|
44
|
+
it { expect(content_detail).to be_hd }
|
45
45
|
end
|
46
46
|
|
47
47
|
context 'given a standard-definition video' do
|
48
48
|
let(:data) { {"definition"=>"sd"} }
|
49
|
-
it { expect(
|
49
|
+
it { expect(content_detail).not_to be_hd }
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
describe '#captioned?' do
|
54
54
|
context 'given a video with captions' do
|
55
55
|
let(:data) { {"caption"=>"true"} }
|
56
|
-
it { expect(
|
56
|
+
it { expect(content_detail).to be_captioned }
|
57
57
|
end
|
58
58
|
|
59
59
|
context 'given a video without captions' do
|
60
60
|
let(:data) { {"caption"=>"false"} }
|
61
|
-
it { expect(
|
61
|
+
it { expect(content_detail).not_to be_captioned }
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
describe '#captioned?' do
|
66
66
|
context 'given a video with licensed content' do
|
67
67
|
let(:data) { {"licensedContent"=>true} }
|
68
|
-
it { expect(
|
68
|
+
it { expect(content_detail).to be_licensed }
|
69
69
|
end
|
70
70
|
|
71
71
|
context 'given a video without licensed content' do
|
72
72
|
let(:data) { {"licensedContent"=>false} }
|
73
|
-
it { expect(
|
73
|
+
it { expect(content_detail).not_to be_licensed }
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'yt/models/statistics_set'
|
3
|
+
|
4
|
+
describe Yt::StatisticsSet do
|
5
|
+
subject(:statistics_set) { Yt::StatisticsSet.new data: data }
|
6
|
+
let(:value) { 42 }
|
7
|
+
|
8
|
+
describe '#view_count' do
|
9
|
+
context 'given a video with views' do
|
10
|
+
let(:data) { {"viewCount"=>value} }
|
11
|
+
it { expect(statistics_set.view_count).to be value }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#comment_count' do
|
16
|
+
context 'given a video with comments' do
|
17
|
+
let(:data) { {"commentCount"=>value} }
|
18
|
+
it { expect(statistics_set.comment_count).to be value }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#like_count' do
|
23
|
+
context 'given a video with likes' do
|
24
|
+
let(:data) { {"likeCount"=>value} }
|
25
|
+
it { expect(statistics_set.like_count).to be value }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#dislike_count' do
|
30
|
+
context 'given a video with dislikes' do
|
31
|
+
let(:data) { {"dislikeCount"=>value} }
|
32
|
+
it { expect(statistics_set.dislike_count).to be value }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#favorite_count' do
|
37
|
+
context 'given a video with favorites' do
|
38
|
+
let(:data) { {"favoriteCount"=>value} }
|
39
|
+
it { expect(statistics_set.favorite_count).to be value }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#video_count' do
|
44
|
+
context 'given a video with videos' do
|
45
|
+
let(:data) { {"videoCount"=>value} }
|
46
|
+
it { expect(statistics_set.video_count).to be value }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#subscriber_count' do
|
51
|
+
context 'given a video with subscribers' do
|
52
|
+
let(:data) { {"subscriberCount"=>value} }
|
53
|
+
it { expect(statistics_set.subscriber_count).to be value }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#subscriber_count_visible?' do
|
58
|
+
context 'given a video with publicly visible subscribers' do
|
59
|
+
let(:data) { {"hiddenSubscriberCount"=>false} }
|
60
|
+
it { expect(statistics_set).to be_subscriber_count_visible }
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'given a video with hidden subscribers' do
|
64
|
+
let(:data) { {"hiddenSubscriberCount"=>true} }
|
65
|
+
it { expect(statistics_set).not_to be_subscriber_count_visible }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
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
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claudio Baccigalupo
|
@@ -129,7 +129,7 @@ files:
|
|
129
129
|
- lib/yt/collections/authentications.rb
|
130
130
|
- lib/yt/collections/base.rb
|
131
131
|
- lib/yt/collections/channels.rb
|
132
|
-
- lib/yt/collections/
|
132
|
+
- lib/yt/collections/content_details.rb
|
133
133
|
- lib/yt/collections/earnings.rb
|
134
134
|
- lib/yt/collections/ids.rb
|
135
135
|
- lib/yt/collections/partnered_channels.rb
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- lib/yt/collections/ratings.rb
|
139
139
|
- lib/yt/collections/reports.rb
|
140
140
|
- lib/yt/collections/snippets.rb
|
141
|
+
- lib/yt/collections/statistics_sets.rb
|
141
142
|
- lib/yt/collections/statuses.rb
|
142
143
|
- lib/yt/collections/subscriptions.rb
|
143
144
|
- lib/yt/collections/user_infos.rb
|
@@ -155,9 +156,9 @@ files:
|
|
155
156
|
- lib/yt/models/base.rb
|
156
157
|
- lib/yt/models/channel.rb
|
157
158
|
- lib/yt/models/configuration.rb
|
159
|
+
- lib/yt/models/content_detail.rb
|
158
160
|
- lib/yt/models/content_owner.rb
|
159
161
|
- lib/yt/models/description.rb
|
160
|
-
- lib/yt/models/details_set.rb
|
161
162
|
- lib/yt/models/id.rb
|
162
163
|
- lib/yt/models/playlist.rb
|
163
164
|
- lib/yt/models/playlist_item.rb
|
@@ -165,6 +166,7 @@ files:
|
|
165
166
|
- lib/yt/models/request.rb
|
166
167
|
- lib/yt/models/resource.rb
|
167
168
|
- lib/yt/models/snippet.rb
|
169
|
+
- lib/yt/models/statistics_set.rb
|
168
170
|
- lib/yt/models/status.rb
|
169
171
|
- lib/yt/models/subscription.rb
|
170
172
|
- lib/yt/models/url.rb
|
@@ -187,7 +189,7 @@ files:
|
|
187
189
|
- spec/associations/server_auth/video_spec.rb
|
188
190
|
- spec/collections/annotations_spec.rb
|
189
191
|
- spec/collections/channels_spec.rb
|
190
|
-
- spec/collections/
|
192
|
+
- spec/collections/content_details_spec.rb
|
191
193
|
- spec/collections/earnings_spec.rb
|
192
194
|
- spec/collections/playlist_items_spec.rb
|
193
195
|
- spec/collections/playlists_spec.rb
|
@@ -203,14 +205,15 @@ files:
|
|
203
205
|
- spec/models/annotation_spec.rb
|
204
206
|
- spec/models/channel_spec.rb
|
205
207
|
- spec/models/configuration_spec.rb
|
208
|
+
- spec/models/content_detail_spec.rb
|
206
209
|
- spec/models/description_spec.rb
|
207
|
-
- spec/models/details_set_spec.rb
|
208
210
|
- spec/models/playlist_item_spec.rb
|
209
211
|
- spec/models/playlist_spec.rb
|
210
212
|
- spec/models/rating_spec.rb
|
211
213
|
- spec/models/request_spec.rb
|
212
214
|
- spec/models/resource_spec.rb
|
213
215
|
- spec/models/snippet_spec.rb
|
216
|
+
- spec/models/statistics_set_spec.rb
|
214
217
|
- spec/models/status_spec.rb
|
215
218
|
- spec/models/subscription_spec.rb
|
216
219
|
- spec/models/url_spec.rb
|
@@ -262,7 +265,7 @@ test_files:
|
|
262
265
|
- spec/associations/server_auth/video_spec.rb
|
263
266
|
- spec/collections/annotations_spec.rb
|
264
267
|
- spec/collections/channels_spec.rb
|
265
|
-
- spec/collections/
|
268
|
+
- spec/collections/content_details_spec.rb
|
266
269
|
- spec/collections/earnings_spec.rb
|
267
270
|
- spec/collections/playlist_items_spec.rb
|
268
271
|
- spec/collections/playlists_spec.rb
|
@@ -278,14 +281,15 @@ test_files:
|
|
278
281
|
- spec/models/annotation_spec.rb
|
279
282
|
- spec/models/channel_spec.rb
|
280
283
|
- spec/models/configuration_spec.rb
|
284
|
+
- spec/models/content_detail_spec.rb
|
281
285
|
- spec/models/description_spec.rb
|
282
|
-
- spec/models/details_set_spec.rb
|
283
286
|
- spec/models/playlist_item_spec.rb
|
284
287
|
- spec/models/playlist_spec.rb
|
285
288
|
- spec/models/rating_spec.rb
|
286
289
|
- spec/models/request_spec.rb
|
287
290
|
- spec/models/resource_spec.rb
|
288
291
|
- spec/models/snippet_spec.rb
|
292
|
+
- spec/models/statistics_set_spec.rb
|
289
293
|
- spec/models/status_spec.rb
|
290
294
|
- spec/models/subscription_spec.rb
|
291
295
|
- spec/models/url_spec.rb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'yt/collections/base'
|
2
|
-
require 'yt/models/details_set'
|
3
|
-
|
4
|
-
module Yt
|
5
|
-
module Collections
|
6
|
-
class DetailsSets < Base
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
|
-
def new_item(data)
|
11
|
-
Yt::DetailsSet.new data: data['contentDetails']
|
12
|
-
end
|
13
|
-
|
14
|
-
def list_params
|
15
|
-
super.tap do |params|
|
16
|
-
params[:params] = {maxResults: 50, part: 'contentDetails', id: @parent.id}
|
17
|
-
params[:path] = '/youtube/v3/videos'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|