go_transit 0.8.0 → 0.9.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
  SHA256:
3
- metadata.gz: 75a803314654232e17915c91c0af5859985172cbeb8c7851377d4e3128bbabc9
4
- data.tar.gz: '09fbe1f8b08c6ea2d00e5a0c212fda686196a7a00bb4c3fd826d6f7732702acc'
3
+ metadata.gz: 54aad8332d8b5bc0889179609017fe97dfb81ebbf10b6c5e260d710baa469cc0
4
+ data.tar.gz: 1f51df5e8755eabfb6d9add2d32df843ce0218b4bcf8f2862afce5671060bff1
5
5
  SHA512:
6
- metadata.gz: d686899e0198bcc3c32d8d38de9fa4f399d25da29b71dd491bde54b6e9c6cada64ea1afd8f2da6fb8aa293ff5172964378da32ba11f49f73bce6a269d57c0344
7
- data.tar.gz: 9e86b72905dcd6c23460669a6d0dbd59df940ef94ea2a858a3300fe3e3bb56f8e0f4d2bf08e65ab6c19b74f427205ad06ff6994817e6263cbfbc75ef466c48da
6
+ metadata.gz: a7178548ace998be435aa218dde735ed46fac843e5a8124e478b58887bbe9fb9e0cb28bf87785d572f0bb99ef0856a94237fbed5f731247ce3a58dd44a0c3d35
7
+ data.tar.gz: acb8c58c71027454a2df4b3245aa7aa105dffb9c7a1e962b43722989914e313c823f25fea42a85177fb3e154132e555971e6dbd77df4c6f2a11008d0fddbed3f
@@ -3,11 +3,11 @@ require "net/http"
3
3
 
4
4
  module GoTransit
5
5
  class Client
6
- BASE_URL = "http://api.openmetrolinx.com/OpenDataAPI/api".freeze
7
6
  API_VERSION = "V1".freeze
8
7
 
9
8
  def get(path)
10
- uri = URI("#{BASE_URL}/#{API_VERSION}/#{path}?key=#{GoTransit.api_key}")
9
+ uri = URI("#{GoTransit.base_url}/#{API_VERSION}/#{path}"\
10
+ "?key=#{GoTransit.api_key}")
11
11
  response = Net::HTTP.get_response(uri)
12
12
  json = JSON.parse(response.body)
13
13
  Response.new(json)
@@ -6,8 +6,8 @@ module GoTransit
6
6
  end
7
7
 
8
8
  NoContentError = Class.new(ApiError)
9
- BadRequestError = Class.new(StandardError)
10
- UnauthorizedError = Class.new(StandardError)
11
- ForbiddenError = Class.new(StandardError)
12
- NotFoundError = Class.new(StandardError)
9
+ BadRequestError = Class.new(ApiError)
10
+ UnauthorizedError = Class.new(ApiError)
11
+ ForbiddenError = Class.new(ApiError)
12
+ NotFoundError = Class.new(ApiError)
13
13
  end
@@ -2,6 +2,10 @@ module GoTransit
2
2
  class Metadata < ApiResource
3
3
  attr_accessor :time_stamp, :error_code, :error_message
4
4
 
5
+ def to_s
6
+ "#{error_code} - #{error_message}"
7
+ end
8
+
5
9
  def code
6
10
  error_code.to_i
7
11
  end
@@ -1,3 +1,3 @@
1
1
  module GoTransit
2
- VERSION = "0.8.0".freeze
2
+ VERSION = "0.9.0".freeze
3
3
  end
data/lib/go_transit.rb CHANGED
@@ -62,6 +62,14 @@ module GoTransit
62
62
  @api_key = ""
63
63
 
64
64
  class << self
65
- attr_accessor :api_key
65
+ attr_accessor :api_key, :custom_base_url
66
+
67
+ def configure
68
+ yield self
69
+ end
70
+
71
+ def base_url
72
+ custom_base_url || "http://api.openmetrolinx.com/OpenDataAPI/api"
73
+ end
66
74
  end
67
75
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: go_transit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Mazur
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-18 00:00:00.000000000 Z
11
+ date: 2023-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "<="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 7.0.8
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "<="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 7.0.8
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement