scnnr 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1cec0a043ac50cceb01a1e2e0cea9f38db142653
4
- data.tar.gz: 5bdc4a14a1e77bcac1e5e8e2b712f99571581372
2
+ SHA256:
3
+ metadata.gz: 235c38c591c2c703be24918f4036a1a5164682190757d79c5be8288bf293728f
4
+ data.tar.gz: 18f5a090fe68f2dc4d7e70529a3045085891ea12e3e8ad4dbf92e13c8db0eae0
5
5
  SHA512:
6
- metadata.gz: 4fcde62832a6b3c1417ae828738940d0b595034475b4c4b669ab8aacb5970036a1b625dad9f8422b2bbeea0f1f8dfe7451be33f0d2949d747f8bc6d397c56219
7
- data.tar.gz: 3c0641f3d67462a5f01b701539c5f7ac5582d8a5d33f005135e5997c6f74a2445d0f9efe735f940bbbdbf5727f2e7dff4825c2659a0195495c3a70898e33c01d
6
+ metadata.gz: 3533faddd548618a744923f3790cd8cc6f46fa3fd73e0bb1b28bc45bd4df94940b187b025ba51e43332080976b3172c06fc44c8140a5e14c7352b15783c4c835
7
+ data.tar.gz: 345aaeb08008708d78cf2ab8b473f04d6261d227c1f2ec54e6e6a5e27b909179f906feec1644139b14d319f96649e5c63866b216934d3f0dc5f11fa1571ebb9d
data/.circleci/config.yml CHANGED
@@ -30,17 +30,27 @@ jobs:
30
30
  - store_artifacts:
31
31
  path: /tmp/test-results
32
32
  destination: test-results
33
- ruby-2.3.5:
33
+ ruby-2.3:
34
34
  <<: *build
35
35
  docker:
36
- - image: circleci/ruby:2.3.5-node-browsers
37
- ruby-2.4.1:
36
+ - image: circleci/ruby:2.3
37
+ ruby-2.4:
38
38
  <<: *build
39
39
  docker:
40
- - image: circleci/ruby:2.4.1-node-browsers
40
+ - image: circleci/ruby:2.4
41
+ ruby-2.5:
42
+ <<: *build
43
+ docker:
44
+ - image: circleci/ruby:2.5
45
+ ruby-2.6:
46
+ <<: *build
47
+ docker:
48
+ - image: circleci/ruby:2.6
41
49
  workflows:
42
50
  version: 2
43
51
  ruby-multi-build:
44
52
  jobs:
45
- - ruby-2.3.5
46
- - ruby-2.4.1
53
+ - ruby-2.3
54
+ - ruby-2.4
55
+ - ruby-2.5
56
+ - ruby-2.6
data/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.3.0] - 2019-08-30
8
+ ### Added
9
+ - Support a retrying feature on `Scnnr::Connection`.
10
+ - Start supporting Ruby 2.5 and 2.6.
11
+
7
12
  ## [1.2.0] - 2018-10-11
8
13
  ### Added
9
14
  - Support `target` parameter for `Scnnr::Client#coordinate`.
data/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # Official #CBK scnnr client library for Ruby.
2
+ [![CircleCI](https://circleci.com/gh/NEWROPE/scnnr-ruby.svg?style=svg)](https://circleci.com/gh/NEWROPE/scnnr-ruby)
2
3
 
3
4
  - [#CBK scnnr](https://scnnr.cubki.jp/)
4
5
  - [API Documentation](https://api.scnnr.cubki.jp/v1/docs)
5
6
 
7
+ ## Supported Ruby versions
8
+ - Ruby 2.3+
9
+
6
10
  ## Installation
7
11
 
8
12
  ### Bundler
@@ -5,6 +5,15 @@ module Scnnr
5
5
  require 'net/http'
6
6
  require 'json'
7
7
 
8
+ RETRY_LIMIT = 3
9
+ RETRY_SLEEP_TIME = 1
10
+ RETRY_ERROR_CLASSES = [
11
+ Timeout::Error, Errno::EINVAL,
12
+ Errno::ECONNRESET, EOFError,
13
+ Net::HTTPBadResponse, Net::ProtocolError,
14
+ Net::HTTPHeaderSyntaxError
15
+ ].freeze
16
+
8
17
  def initialize(uri, method, api_key, logger)
9
18
  @uri = uri
10
19
  @method = method
@@ -31,16 +40,30 @@ module Scnnr
31
40
  def send_request
32
41
  block = block_given? ? Proc.new : nil
33
42
  request = build_request(&block)
34
- run_request(request)
43
+ with_retries do
44
+ Net::HTTP.start(@uri.host, @uri.port, use_ssl: use_ssl?) do |http|
45
+ @logger&.info("Started #{@method.upcase} #{@uri}")
46
+ http.request(request)
47
+ end
48
+ end
35
49
  end
36
50
 
37
51
  private
38
52
 
39
- def run_request(request)
40
- Net::HTTP.start(@uri.host, @uri.port, use_ssl: use_ssl?) do |http|
41
- @logger&.info("Started #{@method.upcase} #{@uri}")
42
- http.request(request)
53
+ def with_retries
54
+ yield
55
+ rescue *RETRY_ERROR_CLASSES => e
56
+ retry_count ||= 0
57
+
58
+ if retry_count < RETRY_LIMIT
59
+ retry_count += 1
60
+ @logger&.info("Retrying to connect: #{@uri}, attempt: #{retry_count}")
61
+
62
+ sleep RETRY_SLEEP_TIME
63
+ retry
43
64
  end
65
+
66
+ raise e.class, "#{e.message} (Endpoint: #{@method.upcase} #{@uri})"
44
67
  end
45
68
 
46
69
  def use_ssl?
data/lib/scnnr/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Scnnr
4
- VERSION = '1.2.0'
4
+ VERSION = '1.3.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scnnr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - NEWROPE Co. Ltd.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-11 00:00:00.000000000 Z
11
+ date: 2019-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -82,8 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  requirements: []
85
- rubyforge_project:
86
- rubygems_version: 2.6.13
85
+ rubygems_version: 3.0.3
87
86
  signing_key:
88
87
  specification_version: 4
89
88
  summary: ''