yt-core 0.1.3 → 0.1.4
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/docs/comments.html +9 -0
- data/lib/yt/comment_thread.rb +8 -0
- data/lib/yt/core/version.rb +1 -1
- data/lib/yt/relation.rb +8 -3
- data/lib/yt/response.rb +4 -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: bcf250be4dd09edba92d177ab388d0e6ad9c1c7c
|
4
|
+
data.tar.gz: 73302bb09f7fa918fb68d040c0c157e4ea171cd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11ad4095e3cba36dac088c13fe60084e3fb3b3a172e83b4a2e0ad893032a86d77afb7e9ffca71145be8a8140b891063eef3b0dbc52f0448a6224fcee5c2e4d58
|
7
|
+
data.tar.gz: f86ceb9904d7480b89b41a0c4d33d93d9056265381085cd9566a4908b7200de69f869b4317a29eea23163093e0a887537c4b404c663f2135aeef12017b474760
|
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.1.4 - 2017-06-02
|
10
|
+
|
11
|
+
* [FEATURE] Add CommentThread#comments
|
12
|
+
|
9
13
|
## 0.1.3 - 2017-05-23
|
10
14
|
|
11
15
|
* [FEATURE] Add Comment and CommentThread
|
data/docs/comments.html
CHANGED
@@ -43,6 +43,15 @@ thread.top_level_comment.text_display # => "A public comment"
|
|
43
43
|
{% include doc.html instance="CommentThread#top_level_comment" %}{% include example.html object='thread' method='top_level_comment' result='<Yt::Comment @id=z121srzx5...>' %}</pre>
|
44
44
|
</div></dd>
|
45
45
|
|
46
|
+
<dl>
|
47
|
+
{% include dt.html title="CommentThread’s comments" label="success" auth="any authentication works" %}
|
48
|
+
<dd><a class="anchor" id="items"></a><div class="highlight"><pre>
|
49
|
+
{% include doc.html instance="CommentThread#comments" %}{% include example.html object='thread' method='comments' %}
|
50
|
+
{% include example.html result='#<Yt::Relation [#<Yt::Comment @id=z1...>, #<Yt::Comment @id=z2...>, ...]>' %}</pre>
|
51
|
+
</div></dd>
|
52
|
+
</dl>
|
53
|
+
|
54
|
+
|
46
55
|
<hr />
|
47
56
|
<h4>List of <code>Yt::Comment</code> data methods</h4>
|
48
57
|
<dl>
|
data/lib/yt/comment_thread.rb
CHANGED
@@ -15,5 +15,13 @@ module Yt
|
|
15
15
|
# @!attribute [r] top_level_comment
|
16
16
|
# @return [Comment] the thread's top-level comment.
|
17
17
|
has_attribute :top_level_comment, in: :snippet, type: Comment
|
18
|
+
|
19
|
+
# @return [Yt::Relation<Yt::Comment>] the comments of a thread.
|
20
|
+
def comments
|
21
|
+
@comments ||= Relation.new(Comment, parent_id: id,
|
22
|
+
initial_items: -> {[top_level_comment]}) do |options|
|
23
|
+
fetch '/youtube/v3/comments', thread_comments_params(options)
|
24
|
+
end
|
25
|
+
end
|
18
26
|
end
|
19
27
|
end
|
data/lib/yt/core/version.rb
CHANGED
data/lib/yt/relation.rb
CHANGED
@@ -8,7 +8,8 @@ module Yt
|
|
8
8
|
# iterating through a collection of YouTube resources.
|
9
9
|
# @yield [Hash] the options to change which items to iterate through.
|
10
10
|
def initialize(item_class, options = {}, &item_block)
|
11
|
-
@options = {parts: %i(id), limit: Float::INFINITY, item_class: item_class
|
11
|
+
@options = {parts: %i(id), limit: Float::INFINITY, item_class: item_class,
|
12
|
+
initial_items: -> {[]}}
|
12
13
|
@options.merge! options
|
13
14
|
@item_block = item_block
|
14
15
|
end
|
@@ -23,7 +24,7 @@ module Yt
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def find_next
|
26
|
-
@items ||=
|
27
|
+
@items ||= initial_items.dup
|
27
28
|
if @items[@last_index].nil? && more_pages?
|
28
29
|
response = Response.new(@options, &@item_block).run
|
29
30
|
more_items = response.body['items'].map do |item|
|
@@ -36,7 +37,11 @@ module Yt
|
|
36
37
|
end
|
37
38
|
|
38
39
|
def more_pages?
|
39
|
-
@last_index.
|
40
|
+
(@last_index == initial_items.size) || !@options[:offset].nil?
|
41
|
+
end
|
42
|
+
|
43
|
+
def initial_items
|
44
|
+
@initial_items ||= @options[:initial_items].call
|
40
45
|
end
|
41
46
|
|
42
47
|
def attributes_for_new_item(item)
|
data/lib/yt/response.rb
CHANGED
@@ -44,6 +44,10 @@ module Yt
|
|
44
44
|
default_params(options).merge video_id: options[:video_id]
|
45
45
|
end
|
46
46
|
|
47
|
+
def thread_comments_params(options)
|
48
|
+
default_params(options).merge parent_id: options[:parent_id]
|
49
|
+
end
|
50
|
+
|
47
51
|
def resource_params(options)
|
48
52
|
default_params(options).merge id: options[:ids].join(',')
|
49
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yt-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claudio Baccigalupo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yt-support
|