yt-core 0.1.3 → 0.1.4

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: 368c82a9dfd70ec0b355a4d1789e30ea9092c178
4
- data.tar.gz: 274884baeadb9e15cc58acf719bee6712a24bec4
3
+ metadata.gz: bcf250be4dd09edba92d177ab388d0e6ad9c1c7c
4
+ data.tar.gz: 73302bb09f7fa918fb68d040c0c157e4ea171cd4
5
5
  SHA512:
6
- metadata.gz: fc56f8e8ecac5151fedf2082584cf02e6eaee572adbe461801a5a2372c4ea84dd3250300bbf392dce0101eb654f18fb522771325e0bd10e3df7af4d5fef8e791
7
- data.tar.gz: 5f56a363ea52f728a7a1ca0f5f0a568f793961f918f712fe23e049c9075981858a49232ad8ed0563ac4a00e0beb544844597511d029bd9aa05518cfa63bb1a41
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='&lt;Yt::Comment @id=z121srzx5...&gt;' %}</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='#&lt;Yt::Relation [#&lt;Yt::Comment @id=z1...&gt;, #&lt;Yt::Comment @id=z2...&gt;, ...]&gt;' %}</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>
@@ -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
@@ -3,6 +3,6 @@ module Yt
3
3
  module Core
4
4
  # @return [String] the SemVer-compatible gem version.
5
5
  # @see http://semver.org
6
- VERSION = '0.1.3'
6
+ VERSION = '0.1.4'
7
7
  end
8
8
  end
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.zero? || !@options[:offset].nil?
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.3
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-05-23 00:00:00.000000000 Z
11
+ date: 2017-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yt-support