yt 0.25.25 → 0.25.26
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 +18 -1
- data/lib/yt/models/comment.rb +37 -0
- data/lib/yt/models/snippet.rb +8 -1
- data/lib/yt/version.rb +1 -1
- data/spec/models/comment_spec.rb +40 -0
- data/spec/requests/as_server_app/comment_spec.rb +28 -0
- metadata +6 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 78dee68c38b98a14d9213c8f01b507425e25cca2
|
|
4
|
+
data.tar.gz: f859f557aef4fa1a76940ddaa5488af2515cb0df
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a98d8b324a2c866fb4ad872e22f7eda31c69dbfc4ce66e11abf5f63fa9a9e497b489a3554ba09baf1c4102b746829ca5fa29eecff3e93dea2887288e4a4ab88d
|
|
7
|
+
data.tar.gz: 8f0da58402c694c51f1b229bf4fd9afe0f2c638893d9086311bb82734639ae523c73b28d6ae441359dc309a2883d0ddfb549bfef56c95468b3648fc4a6cea3f1
|
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.26 - 2016-03-24
|
|
10
|
+
|
|
11
|
+
* [FEATURE] Add Yt::Comment resource.
|
|
12
|
+
|
|
9
13
|
## 0.25.25 - 2016-03-24
|
|
10
14
|
|
|
11
15
|
* [FEATURE] Add Yt::CommentThread resource.
|
data/README.md
CHANGED
|
@@ -121,7 +121,7 @@ Yt::CommentThread
|
|
|
121
121
|
|
|
122
122
|
Use [Yt::CommentThread](http://www.rubydoc.info/gems/yt/Yt/Models/CommentThread) to:
|
|
123
123
|
|
|
124
|
-
* Show details of a comment_thread
|
|
124
|
+
* Show details of a comment_thread.
|
|
125
125
|
|
|
126
126
|
```ruby
|
|
127
127
|
Yt::CommentThread.new id: 'z13vsnnbwtv4sbnug232erczcmi3wzaug'
|
|
@@ -132,6 +132,23 @@ comment_thread.can_reply? #=> true
|
|
|
132
132
|
comment_thread.public? #=> true
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
+
Yt::Comment
|
|
136
|
+
----------------
|
|
137
|
+
|
|
138
|
+
Use [Yt::Comment](http://www.rubydoc.info/gems/yt/Yt/Models/Comment) to:
|
|
139
|
+
|
|
140
|
+
* Get details of a comment.
|
|
141
|
+
|
|
142
|
+
```ruby
|
|
143
|
+
Yt::Comment.new id: 'z13vsnnbwtv4sbnug232erczcmi3wzaug'
|
|
144
|
+
|
|
145
|
+
comment.text_display #=> "awesome"
|
|
146
|
+
comment.author_display_name #=> "Jack"
|
|
147
|
+
comment.like_count #=> 1
|
|
148
|
+
comment.updated_at #=> 2016-03-22 12:56:56 UTC
|
|
149
|
+
comment.parent_id #=> "abc1234" (return nil if the comment is not a reply)
|
|
150
|
+
```
|
|
151
|
+
|
|
135
152
|
Yt::Collections::Videos
|
|
136
153
|
-----------------------
|
|
137
154
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'yt/models/resource'
|
|
2
|
+
|
|
3
|
+
module Yt
|
|
4
|
+
module Models
|
|
5
|
+
# Provides methods to interact with YouTube comment.
|
|
6
|
+
# @see https://developers.google.com/youtube/v3/docs/comments
|
|
7
|
+
class Comment < Resource
|
|
8
|
+
|
|
9
|
+
### SNIPPET ###
|
|
10
|
+
|
|
11
|
+
# @!attribute [r] video_id
|
|
12
|
+
# @return [String] the ID of the video that the comment refers to.
|
|
13
|
+
delegate :video_id, to: :snippet
|
|
14
|
+
|
|
15
|
+
# @!attribute [r] author_display_name
|
|
16
|
+
# @return [String] the display name of the user who posted the comment.
|
|
17
|
+
delegate :author_display_name, to: :snippet
|
|
18
|
+
|
|
19
|
+
# @!attribute [r] text_display
|
|
20
|
+
# @return [String] the comment's text.
|
|
21
|
+
delegate :text_display, to: :snippet
|
|
22
|
+
|
|
23
|
+
# @!attribute [r] parent_id
|
|
24
|
+
# @return [String] the unique ID of the parent comment. This property is only
|
|
25
|
+
# set if the comment was submitted as a reply to another comment.
|
|
26
|
+
delegate :parent_id, to: :snippet
|
|
27
|
+
|
|
28
|
+
# @!attribute [r] like_count
|
|
29
|
+
# @return [Integer] the total number of likes (positive ratings) the comment has received.
|
|
30
|
+
delegate :like_count, to: :snippet
|
|
31
|
+
|
|
32
|
+
# @!attribute [r] updated_at
|
|
33
|
+
# @return [Time] the date and time when the comment was last updated.
|
|
34
|
+
delegate :updated_at, to: :snippet
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
data/lib/yt/models/snippet.rb
CHANGED
|
@@ -8,7 +8,8 @@ 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/
|
|
11
|
+
# @see https://developers.google.com/youtube/v3/docs/commentThreads#resource
|
|
12
|
+
# @see https://developers.google.com/youtube/v3/docs/comments#resource
|
|
12
13
|
class Snippet < Base
|
|
13
14
|
attr_reader :data
|
|
14
15
|
|
|
@@ -31,6 +32,12 @@ module Yt
|
|
|
31
32
|
has_attribute :thumbnails, default: {}
|
|
32
33
|
has_attribute :video_id
|
|
33
34
|
has_attribute :total_reply_count, type: Integer
|
|
35
|
+
has_attribute :author_display_name
|
|
36
|
+
has_attribute :text_display
|
|
37
|
+
has_attribute :parent_id
|
|
38
|
+
has_attribute :like_count, type: Integer
|
|
39
|
+
has_attribute :updated_at, type: Time
|
|
40
|
+
|
|
34
41
|
|
|
35
42
|
def thumbnail_url(size = :default)
|
|
36
43
|
thumbnails.fetch(size.to_s, {})['url']
|
data/lib/yt/version.rb
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'yt/models/comment'
|
|
3
|
+
|
|
4
|
+
describe Yt::Comment do
|
|
5
|
+
subject(:comment) { Yt::Comment.new attrs }
|
|
6
|
+
|
|
7
|
+
describe '#snippet' do
|
|
8
|
+
context 'given fetching a comment returns a snippet' do
|
|
9
|
+
let(:attrs) { {snippet: {"videoId" => "12345"}} }
|
|
10
|
+
it { expect(comment.snippet).to be_a Yt::Snippet }
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe 'attributes' do
|
|
15
|
+
examples = {
|
|
16
|
+
video_id: {with: 'xyz123', without: nil},
|
|
17
|
+
parent_id: {with: 'abc123', without: nil},
|
|
18
|
+
text_display: {with: 'awesome', without: nil},
|
|
19
|
+
author_display_name: {with: 'John', without: nil},
|
|
20
|
+
like_count: {with: 10, without: nil},
|
|
21
|
+
updated_at: {input: '2016-03-22T12:56:56.3Z', with: Time.parse('2016-03-22T12:56:56.3Z'), without: nil},
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
examples.each do |attr, cases|
|
|
25
|
+
describe "##{attr}" do
|
|
26
|
+
context "given a snippet with a #{attr}" do
|
|
27
|
+
let(:attrs) {
|
|
28
|
+
{snippet: {"#{attr.to_s.camelize(:lower)}" => cases[:input] || cases[:with]}}}
|
|
29
|
+
it { expect(comment.send(attr)).to eq cases[:with] }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context "given a snippet without a #{attr}" do
|
|
33
|
+
let(:attrs) { {snippet: {}} }
|
|
34
|
+
it { expect(comment.send(attr)).to eq cases[:without] }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'yt/models/comment'
|
|
3
|
+
|
|
4
|
+
describe Yt::Comment, :server_app do
|
|
5
|
+
subject(:comment) { Yt::Comment.new attrs }
|
|
6
|
+
|
|
7
|
+
context 'given an existing comment (non-reply) ID' do
|
|
8
|
+
let(:attrs) { {id: 'z13kc1bxpp22hzaxr04cd1kreurbjja41q00k'} }
|
|
9
|
+
|
|
10
|
+
it { expect(comment.parent_id).to be_nil }
|
|
11
|
+
it { expect(comment.text_display).to be_a String }
|
|
12
|
+
it { expect(comment.author_display_name).to be_a String }
|
|
13
|
+
it { expect(comment.like_count).to be_a Integer }
|
|
14
|
+
it { expect(comment.updated_at).to be_a Time }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context 'given an existing comment (reply) ID' do
|
|
18
|
+
let(:attrs) { {id: 'z13kc1bxpp22hzaxr04cd1kreurbjja41q00k.1458679991141996'} }
|
|
19
|
+
|
|
20
|
+
it { expect(comment.parent_id).to be_a String }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
context 'given an unknown comment ID' do
|
|
24
|
+
let(:attrs) { {id: 'not-a-comment-id'} }
|
|
25
|
+
it { expect{comment.text_display}.to raise_error Yt::Errors::NoItems }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
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.25.
|
|
4
|
+
version: 0.25.26
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Claudio Baccigalupo
|
|
@@ -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.rb
|
|
192
193
|
- lib/yt/models/comment_thread.rb
|
|
193
194
|
- lib/yt/models/configuration.rb
|
|
194
195
|
- lib/yt/models/content_detail.rb
|
|
@@ -249,6 +250,7 @@ files:
|
|
|
249
250
|
- spec/models/claim_event_spec.rb
|
|
250
251
|
- spec/models/claim_history_spec.rb
|
|
251
252
|
- spec/models/claim_spec.rb
|
|
253
|
+
- spec/models/comment_spec.rb
|
|
252
254
|
- spec/models/comment_thread_spec.rb
|
|
253
255
|
- spec/models/configuration_spec.rb
|
|
254
256
|
- spec/models/content_detail_spec.rb
|
|
@@ -296,6 +298,7 @@ files:
|
|
|
296
298
|
- spec/requests/as_content_owner/video_group_spec.rb
|
|
297
299
|
- spec/requests/as_content_owner/video_spec.rb
|
|
298
300
|
- spec/requests/as_server_app/channel_spec.rb
|
|
301
|
+
- spec/requests/as_server_app/comment_spec.rb
|
|
299
302
|
- spec/requests/as_server_app/comment_thread_spec.rb
|
|
300
303
|
- spec/requests/as_server_app/playlist_item_spec.rb
|
|
301
304
|
- spec/requests/as_server_app/playlist_spec.rb
|
|
@@ -354,6 +357,7 @@ test_files:
|
|
|
354
357
|
- spec/models/claim_event_spec.rb
|
|
355
358
|
- spec/models/claim_history_spec.rb
|
|
356
359
|
- spec/models/claim_spec.rb
|
|
360
|
+
- spec/models/comment_spec.rb
|
|
357
361
|
- spec/models/comment_thread_spec.rb
|
|
358
362
|
- spec/models/configuration_spec.rb
|
|
359
363
|
- spec/models/content_detail_spec.rb
|
|
@@ -401,6 +405,7 @@ test_files:
|
|
|
401
405
|
- spec/requests/as_content_owner/video_group_spec.rb
|
|
402
406
|
- spec/requests/as_content_owner/video_spec.rb
|
|
403
407
|
- spec/requests/as_server_app/channel_spec.rb
|
|
408
|
+
- spec/requests/as_server_app/comment_spec.rb
|
|
404
409
|
- spec/requests/as_server_app/comment_thread_spec.rb
|
|
405
410
|
- spec/requests/as_server_app/playlist_item_spec.rb
|
|
406
411
|
- spec/requests/as_server_app/playlist_spec.rb
|