twitter_retry 0.1.0 → 0.2.0

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: 0a52f9cf9e286f7d0fc9a4ae895116c0418efacb
4
- data.tar.gz: 038b5a727684f0b990c49043320382e173cab72b
3
+ metadata.gz: ff0eab75ac0dbd4ea33d5f2eb2840ef01e617b6f
4
+ data.tar.gz: 2c3dab70979cb3fecb5a4d81360b925ccf532efd
5
5
  SHA512:
6
- metadata.gz: 2506d6e93b4fd3ec4c57e3e7d1e76916d0b951022d260607ba2689056783958ebe846116e6f03efd30023fb982faa1613e61784f863ebdcbcbd447c8b0fe5fe9
7
- data.tar.gz: 4c8b0f4b4ab43640879aca7e51578d6bb2a37901cecb226b0524ceb9e43f5ebf473c3bdf67e4d68f18eda786ef9c95f0ef29f5346273455be70c6634eea1c283
6
+ metadata.gz: 53971d3ac57744fbc9ccaadae99a6ed109ed6ce1ce2317a317cbc734c8855003520af22bee0010a4f8e6203e948daecef4c311a7623a80bdd94652a42f54ae92
7
+ data.tar.gz: 3ee9a129f5c78ed08b0b6dca148ffb6dea9b7093c2eb34dd0840fd60a523aea50bc56b12ea0baed74cc0c093703a5efc4bf734ce81ac234abf572088f43d50bc
@@ -2,6 +2,8 @@ language: ruby
2
2
  rvm:
3
3
  - 2.1
4
4
  - 2.2
5
+ - 2.3.3
6
+ - 2.4.0
5
7
  - ruby-head
6
8
  before_install: gem install bundler -v 1.10.5
7
9
  before_script:
@@ -0,0 +1,13 @@
1
+ ## Unreleased
2
+ [full changelog](https://github.com/sue445/twitter_retry/compare/v0.2.0...master)
3
+
4
+ ## v0.2.0
5
+ [full changelog](https://github.com/sue445/twitter_retry/compare/v0.1.0...v0.2.0)
6
+
7
+ * Support regexp pattern on `retryable_errors?` and `ignorable_errors?`
8
+ * https://github.com/sue445/twitter_retry/pull/9
9
+ * Support: check only error class
10
+ * https://github.com/sue445/twitter_retry/pull/11
11
+
12
+ ## v0.1.0
13
+ * first release
data/Gemfile CHANGED
@@ -2,3 +2,8 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in twitter_retry.gemspec
4
4
  gemspec
5
+
6
+ if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.2.2")
7
+ # NOTE: activesupport 5.x supports only ruby 2.2.2+
8
+ gem "activesupport", "< 5.0.0"
9
+ end
data/README.md CHANGED
@@ -2,11 +2,15 @@
2
2
 
3
3
  Twitter api awesome handling with retry
4
4
 
5
+ [![Gem Version](https://badge.fury.io/rb/twitter_retry.svg)](http://badge.fury.io/rb/twitter_retry)
5
6
  [![Build Status](https://travis-ci.org/sue445/twitter_retry.svg?branch=master)](https://travis-ci.org/sue445/twitter_retry)
6
7
  [![Code Climate](https://codeclimate.com/github/sue445/twitter_retry/badges/gpa.svg)](https://codeclimate.com/github/sue445/twitter_retry)
7
8
  [![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
9
  [![Dependency Status](https://gemnasium.com/sue445/twitter_retry.svg)](https://gemnasium.com/sue445/twitter_retry)
9
10
 
11
+ ## Requirements
12
+ * Ruby 2.1+
13
+
10
14
  ## Installation
11
15
 
12
16
  Add this line to your application's Gemfile:
@@ -52,6 +56,12 @@ TwitterRetry.configure do |config|
52
56
  config.max_retry_count = 3
53
57
  config.retryable_errors << [Twitter::Error, "some error message"]
54
58
  config.ignorable_errors << [Twitter::Error, "some error message"]
59
+
60
+ # Check whether error message matched with regexp
61
+ config.retryable_errors << [Twitter::Error::ServiceUnavailable, /something/]
62
+
63
+ # Check whether only error class matches (error message can be anything)
64
+ config.ignorable_errors << [Twitter::Error::ServiceUnavailable]
55
65
  end
56
66
  ```
57
67
 
@@ -30,17 +30,13 @@ module TwitterRetry
30
30
  # whether retryable error
31
31
  # @param error [Exception]
32
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
33
+ match_any_error?(error, TwitterRetry.config.retryable_errors)
36
34
  end
37
35
 
38
36
  # whether ignorable error
39
37
  # @param error [Exception]
40
38
  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
39
+ match_any_error?(error, TwitterRetry.config.ignorable_errors)
44
40
  end
45
41
 
46
42
  # whether suspended user error
@@ -48,5 +44,26 @@ module TwitterRetry
48
44
  error.is_a?(Twitter::Error::Forbidden) &&
49
45
  error.message.include?("Your account is suspended and is not permitted to access this feature.")
50
46
  end
47
+
48
+ private
49
+
50
+ def match_any_error?(source_error, check_errors)
51
+ check_errors.any? do |error_class, message|
52
+ match_error?(source_error, error_class, message)
53
+ end
54
+ end
55
+
56
+ def match_error?(source_error, error_class, message)
57
+ return false unless source_error.is_a?(error_class)
58
+
59
+ # Check only error class
60
+ return true unless message
61
+
62
+ if message.is_a?(Regexp)
63
+ source_error.message =~ message
64
+ else
65
+ source_error.message.include?(message)
66
+ end
67
+ end
51
68
  end
52
69
  end
@@ -1,3 +1,3 @@
1
1
  module TwitterRetry
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -27,6 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "rake", "~> 10.0"
28
28
  spec.add_development_dependency "rspec"
29
29
  spec.add_development_dependency "rspec-parameterized"
30
- spec.add_development_dependency "rubocop", "0.31.0"
31
30
  spec.add_development_dependency "yard"
32
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter_retry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sue445
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-19 00:00:00.000000000 Z
11
+ date: 2017-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -108,20 +108,6 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
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
111
  - !ruby/object:Gem::Dependency
126
112
  name: yard
127
113
  requirement: !ruby/object:Gem::Requirement
@@ -145,12 +131,10 @@ extra_rdoc_files: []
145
131
  files:
146
132
  - ".coveralls.yml"
147
133
  - ".gitignore"
148
- - ".hound.yml"
149
134
  - ".rspec"
150
- - ".rubocop.yml"
151
- - ".rubocop_standard.yml"
152
135
  - ".travis.yml"
153
136
  - ".yardopts"
137
+ - CHANGELOG.md
154
138
  - Gemfile
155
139
  - LICENSE.txt
156
140
  - README.md
@@ -182,9 +166,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
166
  version: '0'
183
167
  requirements: []
184
168
  rubyforge_project:
185
- rubygems_version: 2.4.5
169
+ rubygems_version: 2.6.11
186
170
  signing_key:
187
171
  specification_version: 4
188
172
  summary: Twitter api awesome handling with retry
189
173
  test_files: []
190
- has_rdoc:
data/.hound.yml DELETED
@@ -1,3 +0,0 @@
1
- ruby:
2
- enabled: true
3
- config_file: .rubocop.yml
@@ -1 +0,0 @@
1
- inherit_from: .rubocop_standard.yml
@@ -1,196 +0,0 @@
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
-