tumblr_draftking 0.7.0.6 → 0.7.0.7

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: 7c1eea8b9775713bed088cc7f3e9c84149c0b14e
4
- data.tar.gz: 4b78cac3fc3bfa9385b1b4d5e92260bcdb5c9f5e
3
+ metadata.gz: 5182d265c74140d67669beb53b1e85482eba5f92
4
+ data.tar.gz: 7579be0019d2ea2828343ee8c9a7b522268cf97f
5
5
  SHA512:
6
- metadata.gz: 64a2026c034e3ea9edefce9ec469921f6d04c949d96fa2976e729ac0fdeefec5f327fa92be4d0be715d453b112a8cf0d6f74d25a14352ac9694e4dbe5374d189
7
- data.tar.gz: bd6df65e2295d339c6582a04f0aeb27f0e1d50ff124525b68f39050b6f78879d587f2a46ac0ce3f7d5b1dd95574c124731ef23a7e4c755f0403588511f994c32
6
+ metadata.gz: a6c03b38f127db39e81670d67502028d968285c081bcdb3a8953802682ee720c07fd364c552d2ad4943138f7666657293060ff5b4963efa7e2261de0ef343c42
7
+ data.tar.gz: f82d3a48f36e6d39c8d81d291d522f15360e8b68ea5836b2dbe9d027459d2216c266386b64d1a8400baf899a6213fe8375bec5cf152ab40c4bd7738e17f262c8
data/CHANGELOG.md CHANGED
@@ -6,6 +6,7 @@
6
6
  + New! (CLI) Updated UI
7
7
  + New! (Config) Restructured .dkconfig file format and DK::Config to accommodate new functionality.
8
8
  + New! (CLI) Use Reporter for all content output
9
+ + New! (Posts) Support for dashboard access; opts={source: 'dashboard', limit: 50, offset: 0}
9
10
  + Bugfix: 'bin/dk' not found error when no default config file is present
10
11
 
11
12
  ## Version 0.6.0.1
data/README.md CHANGED
@@ -19,6 +19,7 @@ Version 0.7.0
19
19
  + New! (CLI) Updated UI
20
20
  + New! (Config) Restructured .dkconfig file format and DK::Config to accommodate new functionality.
21
21
  + New! (CLI) Use Reporter for all content output
22
+ + New! (Posts) Support for dashboard access; opts={source: 'dashboard', limit: 50, offset: 0}
22
23
  + Bugfix: 'bin/dk' not found error when no default config file is present
23
24
 
24
25
  + Please report any [issues] you encounter!
@@ -41,7 +41,7 @@ module DK
41
41
  @tags = options[:add_tags] || @tags
42
42
  @comment = options[:comment] || @comment.to_s
43
43
  @auto_tag = options[:tags].nil? ? true : options[:tags]
44
- @source = options[:source] || :draft
44
+ @source = process_source(options[:source])
45
45
  @before_id = options[:before_id] || 0
46
46
  @offset = options[:offset] || 0
47
47
  @limit = options[:limit]
@@ -75,5 +75,12 @@ module DK
75
75
  def connected?
76
76
  @client && @client.info['status'] != 401
77
77
  end
78
+
79
+ def process_source(src)
80
+ return :draft unless src
81
+ return src if src.is_a? Symbol
82
+ return :dashboard if src.include?('dash')
83
+ return :queue if src.include?('queue')
84
+ end
78
85
  end
79
86
  end
@@ -7,4 +7,11 @@ module Tumblr
7
7
  get(blog_path(blog_name, 'posts/draft'), options)
8
8
  end
9
9
  end
10
+ module User
11
+ def dashboard(options = {})
12
+ valid_opts = [:limit, :offset, :type, :since_id, :reblog_info, :notes_info, :max_id]
13
+ validate_options(valid_opts, options)
14
+ get('v2/user/dashboard', options)
15
+ end
16
+ end
10
17
  end
@@ -34,15 +34,6 @@ module DK
34
34
 
35
35
  # String of post data
36
36
  def to_s
37
- # "id = #{@id}\n" \
38
- # "state = #{@state}\n" \
39
- # "tags = #{@tags}\n" \
40
- # "comment = #{@comment}\n" \
41
- # "summary = #{@summary}\n" \
42
- # "blog_url = #{@blog_url}\n" \
43
- # "reblog_key = #{@reblog_key}\n" \
44
- # "keep_tree = #{@keep_tree}\n" \
45
- # "changed = #{@changed}\n"
46
37
  to_h.map { |k, v| "#{k} = #{v}" }.join("\n")
47
38
  end
48
39
 
@@ -123,6 +123,7 @@ module DK
123
123
  # @return [[Post]] Array of Post Hash data
124
124
  def get_posts
125
125
  return some_test_data if @test_data
126
+ return some_posts(offset: @offset) if dashboard?
126
127
  return all_posts.uniq unless @limit
127
128
  return some_posts(offset: @offset, before_id: @before_id) if @limit <= 50
128
129
  limited_posts
@@ -132,14 +133,23 @@ module DK
132
133
  # @param before_id [Int] [:draft] ID of post to begin reading from
133
134
  # @param offset [Int] [:queue] Post index to start reading from
134
135
  # @return [[Post]] Array of Post Hash data
135
- def some_posts(before_id: 0, offset: 0)
136
+ def some_posts(before_id: 0, offset: 0, max_id: nil, since_id: nil)
136
137
  options = { limit: [(@limit || 50), 50].min }
137
- options[@source == :draft ? :before_id : :offset] = (@source == :draft ? before_id : offset)
138
+ options[:max_id] = max_id if max_id
139
+ options[:since_id] = since_id if since_id
140
+ options[@source == :draft ? :before_id : :offset] =
141
+ (@source == :draft ? before_id : offset) unless dashboard?
138
142
 
139
- result = @client.send(@source, @blog_url, options).first[1]
143
+ result = call_source(options)
140
144
  result.is_a?(Integer) ? [] : result
141
145
  end
142
146
 
147
+ # Dashboard integration
148
+ def call_source(options)
149
+ return @client.send('dashboard', options).first[1] if dashboard?
150
+ @client.send(@source, @blog_url, options).first[1]
151
+ end
152
+
143
153
  # Get @limit # of Posts
144
154
  def limited_posts
145
155
  result = []
@@ -169,5 +179,9 @@ module DK
169
179
  def some_test_data
170
180
  @limit ? @test_data.take(@limit) : @test_data
171
181
  end
182
+
183
+ def dashboard?
184
+ @source == :dashboard
185
+ end
172
186
  end
173
187
  end
@@ -1,3 +1,3 @@
1
1
  module DK
2
- VERSION = '0.7.0.6'.freeze
2
+ VERSION = '0.7.0.7'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tumblr_draftking
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0.6
4
+ version: 0.7.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meissa Dia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-07 00:00:00.000000000 Z
11
+ date: 2016-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tumblr_client