twitter_retry 0.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +9 -0
- data/.hound.yml +3 -0
- data/.rspec +3 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_standard.yml +196 -0
- data/.travis.yml +20 -0
- data/.yardopts +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +72 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/twitter_retry.rb +24 -0
- data/lib/twitter_retry/config.rb +29 -0
- data/lib/twitter_retry/retryable.rb +52 -0
- data/lib/twitter_retry/version.rb +3 -0
- data/twitter_retry.gemspec +32 -0
- metadata +190 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ed93ef8cf4df3d3f46fc904281375a4014720079
|
4
|
+
data.tar.gz: c79fe3a5e74c11848973023d3fa3d782fadb1df2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: adfcd397d9f16c5b410d7a0a39f0e4c645185178b5d2cb93aab77c5ba6d1bb55974508a01c6b78329029a2640b775c6c2aae4437e8d3691fee89f6f1529c9c28
|
7
|
+
data.tar.gz: 2ec0bc05dc73a9943e0a88165b4b0c7fbb9de6db8740b6077add07147717417e5998c84688c0f30c99383dbea57e4b20525990d3c3bb5f0870bc7d4fcb61b41e
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
repo_token: igcyFyf343RQGyIbmuU18O6wGGN69Vx6V
|
data/.gitignore
ADDED
data/.hound.yml
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: .rubocop_standard.yml
|
@@ -0,0 +1,196 @@
|
|
1
|
+
# via. https://gist.github.com/onk/38bfbd78899d892e0e83
|
2
|
+
|
3
|
+
# target_version:
|
4
|
+
# rubocop v0.31.0
|
5
|
+
|
6
|
+
# 自動生成されるものはチェック対象から除外する
|
7
|
+
AllCops:
|
8
|
+
Exclude:
|
9
|
+
- "vendor/**/*" # rubocop config/default.yml
|
10
|
+
- "db/schema.rb"
|
11
|
+
DisplayCopNames: true
|
12
|
+
|
13
|
+
##################### Style ##################################
|
14
|
+
|
15
|
+
# redirect_to xxx and return のイディオムを維持したい
|
16
|
+
Style/AndOr:
|
17
|
+
EnforcedStyle: conditionals
|
18
|
+
|
19
|
+
# 日本語のコメントを許可する
|
20
|
+
Style/AsciiComments:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
# option 等、明示的にハッシュにした方が分かりやすい場合もある
|
24
|
+
Style/BracesAroundHashParameters:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
# Style/CollectionMethods 自体は無効になっているのだが、
|
28
|
+
# https://github.com/bbatsov/rubocop/issues/1084
|
29
|
+
# https://github.com/bbatsov/rubocop/issues/1334
|
30
|
+
# Performance/Detect がこの設定値を見るので PreferredMethods だけ変更しておく。
|
31
|
+
#
|
32
|
+
# デフォルト値から変えたのは
|
33
|
+
# find -> detect
|
34
|
+
# ActiveRecord の find と間違えやすいため
|
35
|
+
# reduce -> inject
|
36
|
+
# detect, reject, select と並べたときに韻を踏んでいるため。
|
37
|
+
# collect -> map を維持しているのは文字数が圧倒的に少ないため。
|
38
|
+
Style/CollectionMethods:
|
39
|
+
PreferredMethods:
|
40
|
+
detect: "detect"
|
41
|
+
find: "detect"
|
42
|
+
inject: "inject"
|
43
|
+
reduce: "inject"
|
44
|
+
|
45
|
+
# Hash#has_key? は許可したい
|
46
|
+
Style/DeprecatedHashMethods:
|
47
|
+
Enabled: false
|
48
|
+
|
49
|
+
# ドキュメントの無い public class を許可する
|
50
|
+
Style/Documentation:
|
51
|
+
Enabled: false
|
52
|
+
|
53
|
+
# !! のイディオムは積極的に使う
|
54
|
+
Style/DoubleNegation:
|
55
|
+
Enabled: false
|
56
|
+
|
57
|
+
# メソッドチェーンの改行は末尾に . を入れる
|
58
|
+
# REPL に貼り付けた際の暴発を防ぐため
|
59
|
+
Style/DotPosition:
|
60
|
+
EnforcedStyle: trailing
|
61
|
+
|
62
|
+
# 明示的に else で nil を返すのは分かりやすいので許可する
|
63
|
+
Style/EmptyElse:
|
64
|
+
EnforcedStyle: empty
|
65
|
+
|
66
|
+
# いずれかに揃えるのならば `sprintf` や `format` より String#% が好きです
|
67
|
+
Style/FormatString:
|
68
|
+
EnforcedStyle: percent
|
69
|
+
|
70
|
+
# if 文の中に 3 行程度のブロックを書くぐらいは許容した方が現実的
|
71
|
+
Style/GuardClause:
|
72
|
+
MinBodyLength: 5
|
73
|
+
|
74
|
+
# 同じ hash 内で記法を混ぜない
|
75
|
+
# rake タスクの順序の hash は rocket を許可する
|
76
|
+
Style/HashSyntax:
|
77
|
+
EnforcedStyle: ruby19_no_mixed_keys
|
78
|
+
Exclude:
|
79
|
+
- "**/*.rake"
|
80
|
+
- "Rakefile"
|
81
|
+
|
82
|
+
# 条件式の方を意識させたい場合には後置の if/unless を使わない方が分かりやすい
|
83
|
+
Style/IfUnlessModifier:
|
84
|
+
Enabled: false
|
85
|
+
|
86
|
+
# ({ と hash を開始した場合に ( の位置にインデントさせる
|
87
|
+
# そもそも {} が必要ない可能性が高いが Style/BracesAroundHashParameters はチェックしないことにしたので
|
88
|
+
Style/IndentHash:
|
89
|
+
EnforcedStyle: consistent
|
90
|
+
|
91
|
+
# private/protected は一段深くインデントする
|
92
|
+
Style/IndentationConsistency:
|
93
|
+
EnforcedStyle: rails
|
94
|
+
|
95
|
+
# scope 等は複数行でも lambda ではなく ->{} で揃えた方が見た目が綺麗
|
96
|
+
Style/Lambda:
|
97
|
+
Enabled: false
|
98
|
+
|
99
|
+
# 1_000_000 と区切り文字が 2 個以上必要になる場合のみ _ 区切りを必須にする
|
100
|
+
Style/NumericLiterals:
|
101
|
+
MinDigits: 7
|
102
|
+
|
103
|
+
# has_ から始まるメソッドは許可する
|
104
|
+
Style/PredicateName:
|
105
|
+
NamePrefixBlacklist:
|
106
|
+
- "is_"
|
107
|
+
- "have_"
|
108
|
+
NamePrefix:
|
109
|
+
- "is_"
|
110
|
+
- "have_"
|
111
|
+
|
112
|
+
# 特に model 内において、ローカル変数とメソッド呼び出しの区別をつけた方が分かりやすい場合が多い
|
113
|
+
Style/RedundantSelf:
|
114
|
+
Enabled: false
|
115
|
+
|
116
|
+
# 受け取り側で multiple assignment しろというのを明示
|
117
|
+
Style/RedundantReturn:
|
118
|
+
AllowMultipleReturnValues: true
|
119
|
+
|
120
|
+
# fail と使い分ける必要ナシ
|
121
|
+
Style/SignalException:
|
122
|
+
EnforcedStyle: only_raise
|
123
|
+
|
124
|
+
# `||` も align に使うことがあるので追加する
|
125
|
+
Style/SpaceAroundOperators:
|
126
|
+
MultiSpaceAllowedForOperators:
|
127
|
+
- "="
|
128
|
+
- "=>"
|
129
|
+
- "||"
|
130
|
+
|
131
|
+
# * 式展開したい場合に書き換えるのが面倒
|
132
|
+
# * 文章ではダブルクォートよりもシングルクォートの方が頻出する
|
133
|
+
# ことから EnforcedStyle: double_quotes 推奨
|
134
|
+
Style/StringLiterals:
|
135
|
+
EnforcedStyle: double_quotes
|
136
|
+
|
137
|
+
# auto-correct 時に Style/StringLiterals とカニバって無限ループになる (v0.28.0)
|
138
|
+
Style/StringLiteralsInInterpolation:
|
139
|
+
Enabled: false
|
140
|
+
|
141
|
+
# いくらなんでも inject { |a, e| } は短すぎるので分かりやすい名前をつけたい
|
142
|
+
Style/SingleLineBlockParams:
|
143
|
+
Enabled: false
|
144
|
+
|
145
|
+
# * migrate
|
146
|
+
# * jbuilder
|
147
|
+
# * model の association
|
148
|
+
# * controller の callback
|
149
|
+
# 辺りの桁揃えで引っかかるので全体的にチェックしない
|
150
|
+
Style/SingleSpaceBeforeFirstArg:
|
151
|
+
Enabled: false
|
152
|
+
|
153
|
+
# 複数行の場合はケツカンマを入れる
|
154
|
+
Style/TrailingComma:
|
155
|
+
EnforcedStyleForMultiline: comma
|
156
|
+
|
157
|
+
##################### Lint ##################################
|
158
|
+
|
159
|
+
# * 同名のメソッドがある場合にローカル変数に `_` を付ける
|
160
|
+
# * 一時変数として `_` を付ける
|
161
|
+
# というテクニックは頻出する
|
162
|
+
Lint/UnderscorePrefixedVariableName:
|
163
|
+
Enabled: false
|
164
|
+
|
165
|
+
# 子クラスで実装させるつもりのメソッドで引っかかるので
|
166
|
+
Lint/UnusedMethodArgument:
|
167
|
+
Enabled: false
|
168
|
+
|
169
|
+
##################### Metrics ##################################
|
170
|
+
|
171
|
+
# 30 まではギリギリ許せる範囲だった
|
172
|
+
Metrics/AbcSize:
|
173
|
+
Max: 30
|
174
|
+
|
175
|
+
# 6 は強すぎるので緩める
|
176
|
+
Metrics/CyclomaticComplexity:
|
177
|
+
Max: 10
|
178
|
+
|
179
|
+
# * 警告 120文字
|
180
|
+
# * 禁止 160文字
|
181
|
+
# のイメージ
|
182
|
+
Metrics/LineLength:
|
183
|
+
Max: 160
|
184
|
+
Exclude:
|
185
|
+
- "db/migrate/*.rb"
|
186
|
+
|
187
|
+
# 20 行超えるのは migration ファイル以外滅多に無い
|
188
|
+
Metrics/MethodLength:
|
189
|
+
Max: 20
|
190
|
+
Exclude:
|
191
|
+
- "db/migrate/*.rb"
|
192
|
+
|
193
|
+
# 分岐の数。ガード句を多用しているとデフォルト 7 だと厳しい
|
194
|
+
Metrics/PerceivedComplexity:
|
195
|
+
Max: 8
|
196
|
+
|
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.1
|
4
|
+
- 2.2
|
5
|
+
- ruby-head
|
6
|
+
before_install: gem install bundler -v 1.10.5
|
7
|
+
before_script:
|
8
|
+
- export CI=true
|
9
|
+
script: bundle exec rspec
|
10
|
+
branches:
|
11
|
+
only:
|
12
|
+
- master
|
13
|
+
notifications:
|
14
|
+
slack:
|
15
|
+
secure: auD2UNPVzPfJ9jKMQ89sK6aXYv5ekXSsuuqn8aiZ2+w96lb/B/lRVzOPgzmDe1/qIvYevYO3AcfgG373ARV0Ft/SEzlwiIOAhu47nyprM641AFiGQovCNe+vpWo6k3YD+J+WNG8NiD+6vDfmkmBSnE6/+VL5HUiVtW8FeFQ0lRBgcu789MWyXkZVtzvWvMTlPk3N94JgARUcT4F2bukTu1Ff95D4fZfnArJLfpv9uzxuCYUB9Ut33OdXb8k9xG+0OJeosV7oTYLKY3I+oK8mkweIzzy9flhpmLw6xCzARX2zQcsoEXeiDoUVKmldTLApBQMF96xCG6yxn1SaapsqKovVbudBuafjhpJklb1zG21UmYuNr7SmZqrLYcBb2sMLD41wyeBfJ/mO7SNWZlwJAvMrL5O538qpMfvbT3EQWGWdWnhYR79nKO5zLDqgUeJC847/QiS43MvnPlwObpO68bXdRq+C4Z6DfL96tjGfFprijKHJtZqG1kFHMELrDx6lzUi03Kt5FaHV2czz/5B7oqPsXvTWWa0yaLopxuSZqcD2zrSaso8bNFFqkt2X4CKTx2Jqq4IuGrrzqqr1NMSX2tbT06tJAKYCUQfa5mJqs2uRtzYR3jivukb+EwNOCFThrRBi69AYa2XAKjzCJ7DoFn3uQvXlmCu/3bbPQTs0LT4=
|
16
|
+
matrix:
|
17
|
+
allow_failures:
|
18
|
+
- rvm: ruby-head
|
19
|
+
sudo: false
|
20
|
+
cache: bundler
|
data/.yardopts
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 sue445
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# TwitterRetry
|
2
|
+
|
3
|
+
Twitter api awesome handling with retry
|
4
|
+
|
5
|
+
[![Build Status](https://travis-ci.org/sue445/twitter_retry.svg?branch=master)](https://travis-ci.org/sue445/twitter_retry)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/sue445/twitter_retry/badges/gpa.svg)](https://codeclimate.com/github/sue445/twitter_retry)
|
7
|
+
[![Coverage Status](https://coveralls.io/repos/sue445/twitter_retry/badge.svg?branch=master&service=github)](https://coveralls.io/github/sue445/twitter_retry?branch=master)
|
8
|
+
[![Dependency Status](https://gemnasium.com/sue445/twitter_retry.svg)](https://gemnasium.com/sue445/twitter_retry)
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'twitter_retry'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install twitter_retry
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
```ruby
|
28
|
+
TwitterRetry.with_handing do
|
29
|
+
# some twitter API code
|
30
|
+
twitter.update("some tweet")
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
* When `twitter.update` not raise error
|
35
|
+
* return `true`
|
36
|
+
* When `twitter.update` raise `Twitter::Error::Forbidden` (Your account is suspended and is not permitted to access this feature.)
|
37
|
+
* raise `TwitterRetry::SuspendedError`
|
38
|
+
* When `twitter.update` raise ignorable error (ex. `Twitter::Error::Forbidden`(User is over daily status update limit.))
|
39
|
+
* error is squashed
|
40
|
+
* return `false`
|
41
|
+
* When `twitter.update` raise retryable error (ex. `Twitter::Error::ServiceUnavailable`(Over capacity))
|
42
|
+
* retry 3 times with sleep 1 second
|
43
|
+
* When successful in retry, return `true`
|
44
|
+
* When all failure, raise `TwitterRetry::RetryOverError`
|
45
|
+
|
46
|
+
The algorithm is actually more concise in code: See [TwitterRetry::Retryable](lib/twitter_retry/retryable.rb)
|
47
|
+
|
48
|
+
## Configuration
|
49
|
+
```ruby
|
50
|
+
TwitterRetry.configure do |config|
|
51
|
+
config.sleep_second = 1
|
52
|
+
config.max_retry_count = 3
|
53
|
+
config.retryable_errors << [Twitter::Error, "some error message"]
|
54
|
+
config.ignorable_errors << [Twitter::Error, "some error message"]
|
55
|
+
end
|
56
|
+
```
|
57
|
+
|
58
|
+
## Development
|
59
|
+
|
60
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
61
|
+
|
62
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
63
|
+
|
64
|
+
## Contributing
|
65
|
+
|
66
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/sue445/twitter_retry.
|
67
|
+
|
68
|
+
|
69
|
+
## License
|
70
|
+
|
71
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
72
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "twitter_retry"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "twitter"
|
2
|
+
require "twitter_retry/version"
|
3
|
+
require "twitter_retry/config"
|
4
|
+
require "twitter_retry/retryable"
|
5
|
+
|
6
|
+
module TwitterRetry
|
7
|
+
extend Retryable
|
8
|
+
|
9
|
+
def self.config
|
10
|
+
@config ||= Config.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.configure
|
14
|
+
yield config if block_given?
|
15
|
+
end
|
16
|
+
|
17
|
+
class BaseError < ::StandardError; end
|
18
|
+
|
19
|
+
class SuspendedError < BaseError; end
|
20
|
+
|
21
|
+
class RetryOverError < BaseError; end
|
22
|
+
|
23
|
+
class CannotRetryableError < BaseError; end
|
24
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module TwitterRetry
|
2
|
+
require "active_support/configurable"
|
3
|
+
|
4
|
+
DEFAULT_RETRYABLE_ERRORS = [
|
5
|
+
[Twitter::Error::ServiceUnavailable, "Over capacity"],
|
6
|
+
[Twitter::Error::InternalServerError, "Internal error"],
|
7
|
+
[Twitter::Error, "getaddrinfo: Name or service not known"],
|
8
|
+
]
|
9
|
+
|
10
|
+
DEFAULT_IGNORABLE_ERRORS = [
|
11
|
+
[Twitter::Error::Forbidden, "Status is a duplicate."],
|
12
|
+
[Twitter::Error::Forbidden, "User is over daily status update limit."],
|
13
|
+
[Twitter::Error::Forbidden, "This request looks like it might be automated."],
|
14
|
+
]
|
15
|
+
|
16
|
+
class Config
|
17
|
+
include ActiveSupport::Configurable
|
18
|
+
|
19
|
+
config_accessor :max_retry_count, :sleep_second
|
20
|
+
config_accessor :retryable_errors, :ignorable_errors
|
21
|
+
|
22
|
+
configure do |config|
|
23
|
+
config.max_retry_count = 3
|
24
|
+
config.sleep_second = 1
|
25
|
+
config.retryable_errors = DEFAULT_RETRYABLE_ERRORS
|
26
|
+
config.ignorable_errors = DEFAULT_IGNORABLE_ERRORS
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module TwitterRetry
|
2
|
+
module Retryable
|
3
|
+
# retry when error occurred matched with {#RETRYABLE_ERRORS}
|
4
|
+
# @return [true] successful
|
5
|
+
# @return [false] error is ignored (ex. {Twitter::Error::Forbidden})
|
6
|
+
# @raise [SuspendedError]
|
7
|
+
# @raise [RetryOverError] retried {TwitterRetry::TwitterRetry#max_retry_count} count, but all failure
|
8
|
+
# @raise [CannotRetryableError]
|
9
|
+
def with_handing
|
10
|
+
retry_count = 0
|
11
|
+
|
12
|
+
begin
|
13
|
+
yield
|
14
|
+
|
15
|
+
rescue => error
|
16
|
+
return false if ignorable?(error)
|
17
|
+
raise SuspendedError if suspended?(error)
|
18
|
+
raise CannotRetryableError unless retryable?(error)
|
19
|
+
raise RetryOverError unless retry_count < TwitterRetry.config.max_retry_count
|
20
|
+
|
21
|
+
retry_count += 1
|
22
|
+
sleep(TwitterRetry.config.sleep_second)
|
23
|
+
retry
|
24
|
+
end
|
25
|
+
|
26
|
+
# successful
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
# whether retryable error
|
31
|
+
# @param error [Exception]
|
32
|
+
def retryable?(error)
|
33
|
+
TwitterRetry.config.retryable_errors.any? do |error_class, message|
|
34
|
+
error.is_a?(error_class) && error.message.include?(message)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# whether ignorable error
|
39
|
+
# @param error [Exception]
|
40
|
+
def ignorable?(error)
|
41
|
+
TwitterRetry.config.ignorable_errors.any? do |error_class, message|
|
42
|
+
error.is_a?(error_class) && error.message.include?(message)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# whether suspended user error
|
47
|
+
def suspended?(error)
|
48
|
+
error.is_a?(Twitter::Error::Forbidden) &&
|
49
|
+
error.message.include?("Your account is suspended and is not permitted to access this feature.")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "twitter_retry/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "twitter_retry"
|
8
|
+
spec.version = TwitterRetry::VERSION
|
9
|
+
spec.authors = ["sue445"]
|
10
|
+
spec.email = ["sue445@sue445.net"]
|
11
|
+
|
12
|
+
spec.summary = "Twitter api awesome handling with retry"
|
13
|
+
spec.description = "Twitter api awesome handling with retry"
|
14
|
+
spec.homepage = "https://github.com/sue445/twitter_retry"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "activesupport"
|
23
|
+
spec.add_dependency "twitter"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
26
|
+
spec.add_development_dependency "coveralls"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rspec"
|
29
|
+
spec.add_development_dependency "rspec-parameterized"
|
30
|
+
spec.add_development_dependency "rubocop", "0.31.0"
|
31
|
+
spec.add_development_dependency "yard"
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: twitter_retry
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.beta1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- sue445
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: twitter
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.10'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: coveralls
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec-parameterized
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.31.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.31.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: yard
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: Twitter api awesome handling with retry
|
140
|
+
email:
|
141
|
+
- sue445@sue445.net
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".coveralls.yml"
|
147
|
+
- ".gitignore"
|
148
|
+
- ".hound.yml"
|
149
|
+
- ".rspec"
|
150
|
+
- ".rubocop.yml"
|
151
|
+
- ".rubocop_standard.yml"
|
152
|
+
- ".travis.yml"
|
153
|
+
- ".yardopts"
|
154
|
+
- Gemfile
|
155
|
+
- LICENSE.txt
|
156
|
+
- README.md
|
157
|
+
- Rakefile
|
158
|
+
- bin/console
|
159
|
+
- bin/setup
|
160
|
+
- lib/twitter_retry.rb
|
161
|
+
- lib/twitter_retry/config.rb
|
162
|
+
- lib/twitter_retry/retryable.rb
|
163
|
+
- lib/twitter_retry/version.rb
|
164
|
+
- twitter_retry.gemspec
|
165
|
+
homepage: https://github.com/sue445/twitter_retry
|
166
|
+
licenses:
|
167
|
+
- MIT
|
168
|
+
metadata: {}
|
169
|
+
post_install_message:
|
170
|
+
rdoc_options: []
|
171
|
+
require_paths:
|
172
|
+
- lib
|
173
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - ">="
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
178
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - ">"
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: 1.3.1
|
183
|
+
requirements: []
|
184
|
+
rubyforge_project:
|
185
|
+
rubygems_version: 2.4.5
|
186
|
+
signing_key:
|
187
|
+
specification_version: 4
|
188
|
+
summary: Twitter api awesome handling with retry
|
189
|
+
test_files: []
|
190
|
+
has_rdoc:
|