yt 0.25.24 → 0.25.25

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: 69646f9b5f3274e30a937499733d3dbfa31db71a
4
- data.tar.gz: 895fb71e79bbf91c05903c96c05b33f5f2155357
3
+ metadata.gz: 1335f7c1a7bb273da431dd594490731ecbcb54a7
4
+ data.tar.gz: 16c2b3b3b522e228be01312e2e453f2a431928a8
5
5
  SHA512:
6
- metadata.gz: b6b837f47d06ce91154d7a42742616d04534cdc313293f315c59f151fc75966cad5103c1eaa505323cae51dd1f005e1712eb216352c9292355c1181b955d9d1b
7
- data.tar.gz: 8bf87aef4cce7fcd4ec28c0cc3e31b646f43bf03d4b0119495aa16cc9560a110f04a19b1674a585faac84510c781cb89863dea00372417c28f39ff15bb511652
6
+ metadata.gz: 74d26b785280270e58896fba613dea5a2a167d1e9b134ab65130d01c8cee34b16328cbea597f6cb37b3754a1d04cd6bfc44a3e324f130f589522deeaa813a26e
7
+ data.tar.gz: b716f6a38a7c55e3037377600571b555c5cc07973600485b0e1003ffdf20e205e2e667bdb4058f4c029df3ece0d4228e214bdad3f3b099d7c97f6c6a669916c2
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.25.25 - 2016-03-24
10
+
11
+ * [FEATURE] Add Yt::CommentThread resource.
12
+
9
13
  ## 0.25.24 - 2016-03-02
10
14
 
11
15
  * [BUGFIX] When `videos.where(..)` returns more than one page, don’t retain the items for the next request.
data/README.md CHANGED
@@ -116,6 +116,22 @@ Yt::PlaylistItem
116
116
 
