travel_time 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/travel_time/client.rb +14 -3
- data/lib/travel_time/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d61024c00091bdbbf0036dcb0f0b3cbc13dfdf0f0690aa847cd2720ba9d7866
|
4
|
+
data.tar.gz: b7eb9f385d345cb2d115e34a37b85e6128730f3b87ca6ee6f34e79988b93236d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16b1444ca180d2a151794b3eacc38d7f88b7873cb1c7c83446d53e19bee5b7b9ce4bf502075fd8f9215489a8132d6296288ecbe85e14ffad48f74ac10e3cd999
|
7
|
+
data.tar.gz: 9f670c473b8536204514f9f638e4cd654eeab197224f46c0a91552a6852d6a9ff35dcdf620220f07b7afbd915ac536c60a5fcfa87ebe45c657ad1f38323e56dd
|
data/README.md
CHANGED
@@ -68,6 +68,14 @@ departure_search = {
|
|
68
68
|
client.time_map(departure_searches: [departure_search])
|
69
69
|
```
|
70
70
|
|
71
|
+
### Rate Limiting
|
72
|
+
|
73
|
+
You may specify an optional rate limit when initializing your client. The `rate_limit` parameter sets a cap on the number of requests that can be made to the API in 60 seconds. Requests are balanced at equal intervals.
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
client = TravelTime::Client.new(rate_limit = 60)
|
77
|
+
```
|
78
|
+
|
71
79
|
### [Isochrones (Time Map)](https://traveltime.com/docs/api/reference/isochrones)
|
72
80
|
Given origin coordinates, find shapes of zones reachable within corresponding travel time.
|
73
81
|
Find unions/intersections between different searches.
|
data/lib/travel_time/client.rb
CHANGED
@@ -3,15 +3,28 @@
|
|
3
3
|
require 'faraday'
|
4
4
|
require 'travel_time/middleware/authentication'
|
5
5
|
require 'travel_time/middleware/proto'
|
6
|
+
require 'limiter'
|
6
7
|
|
7
8
|
module TravelTime
|
8
9
|
# The Client class provides the main interface to interact with the TravelTime API
|
9
10
|
class Client # rubocop:disable Metrics/ClassLength
|
11
|
+
extend Limiter::Mixin
|
10
12
|
API_BASE_URL = 'https://api.traveltimeapp.com/v4/'
|
11
13
|
|
12
14
|
attr_reader :connection, :proto_connection
|
13
15
|
|
14
|
-
def initialize
|
16
|
+
def initialize(rate_limit = nil)
|
17
|
+
init_connection
|
18
|
+
init_proto_connection
|
19
|
+
|
20
|
+
return unless rate_limit
|
21
|
+
|
22
|
+
%i[perform_request perform_request_proto].each do |method_name|
|
23
|
+
self.class.limit_method method_name, balanced: true, rate: rate_limit
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def init_connection
|
15
28
|
@connection = Faraday.new(API_BASE_URL) do |f|
|
16
29
|
f.request :json
|
17
30
|
f.response :raise_error if TravelTime.config.raise_on_failure
|
@@ -20,8 +33,6 @@ module TravelTime
|
|
20
33
|
f.use TravelTime::Middleware::Authentication
|
21
34
|
f.adapter TravelTime.config.http_adapter || Faraday.default_adapter
|
22
35
|
end
|
23
|
-
|
24
|
-
init_proto_connection
|
25
36
|
end
|
26
37
|
|
27
38
|
def init_proto_connection
|
data/lib/travel_time/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: travel_time
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TravelTime Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03
|
11
|
+
date: 2023-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|
@@ -64,6 +64,20 @@ dependencies:
|
|
64
64
|
- - "<"
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: 3.21.9
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: ruby-limiter
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 2.2.2
|
74
|
+
type: :runtime
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 2.2.2
|
67
81
|
description: TravelTime SDK for Ruby programming language
|
68
82
|
email:
|
69
83
|
- support@traveltime.com
|