tumblr_draftking 0.10.0 → 0.10.0.1

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: b6e41e4944fa26486bda43f3878307b7b400b67a
4
- data.tar.gz: d5e11a2fcd4e12760460d75a9144b81c4a091796
3
+ metadata.gz: baf83276f4bba8b2a25431e0a28f6d177252bc19
4
+ data.tar.gz: af32e44ef1e49c5e99f1f4247c28db78a57025f9
5
5
  SHA512:
6
- metadata.gz: 9457b1402c0e86adcd0078e1d158924e233885a7174e7875c7fc755736b9e69afde064e06464397611c2acf5fbce5f14097ce2dcf724eaabfe3bda76be6202e5
7
- data.tar.gz: efae44606eba41deb21fd78ee9a5d05de205c2873fb67865cdae19861da5c36b23d7d650433b4ccda8eec0b8f8631eefb1974fdb956d14926648b24adab85377
6
+ metadata.gz: f736833a732b2bd5a72ac312c302ec93a5d984547b0db2144517138f9b337241f83c5c6e431ef8c7120df6238ca274c66018e94eb30e50d36572469b651270fd
7
+ data.tar.gz: 25353c3a70bc1d534894e9da8a55bd16c22687bf473788e254f378af5929a5b28f191dbd7f5cb40823b035a91fe47d08ddc585d08abfa900cc4ab08e2c123d8e
@@ -1,4 +1,7 @@
1
1
  # Changelog :: tumblr_draftking
2
+ ## Version 0.10.0.1
3
+ + Fix for Faraday::ConnectionFailed when trying to reach Tumblr
4
+
2
5
  ## Version 0.10.0
3
6
  + Enhanced get_posts logic to handle retrieval of published posts. Set `dk.source = DK::PUBLISH` before calling `dk.get_posts`.
4
7
 
data/README.md CHANGED
@@ -15,8 +15,8 @@ DraftKing for Tumblr takes the hassle out of managing your draft queue!
15
15
  + **Randomize post order to add variety.**
16
16
  + **Manage multiple accounts.**
17
17
 
18
- Version 0.10.0
19
- + Enhanced get_posts logic to handle retrieval of published posts. Set `dk.source = DK::PUBLISH` before calling `dk.get_posts`.
18
+ Version 0.10.0.1
19
+ + Fix for Faraday::ConnectionFailed when trying to reach Tumblr
20
20
 
21
21
  + Please report any [issues] you encounter!
22
22
  + [Change Log](./CHANGELOG.md)
@@ -65,7 +65,7 @@ module DK
65
65
  # @param name [String] Name of blog to target
66
66
  def act_on_blog(name: nil)
67
67
  return unless connected?
68
- @user = JSON.parse(@client.info['user'].to_json, object_class: OpenStruct)
68
+ @user = client_user_info_to_ostruct
69
69
  @blog_name = name ? name.gsub('.tumblr.com', '') : @user.blogs.first.name
70
70
  @blog_url = tumblr_url(@blog_name)
71
71
  @user.blogs.each do |blog|
@@ -77,6 +77,21 @@ module DK
77
77
  end
78
78
  end
79
79
 
80
+ def client_user_info_to_ostruct
81
+ info = block_with_retry { |_| @client.info['user'].to_json }
82
+ JSON.parse(info, object_class: OpenStruct)
83
+ end
84
+
85
+ def block_with_retry(opts = {}, &block)
86
+ retries = 0
87
+ begin
88
+ return block.call(opts)
89
+ rescue
90
+ retry unless (retries += 1) > MAX_RETRY
91
+ return nil
92
+ end
93
+ end
94
+
80
95
  def connected?
81
96
  @client && @client.info['status'] != 401
82
97
  end
@@ -17,7 +17,7 @@ module DK
17
17
 
18
18
  # Scaling
19
19
  MAX_THREADS = 3
20
- MAX_RETRY = 2
20
+ MAX_RETRY = 3
21
21
 
22
22
  # PostReporter
23
23
  REPORT_TITLE = 'Post Report'.freeze
@@ -157,8 +157,12 @@ module DK
157
157
 
158
158
  # Dashboard integration
159
159
  def call_source(options)
160
- return @client.send(@source, options).first[1] if dashboard? || likes?
161
- @client.send(check_for_publish(@source), @blog_url, options)
160
+ begin
161
+ return @client.send(@source, options).first[1] if dashboard? || likes?
162
+ @client.send(check_for_publish(@source), @blog_url, options)
163
+ rescue
164
+ retry
165
+ end
162
166
  end
163
167
 
164
168
  def check_for_publish(source)
@@ -96,10 +96,17 @@ module DK
96
96
  # @param simulate [Bool] Simulate Action?
97
97
  def reblog(client:, simulate: nil)
98
98
  return 1 if simulate
99
- client.reblog @blog_url,
100
- id: id,
101
- reblog_key: @reblog_key,
102
- comment: @comment
99
+ retries = 0
100
+ begin
101
+ client.reblog @blog_url,
102
+ id: id,
103
+ reblog_key: @reblog_key,
104
+ comment: @comment
105
+ rescue
106
+ retries += 1
107
+ retry unless retries > MAX_RETRY
108
+ raise IOError, 'Connection to Tumblr timed-out!'
109
+ end
103
110
  end
104
111
 
105
112
  # Save a post
@@ -108,13 +115,20 @@ module DK
108
115
  def save(client:, simulate: nil)
109
116
  return 0 unless @changed
110
117
  return @saved = 1 if simulate
111
- res = client.edit @blog_url,
112
- id: id,
113
- reblog_key: @reblog_key,
114
- state: validate_state,
115
- attach_reblog_tree: @keep_tree,
116
- tags: @tags.join(','),
117
- caption: @comment
118
+ retries = 0
119
+ begin
120
+ res = client.edit @blog_url,
121
+ id: id,
122
+ reblog_key: @reblog_key,
123
+ state: validate_state,
124
+ attach_reblog_tree: @keep_tree,
125
+ tags: @tags.join(','),
126
+ caption: @comment
127
+ rescue
128
+ retries += 1
129
+ retry unless retries > MAX_RETRY
130
+ raise IOError, 'Connection to Tumblr timed-out!'
131
+ end
118
132
  return 0 unless res && res['id']
119
133
  @changed = false
120
134
  @saved = 1
@@ -1,3 +1,3 @@
1
1
  module DK
2
- VERSION = '0.10.0'.freeze
2
+ VERSION = '0.10.0.1'.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.10.0
4
+ version: 0.10.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meissa Dia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-15 00:00:00.000000000 Z
11
+ date: 2018-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tumblr_client