117
117
  Check [fullscreen.github.io/yt](http://fullscreen.github.io/yt/playlist_items.html) for the list of methods available for `Yt::PlaylistItem`.
118
118
 
119
+ Yt::CommentThread
120
+ ----------------
121
+
122
+ Use [Yt::CommentThread](http://www.rubydoc.info/gems/yt/Yt/Models/CommentThread) to:
123
+
124
+ * Show details of a comment_thread
125
+
126
+ ```ruby
127
+ Yt::CommentThread.new id: 'z13vsnnbwtv4sbnug232erczcmi3wzaug'
128
+
129
+ comment_thread.video_id #=> "1234"
130
+ comment_thread.total_reply_count #=> 1
131
+ comment_thread.can_reply? #=> true
132
+ comment_thread.public? #=> true
133
+ ```
134
+
119
135
  Yt::Collections::Videos
120
136
  -----------------------
121
137
 
data/lib/yt.rb CHANGED
@@ -11,6 +11,7 @@ require 'yt/models/playlist'
11
11
  require 'yt/models/playlist_item'
12
12
  require 'yt/models/video'
13
13
  require 'yt/models/video_group'
14
+ require 'yt/models/comment_thread'
14
15
  require 'yt/models/ownership'
15
16
  require 'yt/models/advertising_options_set'
16
17
 
@@ -20,4 +21,4 @@ require 'yt/models/advertising_options_set'
20
21
  # ...), YouTube Analytics API V2 resources (metrics, earnings, ...), and
21
22
  # objects not available through the API (annotations).
22
23
  module Yt
23
- end
24
+ end
@@ -0,0 +1,30 @@
1
+ require 'yt/models/resource'
2
+
3
+ module Yt
4
+ module Models
5
+ # Provides methods to interact with YouTube channels.
6
+ # @see https://developers.google.com/youtube/v3/docs/commentThreads
7
+ class CommentThread < Resource
8
+
9
+ ### SNIPPET ###
10
+
11
+ # @!attribute [r] video_id
12
+ # @return [String] the ID of the video that the comments refer to, if
13
+ # any. If this property is not present or does not have a value, then
14
+ # the thread applies to the channel and not to a specific video.
15
+ delegate :video_id, to: :snippet
16
+
17
+ # @!attribute [r] total_reply_count
18
+ # @return [String] The total number of replies that have been submitted
19
+ # in response to the top-level comment.
20
+ delegate :total_reply_count, to: :snippet
21
+
22
+ # @return [Boolean] whether the thread, including all of its comments and
23
+ # comment replies, is visible to all YouTube users.
24
+ delegate :public?, to: :snippet
25
+
26
+ # @return [Boolean] whether the current viewer can reply to the thread.
27
+ delegate :can_reply?, to: :snippet
28
+ end
29
+ end
30
+ end
@@ -8,6 +8,7 @@ module Yt
8
8
  # @see https://developers.google.com/youtube/v3/docs/videos#resource
9
9
  # @see https://developers.google.com/youtube/v3/docs/playlists#resource
10
10
  # @see https://developers.google.com/youtube/v3/docs/playlistItems#resource
11
+ # @see https://developers.google.com/youtube/v3/docs/commentThread#resource
11
12
  class Snippet < Base
12
13
  attr_reader :data
13
14
 
@@ -28,11 +29,21 @@ module Yt
28
29
  has_attribute :position, type: Integer
29
30
  has_attribute :resource_id, default: {}
30
31
  has_attribute :thumbnails, default: {}
32
+ has_attribute :video_id
33
+ has_attribute :total_reply_count, type: Integer
31
34
 
32
35
  def thumbnail_url(size = :default)
33
36
  thumbnails.fetch(size.to_s, {})['url']
34
37
  end
35
38
 
39
+ def public?
40
+ @public ||= data.fetch 'isPublic', false
41
+ end
42
+
43
+ def can_reply?
44
+ @can_reply ||= data.fetch 'canReply', false
45
+ end
46
+
36
47
  # Returns whether YouTube API includes all attributes in this snippet.
37
48
  # For instance, YouTube API only returns tags and categoryId on
38
49
  # Videos#list, not on Videos#search. And returns position on
@@ -47,4 +58,4 @@ module Yt
47
58
  end
48
59
  end
49
60
  end
50
- end
61
+ end
data/lib/yt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.25.24'
2
+ VERSION = '0.25.25'
3
3
  end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+ require 'yt/models/comment_thread'
3
+
4
+ describe Yt::CommentThread do
5
+ subject(:comment_thread) { Yt::CommentThread.new attrs }
6
+
7
+ describe '#snippet' do
8
+ context 'given fetching a comment thread returns a snippet' do
9
+ let(:attrs) { {snippet: {"videoId" => "12345"}} }
10
+ it { expect(comment_thread.snippet).to be_a Yt::Snippet }
11
+ end
12
+ end
13
+
14
+ describe '#video_id' do
15
+ context 'given a snippet with a video id' do
16
+ let(:attrs) { {snippet: {"videoId"=>"12345"}} }
17
+ it { expect(comment_thread.video_id).to eq '12345' }
18
+ end
19
+
20
+ context 'given a snippet without a video id' do
21
+ let(:attrs) { {snippet: {}} }
22
+ it { expect(comment_thread.video_id).to be_nil }
23
+ end
24
+ end
25
+
26
+ describe '#total_reply_count' do
27
+ context 'given a snippet with a total reply count' do
28
+ let(:attrs) { {snippet: {"totalReplyCount"=>1}} }
29
+ it { expect(comment_thread.total_reply_count).to eq 1 }
30
+ end
31
+
32
+ context 'given a snippet without a total reply count' do
33
+ let(:attrs) { {snippet: {}} }
34
+ it { expect(comment_thread.total_reply_count).to be_nil }
35
+ end
36
+ end
37
+
38
+ describe '#can_reply?' do
39
+ context 'given a snippet with canReply set' do
40
+ let(:attrs) { {snippet: {"canReply"=>true}} }
41
+ it { expect(comment_thread.can_reply?).to be true }
42
+ end
43
+
44
+ context 'given a snippet without canReply set' do
45
+ let(:attrs) { {snippet: {}} }
46
+ it { expect(comment_thread.can_reply?).to be false }
47
+ end
48
+ end
49
+
50
+ describe '#is_public?' do
51
+ context 'given a snippet with isPublic set' do
52
+ let(:attrs) { {snippet: {"isPublic"=>true}} }
53
+ it { expect(comment_thread).to be_public }
54
+ end
55
+
56
+ context 'given a snippet without isPublic set' do
57
+ let(:attrs) { {snippet: {}} }
58
+ it { expect(comment_thread).to_not be_public }
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+ require 'yt/models/comment_thread'
3
+
4
+ describe Yt::CommentThread, :server_app do
5
+ subject(:comment_thread) { Yt::CommentThread.new attrs }
6
+
7
+ context 'given an existing comment thread ID about a channel' do
8
+ let(:attrs) { {id: 'z13vsnnbwtv4sbnug232erczcmi3wzaug'} }
9
+
10
+ it { expect(comment_thread.video_id).to be_nil }
11
+ it { expect(comment_thread.total_reply_count).to be_an Integer }
12
+ it { expect(comment_thread.can_reply?).to be false }
13
+ it { expect(comment_thread).to be_public }
14
+ end
15
+
16
+ context 'given an comment thread ID about a video' do
17
+ let(:attrs) { {id: 'z13ij10h2z3qxpcte23hc5oh2vfzeptk4'} }
18
+ it { expect(comment_thread.video_id).to be_a String }
19
+ end
20
+
21
+ context 'given an unknown comment thread ID' do
22
+ let(:attrs) { {id: 'not-a-comment-thread-id'} }
23
+ it { expect{comment_thread.total_reply_count}.to raise_error Yt::Errors::NoItems }
24
+ end
25
+
26
+ 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.25.24
4
+ version: 0.25.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-02 00:00:00.000000000 Z
11
+ date: 2016-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -189,6 +189,7 @@ files:
189
189
  - lib/yt/models/claim.rb
190
190
  - lib/yt/models/claim_event.rb
191
191
  - lib/yt/models/claim_history.rb
192
+ - lib/yt/models/comment_thread.rb
192
193
  - lib/yt/models/configuration.rb
193
194
  - lib/yt/models/content_detail.rb
194
195
  - lib/yt/models/content_owner.rb
@@ -248,6 +249,7 @@ files:
248
249
  - spec/models/claim_event_spec.rb
249
250
  - spec/models/claim_history_spec.rb
250
251
  - spec/models/claim_spec.rb
252
+ - spec/models/comment_thread_spec.rb
251
253
  - spec/models/configuration_spec.rb
252
254
  - spec/models/content_detail_spec.rb
253
255
  - spec/models/content_owner_detail_spec.rb
@@ -294,6 +296,7 @@ files:
294
296
  - spec/requests/as_content_owner/video_group_spec.rb
295
297
  - spec/requests/as_content_owner/video_spec.rb
296
298
  - spec/requests/as_server_app/channel_spec.rb
299
+ - spec/requests/as_server_app/comment_thread_spec.rb
297
300
  - spec/requests/as_server_app/playlist_item_spec.rb
298
301
  - spec/requests/as_server_app/playlist_spec.rb
299
302
  - spec/requests/as_server_app/video_spec.rb
@@ -351,6 +354,7 @@ test_files:
351
354
  - spec/models/claim_event_spec.rb
352
355
  - spec/models/claim_history_spec.rb
353
356
  - spec/models/claim_spec.rb
357
+ - spec/models/comment_thread_spec.rb
354
358
  - spec/models/configuration_spec.rb
355
359
  - spec/models/content_detail_spec.rb
356
360
  - spec/models/content_owner_detail_spec.rb
@@ -397,6 +401,7 @@ test_files:
397
401
  - spec/requests/as_content_owner/video_group_spec.rb
398
402
  - spec/requests/as_content_owner/video_spec.rb
399
403
  - spec/requests/as_server_app/channel_spec.rb
404
+ - spec/requests/as_server_app/comment_thread_spec.rb
400
405
  - spec/requests/as_server_app/playlist_item_spec.rb
401
406
  - spec/requests/as_server_app/playlist_spec.rb
402
407
  - spec/requests/as_server_app/video_spec.rb