tumblr_draftking 0.7.0.7 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +4 -9
- data/lib/draftking/cli/commands/status.rb +13 -9
- data/lib/draftking/client.rb +2 -0
- data/lib/draftking/drafts.rb +6 -9
- data/lib/draftking/posts/post.rb +38 -22
- data/lib/draftking/posts.rb +3 -4
- data/lib/draftking/queue.rb +1 -2
- data/lib/draftking/version.rb +1 -1
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c93a9633bd0ae2cfd31d6791298f44bffaf345da
|
4
|
+
data.tar.gz: 1441e5671dd6325a9bfc7a05669d1bf879b02ad5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80db75ddb4b552d75f8ecbd64055fd8e2655c31a1ce2038908e9642ab55ba715cbb13db040212e6509d27850eda7697c482c3a2f17a7475d026744c37b4e5413
|
7
|
+
data.tar.gz: a5569f9c6fc6aa2254792ed5f30c211e16b7d6332bc6a7399d61ad904411652c9a5db95501401618420d497a5308fc7518f33690586ac3311c308b81c7d49e9d
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
# Changelog :: tumblr_draftking
|
2
|
+
## Version 0.8.0
|
3
|
+
+ DK#post_operation now returns both modified count and modified posts. Use `post_operation(opts)[0]` for previous behavior.
|
4
|
+
+ Access all Tumblr Post data via DK::Post. i.e. `DK::Post.new(post_data).photos.first.original_size.url`
|
5
|
+
+ Post.image (first photo, original size), Post.alt_sizes, Post.photos (array of Photo structs)
|
6
|
+
|
2
7
|
## Version 0.7.0
|
3
8
|
+ New! (CLI) Store [custom commands](#custom-commands) in .dkconfig then view/execute them using DK ($> dk custom)
|
4
9
|
+ New! (Posts) #post_operation Reporter dependency injected via options[:reporter], allowing custom report formats.
|
data/README.md
CHANGED
@@ -12,15 +12,10 @@ DraftKing for Tumblr takes the hassle out of managing your draft queue!
|
|
12
12
|
+ **Randomize post order to add variety.**
|
13
13
|
+ **Manage multiple accounts.**
|
14
14
|
|
15
|
-
Version 0.
|
16
|
-
+
|
17
|
-
+
|
18
|
-
+
|
19
|
-
+ New! (CLI) Updated UI
|
20
|
-
+ New! (Config) Restructured .dkconfig file format and DK::Config to accommodate new functionality.
|
21
|
-
+ New! (CLI) Use Reporter for all content output
|
22
|
-
+ New! (Posts) Support for dashboard access; opts={source: 'dashboard', limit: 50, offset: 0}
|
23
|
-
+ Bugfix: 'bin/dk' not found error when no default config file is present
|
15
|
+
Version 0.8.0
|
16
|
+
+ DK#post_operation now returns both modified count and modified posts. Use `post_operation(opts)[0]` for previous behavior.
|
17
|
+
+ Access all Tumblr Post data via DK::Post. i.e. `DK::Post.new(post_data).photos.first.original_size.url`
|
18
|
+
+ Post.image (first photo, original size), Post.alt_sizes, Post.photos (array of Photo structs)
|
24
19
|
|
25
20
|
+ Please report any [issues] you encounter!
|
26
21
|
+ [Change Log](./CHANGELOG.md)
|
@@ -8,17 +8,21 @@ module DK
|
|
8
8
|
fields = %w(Blog Drafts Queued Q.Space)
|
9
9
|
opts = process_options(options.dup.merge(blog: blog))
|
10
10
|
dk = get_dk_instance(opts)
|
11
|
-
rows =
|
12
|
-
dk.user.blogs.map do |b|
|
13
|
-
next unless blog.nil? || b.name == blog
|
14
|
-
[b.name, b.drafts, b.queue, 300 - b.queue.to_i]
|
15
|
-
end.compact
|
16
|
-
rescue
|
17
|
-
[]
|
18
|
-
end
|
11
|
+
rows = build_rows(dk)
|
19
12
|
report = Reporter.new(title: title, rows: rows, headers: fields)
|
20
|
-
report.show unless simulate
|
13
|
+
report.show unless dk.simulate
|
21
14
|
report
|
22
15
|
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def build_rows(dk)
|
20
|
+
dk.user.blogs.map do |b|
|
21
|
+
next unless blog.nil? || b.name == blog
|
22
|
+
[b.name, b.drafts, b.queue, 300 - b.queue.to_i]
|
23
|
+
end.compact
|
24
|
+
rescue
|
25
|
+
[]
|
26
|
+
end
|
23
27
|
end
|
24
28
|
end
|
data/lib/draftking/client.rb
CHANGED
@@ -45,6 +45,7 @@ module DK
|
|
45
45
|
@before_id = options[:before_id] || 0
|
46
46
|
@offset = options[:offset] || 0
|
47
47
|
@limit = options[:limit]
|
48
|
+
@type = options[:type]
|
48
49
|
end
|
49
50
|
|
50
51
|
# Configure tumblr_client gem
|
@@ -76,6 +77,7 @@ module DK
|
|
76
77
|
@client && @client.info['status'] != 401
|
77
78
|
end
|
78
79
|
|
80
|
+
# Process options[:source]
|
79
81
|
def process_source(src)
|
80
82
|
return :draft unless src
|
81
83
|
return src if src.is_a? Symbol
|
data/lib/draftking/drafts.rb
CHANGED
@@ -8,18 +8,16 @@ module DK
|
|
8
8
|
# @return [int] Number of modified posts
|
9
9
|
def strip_old_comments(options = {})
|
10
10
|
options[:message] = 'Stripping previous comments: '
|
11
|
-
|
11
|
+
post_operation(options) do |post, _|
|
12
12
|
post.changed = true
|
13
13
|
end
|
14
|
-
mod_count
|
15
14
|
end
|
16
15
|
|
17
16
|
def strip_tags(options = {})
|
18
17
|
options[:message] = 'Stripping previous comments: '
|
19
|
-
|
18
|
+
post_operation(options) do |post, _|
|
20
19
|
post.clear_tags
|
21
20
|
end
|
22
|
-
mod_count
|
23
21
|
end
|
24
22
|
|
25
23
|
# Move Drafts to Queue
|
@@ -37,17 +35,16 @@ module DK
|
|
37
35
|
options[:shuffle] = true
|
38
36
|
options[:state] = DK::QUEUE
|
39
37
|
options[:limit] ||= @q_space
|
40
|
-
|
38
|
+
post_operation(options) do |post, index|
|
41
39
|
next false unless index_within_limit?(index, @q_space)
|
42
40
|
next false unless post.has_key_text?(@key_text)
|
43
41
|
post.replace_comment_with(@comment)
|
44
42
|
post.change_state(@state)
|
45
43
|
post.generate_tags(keep_tags: @keep_tags,
|
46
|
-
add_tags:
|
47
|
-
exclude:
|
48
|
-
credit:
|
44
|
+
add_tags: @tags,
|
45
|
+
exclude: @comment,
|
46
|
+
credit: @credit) if @auto_tag
|
49
47
|
end
|
50
|
-
mod_count
|
51
48
|
end
|
52
49
|
end
|
53
50
|
end
|
data/lib/draftking/posts/post.rb
CHANGED
@@ -4,32 +4,30 @@ include DK::Posts
|
|
4
4
|
module DK
|
5
5
|
# Tumblr Post
|
6
6
|
class Post
|
7
|
-
attr_accessor :id, :state, :tags, :comment, :summary, :reblog_key
|
8
|
-
attr_accessor :keep_tree, :changed, :saved, :blog_url
|
9
|
-
attr_accessor :image
|
10
|
-
attr_reader :data
|
11
|
-
|
12
7
|
# @param hash [Hash] Post Data
|
13
8
|
# @param keep_tree [Bool] Attach Reblog Tree?
|
14
9
|
def initialize(hash, keep_tree: nil)
|
15
10
|
return if hash.nil?
|
16
|
-
|
17
|
-
|
18
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@tags = data.tags
|
24
|
-
@comment = data.reblog.comment
|
25
|
-
@summary = data.summary
|
26
|
-
@blog_url = tumblr_url(data.blog_name)
|
27
|
-
@reblog_key = data.reblog_key
|
28
|
-
@image = data.photos.first.original_size.url if data.photos
|
11
|
+
@data = JSON.parse(hash.to_json, object_class: OpenStruct)
|
12
|
+
|
13
|
+
# Translate
|
14
|
+
@state = process_state(@data.state)
|
15
|
+
@blog_url = tumblr_url(@data.blog_name)
|
16
|
+
@image = original_image_url
|
17
|
+
@photoset = @data.photoset_layout
|
29
18
|
@keep_tree = keep_tree.nil? ? false : keep_tree
|
30
19
|
@changed = false
|
31
20
|
@saved = 0
|
32
|
-
|
21
|
+
@comment = @data.caption
|
22
|
+
|
23
|
+
# Direct map
|
24
|
+
@id = @data.id
|
25
|
+
@reblog_key = @data.reblog_key
|
26
|
+
@state = @data.state
|
27
|
+
@summary = @data.summary
|
28
|
+
@tags = @data.tags
|
29
|
+
|
30
|
+
make_accessors(instance_variables)
|
33
31
|
end
|
34
32
|
|
35
33
|
# String of post data
|
@@ -82,7 +80,7 @@ module DK
|
|
82
80
|
# @param simulate [Bool] Simulate Action?
|
83
81
|
def delete(client:, simulate: nil)
|
84
82
|
return 1 if simulate
|
85
|
-
res = client.delete @blog_url,
|
83
|
+
res = client.delete @blog_url, id
|
86
84
|
@changed = true if res['id']
|
87
85
|
res['id'] ? 1 : 0
|
88
86
|
end
|
@@ -93,7 +91,7 @@ module DK
|
|
93
91
|
def reblog(client:, simulate: nil)
|
94
92
|
return 1 if simulate
|
95
93
|
client.reblog @blog_url,
|
96
|
-
id:
|
94
|
+
id: id,
|
97
95
|
reblog_key: @reblog_key,
|
98
96
|
comment: @comment
|
99
97
|
end
|
@@ -105,7 +103,7 @@ module DK
|
|
105
103
|
return 0 unless @changed
|
106
104
|
return @saved = 1 if simulate
|
107
105
|
res = client.edit @blog_url,
|
108
|
-
id:
|
106
|
+
id: id,
|
109
107
|
reblog_key: @reblog_key,
|
110
108
|
state: @state,
|
111
109
|
attach_reblog_tree: @keep_tree,
|
@@ -145,6 +143,24 @@ module DK
|
|
145
143
|
|
146
144
|
private
|
147
145
|
|
146
|
+
def make_accessors(keys)
|
147
|
+
for key in keys
|
148
|
+
singleton_class.class_eval { attr_accessor key.to_s.delete('@') }
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def method_missing(method, *args)
|
153
|
+
if @data.respond_to?(method)
|
154
|
+
return @data.send(method) unless method.to_s.include?('=')
|
155
|
+
@data.send(method, args)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def original_image_url
|
160
|
+
return nil unless @data.photos
|
161
|
+
@data.photos.first.original_size.url unless @data.photos.empty?
|
162
|
+
end
|
163
|
+
|
148
164
|
def process_state(state)
|
149
165
|
return DK::DRAFT unless state
|
150
166
|
return DK::QUEUE if state == 'queued'
|
data/lib/draftking/posts.rb
CHANGED
@@ -82,14 +82,13 @@ module DK
|
|
82
82
|
def comment_posts(options = {})
|
83
83
|
src = source_string(options[:source])
|
84
84
|
options[:message] = "Adding #{src} comment \'#{comment}\': "
|
85
|
-
|
85
|
+
post_operation(options) do |post, _|
|
86
86
|
post.replace_comment_with(@comment)
|
87
87
|
post.generate_tags(keep_tags: @keep_tags,
|
88
88
|
add_tags: @tags,
|
89
89
|
exclude: @comment,
|
90
90
|
credit: @credit) if @auto_tag
|
91
91
|
end
|
92
|
-
mod_count
|
93
92
|
end
|
94
93
|
|
95
94
|
# @param options[:credit] [Bool] Give dk credit?
|
@@ -104,13 +103,12 @@ module DK
|
|
104
103
|
def tag_posts(options)
|
105
104
|
src = source_string(options[:source])
|
106
105
|
options[:message] = "Tagging #{src} with #{options[:add_tags]}: "
|
107
|
-
|
106
|
+
post_operation(options) do |post, _|
|
108
107
|
post.generate_tags(keep_tags: @keep_tags,
|
109
108
|
add_tags: @tags,
|
110
109
|
exclude: @comment,
|
111
110
|
credit: @credit) if @auto_tag
|
112
111
|
end
|
113
|
-
mod_count
|
114
112
|
end
|
115
113
|
|
116
114
|
# Determine draft data to use.
|
@@ -139,6 +137,7 @@ module DK
|
|
139
137
|
options[:since_id] = since_id if since_id
|
140
138
|
options[@source == :draft ? :before_id : :offset] =
|
141
139
|
(@source == :draft ? before_id : offset) unless dashboard?
|
140
|
+
options[:type] = @type if @type
|
142
141
|
|
143
142
|
result = call_source(options)
|
144
143
|
result.is_a?(Integer) ? [] : result
|
data/lib/draftking/queue.rb
CHANGED
@@ -8,10 +8,9 @@ module DK
|
|
8
8
|
options[:message] = 'Moving Queue ~> Drafts: '
|
9
9
|
options[:shuffle] = false
|
10
10
|
options[:state] = DK::DRAFT
|
11
|
-
|
11
|
+
post_operation(options) do |post, _|
|
12
12
|
post.changed = !post.has_key_text?(@key_text)
|
13
13
|
end
|
14
|
-
mod_count
|
15
14
|
end
|
16
15
|
end
|
17
16
|
end
|
data/lib/draftking/version.rb
CHANGED
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.
|
4
|
+
version: 0.8.0
|
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-
|
11
|
+
date: 2016-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tumblr_client
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '10.4'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '10.4'
|
97
97
|
description: "\n Automate a number of tasks for your Tumblr Drafts and Queue such
|
98
98
|
as: tagging, stripping\n previous comments and moving Drafts to your Queue. Visit
|
99
99
|
the homepage for information on\n the latest release or to file a bug report!\n
|
@@ -167,4 +167,3 @@ signing_key:
|
|
167
167
|
specification_version: 4
|
168
168
|
summary: Take the hassle out of managing your Tumblr account!
|
169
169
|
test_files: []
|
170
|
-
has_rdoc:
|