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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a86ecccf4c665eb7b927203f5ef69ef3dca7465c
4
- data.tar.gz: c9d62ede06e44012408a372678a405300061555e
3
+ metadata.gz: 7c1eea8b9775713bed088cc7f3e9c84149c0b14e
4
+ data.tar.gz: 4b78cac3fc3bfa9385b1b4d5e92260bcdb5c9f5e
5
5
  SHA512:
6
- metadata.gz: 728531ccf76c03c01e8ff2a83589045dfa21c09662600666b501b7c9588913d496623183cc90e2631ee58ad2d2755a3531265961a100fc699ef6af40a820a3b1
7
- data.tar.gz: 80e693348d67ea627146709b35c3f0008f9c22b119a041da60497fa44934cab94b47d17628cffff57dcffc8ab6e14ec20eac6f01d4a10199648c26028e2afe66
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 hoboken).freeze
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
@@ -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
- @data = JSON.parse(hash.to_json, object_class: OpenStruct)
17
- @id = @data.id # hash['id']
18
- @state = process_state(@data.state) # hash['state'])
19
- @tags = @data.tags # hash['tags']
20
- @comment = @data.reblog.comment # hash['reblog']['comment']
21
- @summary = @data.summary # hash['summary']
22
- @blog_url = tumblr_url(@data.blog_name) # hash['blog_name'])
23
- @reblog_key = @data.reblog_key # hash['reblog_key']
24
- @image = begin
25
- @data.photos.first.original_size.url
26
- rescue
27
- nil
28
- end
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
- "state = #{@state}\n" \
38
- "tags = #{@tags}\n" \
39
- "comment = #{@comment}\n" \
40
- "summary = #{@summary}\n" \
41
- "blog_url = #{@blog_url}\n" \
42
- "reblog_key = #{@reblog_key}\n" \
43
- "keep_tree = #{@keep_tree}\n" \
44
- "changed = #{@changed}\n"
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)
@@ -1,3 +1,3 @@
1
1
  module DK
2
- VERSION = '0.7.0.5'.freeze
2
+ VERSION = '0.7.0.6'.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.5
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-05 00:00:00.000000000 Z
11
+ date: 2016-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tumblr_client