freight_kit 0.1.3 → 0.1.5

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: 6580f865ed67b79e9b6c426bd519af397ff527725b8d48e74a489b42ad3bb793
4
- data.tar.gz: 98b55c646d50f715d79a63ba7e0defe0a2b53d74f5d872064931b506327c0f6d
3
+ metadata.gz: 237b94cd7a42c8029f175485fa40e4f88d0b09084ab28be9e8af446fafa496d7
4
+ data.tar.gz: 8563b82c4bb782d3ec16002d8bb07684a30a509f98642307f3f314cbdbd78a48
5
5
  SHA512:
6
- metadata.gz: 1fad0c913388a085bd5d94231bc5ca1d68aaeef57a251d05a43506ef863404442fd19d7113235a78a4b556a16a0dde83070b8d5cc094d0fb07e0873810f2b4f6
7
- data.tar.gz: 6637da5a16e09322598cff6e4cdeb9ef6c30b45f794504ac348d05dfee0b81e68e3c305a1975554c2c6ab7d131edc863507be0d885c850f2131fe35cb3fc057a
6
+ metadata.gz: a5e6e4779b45b05d7bdd490f5dedbe3d4545b1fd42838819273a4a1eaf37daa8a0dcf6c9c798b6c3f283965dc02d8ba71f7d0808e7bb737f6db24df5367d35fc
7
+ data.tar.gz: 8e9f732d32d0009d045ce729809baf45b6761836a77a05ea57a089c5e171c37f8a073d5bcb79ec0ff8a5ca2ccb08de397b67d1822a1e9e9f14ca21cd8f5b3c59
data/Gemfile.lock CHANGED
@@ -1,18 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- freight_kit (0.1.2)
4
+ freight_kit (0.1.4)
5
5
  active_utils (>= 3.3.1, < 3.5.0)
6
- activemodel (>= 4.2, < 7.1.3)
6
+ activemodel (>= 4.2, < 7.1.4)
7
7
  activesupport (>= 4.2, < 7.1.4)
8
8
  httparty (~> 0.10)
9
9
  measured (>= 2.0, < 2.8.3)
10
10
  mimemagic (~> 0.4.3)
11
11
  nokogiri (>= 1.6, < 1.17)
12
- place_kit (~> 0.0.1)
13
- savon (>= 2.0, < 2.15)
12
+ place_kit (~> 0.0.2)
13
+ savon (>= 2.0, < 2.16)
14
14
  tzinfo-data (~> 1.2023, >= 1.2023.3)
15
- watir (>= 7.0, < 7.2)
15
+ watir (>= 7.0, < 7.4)
16
+ zeitwerk (>= 2.6.0, < 2.6.14)
16
17
 
17
18
  GEM
18
19
  remote: https://rubygems.org/
@@ -73,8 +74,8 @@ GEM
73
74
  parser (3.2.2.3)
74
75
  ast (~> 2.4.1)
75
76
  racc
76
- place_kit (0.0.1)
77
- activesupport (>= 6.0.0, < 7.1)
77
+ place_kit (0.0.2)
78
+ activesupport (>= 6.0.0, < 7.2)
78
79
  fastcsv (~> 0.0.6)
79
80
  public_suffix (5.0.3)
80
81
  racc (1.7.1)
@@ -82,7 +83,7 @@ GEM
82
83
  rainbow (3.1.1)
83
84
  rake (13.1.0)
84
85
  redcarpet (3.6.0)
85
- regexp_parser (2.8.1)
86
+ regexp_parser (2.9.0)
86
87
  rexml (3.2.6)
87
88
  rspec (3.12.0)
88
89
  rspec-core (~> 3.12.0)
@@ -146,7 +147,7 @@ GEM
146
147
  nokogiri (>= 1.8.1)
147
148
  nori (~> 2.4)
148
149
  wasabi (~> 3.4)
149
- selenium-webdriver (4.12.0)
150
+ selenium-webdriver (4.16.0)
150
151
  rexml (~> 3.2, >= 3.2.5)
151
152
  rubyzip (>= 1.2.2, < 3.0)
152
153
  websocket (~> 1.0)
@@ -160,14 +161,16 @@ GEM
160
161
  addressable
161
162
  httpi (~> 2.0)
162
163
  nokogiri (>= 1.4.2)
163
- watir (7.1.0)
164
+ watir (7.3.0)
164
165
  regexp_parser (>= 1.2, < 3)
