tumblr_draftking 0.7.0.5 → 0.7.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/draftking/cli/commands/user_command.rb +1 -2
- data/lib/draftking/posts/post.rb +46 -22
- data/lib/draftking/version.rb +1 -1
- 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: 7c1eea8b9775713bed088cc7f3e9c84149c0b14e
|
4
|
+
data.tar.gz: 4b78cac3fc3bfa9385b1b4d5e92260bcdb5c9f5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64a2026c034e3ea9edefce9ec469921f6d04c949d96fa2976e729ac0fdeefec5f327fa92be4d0be715d453b112a8cf0d6f74d25a14352ac9694e4dbe5374d189
|
7
|
+
data.tar.gz: bd6df65e2295d339c6582a04f0aeb27f0e1d50ff124525b68f39050b6f78879d587f2a46ac0ce3f7d5b1dd95574c124731ef23a7e4c755f0403588511f994c32
|
@@ -1,14 +1,13 @@
|
|
1
1
|
module DK
|
2
2
|
# User Defined Command
|
3
3
|
class UserCommand
|
4
|
-
REQUIRED_FIELDS = %w(command
|
4
|
+
REQUIRED_FIELDS = %w(command).freeze
|
5
5
|
def initialize(opts)
|
6
6
|
opts.each_pair do |k, v|
|
7
7
|
singleton_class.class_eval { attr_accessor k.to_s }
|
8
8
|
send("#{k}=", v)
|
9
9
|
end
|
10
10
|
check_required_fields
|
11
|
-
@command_result = nil
|
12
11
|
end
|
13
12
|
|
14
13
|
# Replace current process with execution of @command
|
data/lib/draftking/posts/post.rb
CHANGED
@@ -13,35 +13,53 @@ module DK
|
|
13
13
|
# @param keep_tree [Bool] Attach Reblog Tree?
|
14
14
|
def initialize(hash, keep_tree: nil)
|
15
15
|
return if hash.nil?
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@
|
24
|
-
@
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
16
|
+
# TODO: remove @data
|
17
|
+
# TODO add post type
|
18
|
+
# TODO add photoset images
|
19
|
+
# TODO add various photo sizes
|
20
|
+
data = JSON.parse(hash.to_json, object_class: OpenStruct)
|
21
|
+
@id = data.id
|
22
|
+
@state = process_state(data.state)
|
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
|
29
29
|
@keep_tree = keep_tree.nil? ? false : keep_tree
|
30
30
|
@changed = false
|
31
31
|
@saved = 0
|
32
|
+
data = nil
|
32
33
|
end
|
33
34
|
|
34
35
|
# String of post data
|
35
36
|
def to_s
|
36
|
-
"id = #{@id}\n" \
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
+
to_h.map { |k, v| "#{k} = #{v}" }.join("\n")
|
47
|
+
end
|
48
|
+
|
49
|
+
# Hash of post data
|
50
|
+
def to_h
|
51
|
+
{
|
52
|
+
tumblr_id: @id,
|
53
|
+
state: @state,
|
54
|
+
tags: @tags.join(','),
|
55
|
+
comment: @comment,
|
56
|
+
summary: @summary,
|
57
|
+
blog_url: @blog_url,
|
58
|
+
reblog_key: @reblog_key,
|
59
|
+
keep_tree: @keep_tree,
|
60
|
+
modified: @changed,
|
61
|
+
image: @image
|
62
|
+
}
|
45
63
|
end
|
46
64
|
|
47
65
|
# Change the state of a post
|
@@ -128,6 +146,12 @@ module DK
|
|
128
146
|
@tags = []
|
129
147
|
end
|
130
148
|
|
149
|
+
# Appends CSV or array of tags
|
150
|
+
def add_tags(tags)
|
151
|
+
tags = csv_to_a(tags) if tags.is_a? String
|
152
|
+
@tags += tags
|
153
|
+
end
|
154
|
+
|
131
155
|
private
|
132
156
|
|
133
157
|
def process_state(state)
|
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.7.0.
|
4
|
+
version: 0.7.0.6
|
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-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tumblr_client
|