goodcheck 3.0.0 → 3.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
  SHA256:
3
- metadata.gz: fa64d7f536fc7b357fbae7aa685827211236015ff9203bc7291847705e4a8189
4
- data.tar.gz: bf23ca5741b3e424d064d45b9e16ccc28fbf53d299d8a4966ce7a5566c277a0f
3
+ metadata.gz: 9ccb42f8ae06c1c3f78fc6361de1e3074a3ea1ebf8ec1fc6216d4f076531e4fe
4
+ data.tar.gz: f46bde84176b92dffa679e50536221f52d1efe54a2bf6a583533a14fd8404bfb
5
5
  SHA512:
6
- metadata.gz: d184c5e83feb1b656afdbb2aa71c724b33c584a674de2def35201bbd8a66275b5c2a45b466c477aee38689f53dc6e39a0ee4183a6ad61b3ba587485eeb7f3d89
7
- data.tar.gz: 215b0532befa04bdbbdbb0ac24be805fde46ebe51bafda8d6193df1c3a183fbf0faad0495454b9dcfe6dec27015f817b5b52f99b4fa26936f57ac491fa923bf5
6
+ metadata.gz: 717e2a137f03c9b436e7ef9f88ad6c5f9d8ec33989a929cb69e327aabf09e83fdfe1565607c669928d7e3b3306cde434ab59c64ff741840c840263980856d8cd
7
+ data.tar.gz: c7041cb4c9d9c4b1926776a98a8c55ec59496169fdeedd8ac4277c37950d579cdb6cfa50cc9dd6215c31baa2c85cd3b9a513495ec2f82dc705696a05ef13af4b
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## HEAD
4
4
 
5
+ ## 3.0.1 (2021-06-14)
6
+
7
+ * Retry HTTP GET request on importing rules [#197](https://github.com/sider/goodcheck/pull/197)
8
+
5
9
  ## 3.0.0 (2021-06-14)
6
10
 
7
11
  Breaking changes:
data/README.md CHANGED
@@ -42,7 +42,7 @@ To release a new version, follows the steps below:
42
42
  3. Update the documentation via `bundle exec rake docs:update_version`.
43
43
  4. Commit the above changes like `git commit -m 'Version 1.2.3'`.
44
44
  5. 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).
45
- 6. Publish the updated documentation like `GIT_USER=some_user USE_SSH=true bundle exec rake docs:publish`.
45
+ 6. Publish the updated documentation like `GIT_USER=some_user [USE_SSH=true] bundle exec rake docs:publish`.
46
46
 
47
47
  ## Contributing
48
48
 
@@ -1,8 +1,5 @@
1
1
  module Goodcheck
2
2
  class Buffer
3
- attr_reader :path
4
- attr_reader :content
5
-
6
3
  DISABLE_LINE_PATTERNS = [
7
4
  /\/\/ goodcheck-disable-line$/, #JS, Java, C, ...
8
5
  /# goodcheck-disable-line$/, # Ruby, Python, PHP, ...
@@ -25,10 +22,8 @@ module Goodcheck
25
22
  /' goodcheck-disable-next-line$/, # VB
26
23
  ].freeze
27
24
 
28
- class << self
29
- attr_accessor :DISABLE_LINE_PATTERNS
30
- attr_accessor :DISABLE_NEXT_LINE_PATTERNS
31
- end
25
+ attr_reader :path
26
+ attr_reader :content
32
27
 
33
28
  def initialize(path:, content:)
34
29
  @path = path
@@ -18,6 +18,19 @@ module Goodcheck
18
18
  end
19
19
  end
20
20
 
21
+ class HTTPGetError < Error
22
+ attr_reader :response
23
+
24
+ def initialize(res)
25
+ super("HTTP GET #{res.uri} => #{res.code} #{res.message}")
26
+ @response = res
27
+ end
28
+
29
+ def error_response?
30
+ response.is_a?(Net::HTTPClientError) || response.is_a?(Net::HTTPServerError)
31
+ end
32
+ end
33
+
21
34
  attr_reader :cache_path
22
35
  attr_reader :expires_in
23
36
  attr_reader :force_download
@@ -122,15 +135,28 @@ module Goodcheck
122
135
  def http_get(uri, limit = 10)
123
136
  raise ArgumentError, "Too many HTTP redirects" if limit == 0
124
137
 
125
- res = Net::HTTP.get_response URI(uri)
126
- case res
127
- when Net::HTTPSuccess
128
- res.body
129
- when Net::HTTPRedirection
130
- location = res['Location']
131
- http_get location, limit - 1
132
- else
133
- raise "Error: HTTP GET #{uri.inspect} #{res.inspect}"
138
+ max_retry_count = 2
139
+ retry_count = 0
140
+ begin
141
+ res = Net::HTTP.get_response URI(uri)
142
+ case res
143
+ when Net::HTTPSuccess
144
+ res.body
145
+ when Net::HTTPRedirection
146
+ location = res['Location']
147
+ http_get location, limit - 1
148
+ else
149
+ raise HTTPGetError.new(res)
150
+ end
151
+ rescue HTTPGetError => exn
152
+ if retry_count < max_retry_count && exn.error_response?
153
+ retry_count += 1
154
+ Goodcheck.logger.info "#{retry_count} retry HTTP GET #{exn.response.uri} due to '#{exn.response.code} #{exn.response.message}'..."
155
+ sleep 1
156
+ retry
157
+ else
158
+ raise
159
+ end
134
160
  end
135
161
  end
136
162
 
@@ -1,3 +1,3 @@
1
1
  module Goodcheck
2
- VERSION = "3.0.0".freeze
2
+ VERSION = "3.0.1".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goodcheck
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sider Corporation