165
- selenium-webdriver (~> 4.0)
166
- websocket (1.2.9)
166
+ selenium-webdriver (~> 4.2)
167
+ websocket (1.2.10)
167
168
  yard (0.9.34)
169
+ zeitwerk (2.6.11)
168
170
 
169
171
  PLATFORMS
170
172
  arm64-darwin-22
173
+ arm64-darwin-23
171
174
 
172
175
  DEPENDENCIES
173
176
  business_time (~> 0.13.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.5
@@ -32,6 +32,8 @@
32
32
  :fitness_center_pickup
33
33
  :flatbed_delivery
34
34
  :flatbed_pickup
35
+ :gated_community_delivery
36
+ :gated_community_pickup
35
37
  :golf_course_delivery
36
38
  :golf_course_pickup
37
39
  :government_delivery
data/freight_kit.gemspec CHANGED
@@ -31,10 +31,9 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency('business_time', '~> 0.13.0')
32
32
  spec.add_development_dependency('faker', '~> 3.2.1')
33
33
  spec.add_development_dependency('rake', '~> 13.1.0')
34
+ spec.add_development_dependency('redcarpet', '~> 3.6.0') # for yard
34
35
  spec.add_development_dependency('rspec', '~> 3.12')
35
36
  spec.add_development_dependency('rubocop-next', '~> 1.0.3')
36
-
37
- spec.add_development_dependency('redcarpet', '~> 3.6.0') # for yard
38
37
  spec.add_development_dependency('yard', '~> 0.9.28')
39
38
 
40
39
  spec.add_dependency('activemodel', '>= 4.2', '< 7.1.4')
@@ -44,10 +43,11 @@ Gem::Specification.new do |spec|
44
43
  spec.add_dependency('measured', '>= 2.0', '< 2.8.3')
45
44
  spec.add_dependency('mimemagic', '~> 0.4.3')
46
45
  spec.add_dependency('nokogiri', '>= 1.6', '< 1.17')
47
- spec.add_dependency('place_kit', '~> 0.0.1')
48
- spec.add_dependency('savon', '>= 2.0', '< 2.15')
46
+ spec.add_dependency('place_kit', '~> 0.0.2')
47
+ spec.add_dependency('savon', '>= 2.0', '< 2.16')
49
48
  spec.add_dependency('tzinfo-data', '~> 1.2023', '>= 1.2023.3')
50
- spec.add_dependency('watir', '>= 7.0', '< 7.2')
49
+ spec.add_dependency('watir', '>= 7.0', '< 7.4')
50
+ spec.add_dependency('zeitwerk', '>= 2.6.0', '< 2.6.14')
51
51
 
52
52
  spec.required_ruby_version = '>= 3.2.0'
53
53
  end
@@ -98,8 +98,54 @@ module FreightKit
98
98
  def required_credential_types
99
99
  %i[api]
100
100
  end
101
+
102
+ # The template URL for tracking one of carrier's `NUMBERS` publicly. A template URL is a URL containing the token
103
+ # "%s" that can be replaced to generate a valid URL.
104
+ #
105
+ # This method is designed to provide a template URL for a specific tracking-related key, allowing applications to
106
+ # generate valid tracking URLs without involving FreightKit each time. The `key` parameter must be one of the
107
+ # predefined carrier number types specified in the `NUMBERS` constant.
108
+ #
109
+ # @see `NUMBERS`
110
+ # @param [Symbol] key The symbol representing the type of tracking information for which the template URL is
111
+ # needed.
112
+ # @raise [ArgumentError]
113
+ # @return [String, nil] The template URL or nil if no template is available for the given key.
114
+ def tracking_url_template(key)
115
+ raise ArgumentError, "key must be one of: #{NUMBERS.join(", ")}" if NUMBERS.exclude?(key)
116
+
117
+ "#{self}::#{key.to_s.upcase}_TRACKING_URL_TEMPLATE".constantize
118
+ end
119
+
120
+ # Regular expression to use for validating carrier's `NUMBERS`.
121
+ #
122
+ # Returns the regular expression used for validating the carrier's number based on the provided `key`.
123
+ # The `key` parameter must be one of the predefined carrier number types specified in the `NUMBERS` constant.
124
+ #
125
+ # @see `NUMBERS`
126
+ # @param [Symbol] key The symbol representing the carrier number type for which the regular expression is needed.
127
+ # @raise [ArgumentError] Raised if the provided key is not one of the specified carrier number types.
128
+ # @return [Regexp] The regular expression for validating the specified carrier number type.
129
+ def valid_number_regex(key)
130
+ raise ArgumentError, "key must be one of: #{NUMBERS.join(", ")}" if NUMBERS.exclude?(key)
131
+
132
+ "#{self}::VALID_#{key.to_s.upcase}_REGEX".constantize
133
+ end
101
134
  end
102
135
 
136
+ BOL_NUMBER_TRACKING_URL_TEMPLATE = nil
137
+ ORDER_NUMBER_TRACKING_URL_TEMPLATE = nil
138
+ PICKUP_NUMBER_TRACKING_URL_TEMPLATE = nil
139
+ PO_NUMBER_TRACKING_URL_TEMPLATE = nil
140
+ TRACKING_NUMBER_TRACKING_URL_TEMPLATE = nil
141
+ VALID_BOL_NUMBER_REGEX = nil
142
+ VALID_ORDER_NUMBER_REGEX = nil
143
+ VALID_PICKUP_NUMBER_REGEX = nil
144
+ VALID_PO_NUMBER_REGEX = nil
145
+ VALID_TRACKING_NUMBER_REGEX = nil
146
+
147
+ NUMBERS = %i[bol_number order_number pickup_number po_number tracking_number]
148
+
103
149
  attr_accessor :conf, :rates_with_excessive_length_fees, :tmpdir
104
150
  attr_reader :credentials, :customer_location, :last_request, :tariff
105
151
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FreightKit
4
- class Error < ActiveUtils::ActiveUtilsError; end
4
+ class Error < StandardError; end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FreightKit
4
- class DocumentNotFoundError < FreightKit::Error; end
4
+ class DocumentNotFoundError < Error; end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FreightKit
4
- class ExpiredCredentialsError < FreightKit::InvalidCredentialsError; end
4
+ class ExpiredCredentialsError < InvalidCredentialsError; end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FreightKit
4
- class HTTPError < FreightKit::Error
4
+ class HTTPError < Error
5
5
  attr_reader :body, :code
6
6
 
7
7
  def initialize(body:, code:)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FreightKit
4
- class InvalidCredentialsError < FreightKit::Error; end
4
+ class InvalidCredentialsError < Error; end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FreightKit
4
- class ResponseError < FreightKit::Error
4
+ class ResponseError < Error
5
5
  attr_reader :response
6
6
 
7
7
  def initialize(response = nil)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FreightKit
4
- class ShipmentNotFoundError < FreightKit::Error; end
4
+ class ShipmentNotFoundError < Error; end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FreightKit
4
- class UnserviceableAccessorialsError < FreightKit::UnserviceableError
4
+ class UnserviceableAccessorialsError < UnserviceableError
5
5
  attr_reader :accessorials
6
6
 
7
7
  def initialize(accessorials:)
@@ -11,7 +11,9 @@ module FreightKit
11
11
  end
12
12
 
13
13
  def message
14
- @message ||= "Unable to service #{@accessorials.map { |accessorial| accessorial.to_s.gsub("_", " ") }.join(", ")}"
14
+ @message ||= "Unable to service #{@accessorials.map do |accessorial|
15
+ accessorial.to_s.gsub("_", " ")
16
+ end.join(", ")}"
15
17
  end
16
18
  end
17
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FreightKit
4
- class UnserviceableError < FreightKit::Error; end
4
+ class UnserviceableError < Error; end
5
5
  end
data/lib/freight_kit.rb CHANGED
@@ -3,10 +3,8 @@
3
3
  require 'active_model'
4
4
  require 'active_support/all'
5
5
  require 'active_utils'
6
-
6
+ require 'business_time'
7
7
  require 'cgi'
8
- require 'yaml'
9
-
10
8
  require 'httparty'
11
9
  require 'measured'
12
10
  require 'mimemagic'
@@ -15,20 +13,28 @@ require 'open-uri'
15
13
  require 'place_kit'
16
14
  require 'savon'
17
15
  require 'watir'
16
+ require 'yaml'
17
+ require 'zeitwerk'
18
+
19
+ module FreightKit
20
+ VERSION = File.read(File.expand_path('../VERSION', __dir__)).strip.freeze
21
+
22
+ class Inflector < Zeitwerk::Inflector
23
+ def camelize(basename, abspath)
24
+ if basename =~ /\Ahttp_(.*)/
25
+ return "HTTP#{super(::Regexp.last_match(1), abspath)}"
26
+ end
27
+
28
+ super
29
+ end
30
+ end
31
+ end
32
+
33
+ loader = Zeitwerk::Loader.for_gem
34
+
35
+ loader.collapse("#{__dir__}/freight_kit/errors")
36
+ loader.collapse("#{__dir__}/freight_kit/models")
37
+
38
+ loader.inflector = FreightKit::Inflector.new
18
39
 
19
- require 'freight_kit/error'
20
- require 'freight_kit/errors'
21
-
22
- require 'freight_kit/model'
23
- require 'freight_kit/models'
24
-
25
- require 'freight_kit/carrier'
26
- require 'freight_kit/carriers'
27
- require 'freight_kit/contact'
28
- require 'freight_kit/package_item'
29
- require 'freight_kit/package'
30
- require 'freight_kit/packaging'
31
- require 'freight_kit/platform'
32
- require 'freight_kit/shipment_packer'
33
- require 'freight_kit/tariff'
34
- require 'freight_kit/version'
40
+ loader.setup
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freight_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Third Party Transportation Systems LLC
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2024-01-25 00:00:00.000000000 Z
14
+ date: 2024-05-24 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: business_time
@@ -56,47 +56,47 @@ dependencies:
56
56
  - !ruby/object:Gem::Version
57
57
  version: 13.1.0
58
58
  - !ruby/object:Gem::Dependency
59
- name: rspec
59
+ name: redcarpet
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - "~>"
63
63
  - !ruby/object:Gem::Version
64
- version: '3.12'
64
+ version: 3.6.0
65
65
  type: :development
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - "~>"
70
70
  - !ruby/object:Gem::Version
71
- version: '3.12'
71
+ version: 3.6.0
72
72
  - !ruby/object:Gem::Dependency
73
- name: rubocop-next
73
+ name: rspec
74
74
  requirement: !ruby/object:Gem::Requirement
75
75
  requirements:
76
76
  - - "~>"
77
77
  - !ruby/object:Gem::Version
78
- version: 1.0.3
78
+ version: '3.12'
79
79
  type: :development
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
83
  - - "~>"
84
84
  - !ruby/object:Gem::Version
85
- version: 1.0.3
85
+ version: '3.12'
86
86
  - !ruby/object:Gem::Dependency
87
- name: redcarpet
87
+ name: rubocop-next
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
90
  - - "~>"
91
91
  - !ruby/object:Gem::Version
92
- version: 3.6.0
92
+ version: 1.0.3
93
93
  type: :development
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
97
  - - "~>"
98
98
  - !ruby/object:Gem::Version
99
- version: 3.6.0
99
+ version: 1.0.3
100
100
  - !ruby/object:Gem::Dependency
101
101
  name: yard
102
102
  requirement: !ruby/object:Gem::Requirement
@@ -245,14 +245,14 @@ dependencies:
245
245
  requirements:
246
246
  - - "~>"
247
247
  - !ruby/object:Gem::Version
248
- version: 0.0.1
248
+ version: 0.0.2
249
249
  type: :runtime
250
250
  prerelease: false
251
251
  version_requirements: !ruby/object:Gem::Requirement
252
252
  requirements:
253
253
  - - "~>"
254
254
  - !ruby/object:Gem::Version
255
- version: 0.0.1
255
+ version: 0.0.2
256
256
  - !ruby/object:Gem::Dependency
257
257
  name: savon
258
258
  requirement: !ruby/object:Gem::Requirement
@@ -262,7 +262,7 @@ dependencies:
262
262
  version: '2.0'
263
263
  - - "<"
264
264
  - !ruby/object:Gem::Version
265
- version: '2.15'
265
+ version: '2.16'
266
266
  type: :runtime
267
267
  prerelease: false
268
268
  version_requirements: !ruby/object:Gem::Requirement
@@ -272,7 +272,7 @@ dependencies:
272
272
  version: '2.0'
273
273
  - - "<"
274
274
  - !ruby/object:Gem::Version
275
- version: '2.15'
275
+ version: '2.16'
276
276
  - !ruby/object:Gem::Dependency
277
277
  name: tzinfo-data
278
278
  requirement: !ruby/object:Gem::Requirement
@@ -302,7 +302,7 @@ dependencies:
302
302
  version: '7.0'
303
303
  - - "<"
304
304
  - !ruby/object:Gem::Version
305
- version: '7.2'
305
+ version: '7.4'
306
306
  type: :runtime
307
307
  prerelease: false
308
308
  version_requirements: !ruby/object:Gem::Requirement
@@ -312,7 +312,27 @@ dependencies:
312
312
  version: '7.0'
313
313
  - - "<"
314
314
  - !ruby/object:Gem::Version
315
- version: '7.2'
315
+ version: '7.4'
316
+ - !ruby/object:Gem::Dependency
317
+ name: zeitwerk
318
+ requirement: !ruby/object:Gem::Requirement
319
+ requirements:
320
+ - - ">="
321
+ - !ruby/object:Gem::Version
322
+ version: 2.6.0
323
+ - - "<"
324
+ - !ruby/object:Gem::Version
325
+ version: 2.6.14
326
+ type: :runtime
327
+ prerelease: false
328
+ version_requirements: !ruby/object:Gem::Requirement
329
+ requirements:
330
+ - - ">="
331
+ - !ruby/object:Gem::Version
332
+ version: 2.6.0
333
+ - - "<"
334
+ - !ruby/object:Gem::Version
335
+ version: 2.6.14
316
336
  description: Freight carrier API and website abstraction library for transportation
317
337
  management systems (TMS)
318
338
  email:
@@ -334,9 +354,7 @@ files:
334
354
  - lib/freight_kit.rb
335
355
  - lib/freight_kit/carrier.rb
336
356
  - lib/freight_kit/carriers.rb
337
- - lib/freight_kit/contact.rb
338
357
  - lib/freight_kit/error.rb
339
- - lib/freight_kit/errors.rb
340
358
  - lib/freight_kit/errors/document_not_found_error.rb
341
359
  - lib/freight_kit/errors/expired_credentials_error.rb
342
360
  - lib/freight_kit/errors/http_error.rb
@@ -346,7 +364,7 @@ files:
346
364
  - lib/freight_kit/errors/unserviceable_accessorials_error.rb
347
365
  - lib/freight_kit/errors/unserviceable_error.rb
348
366
  - lib/freight_kit/model.rb
349
- - lib/freight_kit/models.rb
367
+ - lib/freight_kit/models/contact.rb
350
368
  - lib/freight_kit/models/credential.rb
351
369
  - lib/freight_kit/models/date_time.rb
352
370
  - lib/freight_kit/models/document_response.rb
@@ -366,7 +384,6 @@ files:
366
384
  - lib/freight_kit/platform.rb
367
385
  - lib/freight_kit/shipment_packer.rb
368
386
  - lib/freight_kit/tariff.rb
369
- - lib/freight_kit/version.rb
370
387
  - service_type_symbols.txt
371
388
  - shipment_event_symbols.txt
372
389
  homepage: https://github.com/next-tms/freight_kit
@@ -387,7 +404,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
387
404
  - !ruby/object:Gem::Version
388
405
  version: '0'
389
406
  requirements: []
390
- rubygems_version: 3.5.5
407
+ rubygems_version: 3.4.10
391
408
  signing_key:
392
409
  specification_version: 4
393
410
  summary: Freight carrier API and website abstraction library for transportation management
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'freight_kit/errors/http_error'
4
- require 'freight_kit/errors/invalid_credentials_error'
5
- require 'freight_kit/errors/expired_credentials_error'
6
- require 'freight_kit/errors/document_not_found_error'
7
- require 'freight_kit/errors/shipment_not_found_error'
8
- require 'freight_kit/errors/response_error'
9
- require 'freight_kit/errors/unserviceable_error'
10
- require 'freight_kit/errors/unserviceable_accessorials_error'
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'freight_kit/models/credential'
4
- require 'freight_kit/models/label'
5
- require 'freight_kit/models/price'
6
- require 'freight_kit/models/rate'
7
- require 'freight_kit/models/shipment'
8
-
9
- require 'freight_kit/models/date_time'
10
- require 'freight_kit/models/location'
11
-
12
- require 'freight_kit/models/response'
13
- require 'freight_kit/models/document_response'
14
- require 'freight_kit/models/pickup_response'
15
- require 'freight_kit/models/rate_response'
16
- require 'freight_kit/models/shipment_event'
17
- require 'freight_kit/models/tracking_response'
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module FreightKit
4
- VERSION = File.read(File.expand_path('../../VERSION', __dir__)).strip.freeze
5
- end
File without changes