tracking_number 1.3.2 → 1.4.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: 7f1c67af2720cc0d2ba41487f936900218b41a6ad950aa13df012c83254c4e79
4
- data.tar.gz: e62646e4968999d1683cc8a24962d58ad0506debd1a1e3f1c66c0c4239ea2ec8
3
+ metadata.gz: 632e88e03ffd1404e26689c874e6093d8b978ceb7326d0e9c13879ffcf5c4a27
4
+ data.tar.gz: eb6acde6415fb26c3e303ba155714b8f033a14108b4b39a123f841b38d0310ba
5
5
  SHA512:
6
- metadata.gz: 4679026723c90a20749b0088fcfb7fce805eceac56076f5d2620fad31cc3e48a0dae6f5d445784b0ad8351d46af534ae70ea8eb6ef8ef49e5f0ed34e29f1d130
7
- data.tar.gz: 8c49fcffcacf2be4a081229a2df411157614b3367611220cae997c9f4010b35c493623d4440bfc52d6ce608fe1e055cd014f1b2093f90e0cc099e984c70d045f
6
+ metadata.gz: 5816c80bcd06b12d4918ca9b8b017035eb9f8caa2fb79c47a457e92863636d2263aa2f09abe757fe5219d149eb940a67556f4efcfa43501cdbb47ef304ee743a
7
+ data.tar.gz: 416f4a346ad8449e39d0bb570fbbd9ea157c19062f32d7ffc4cc8f2514a5e75b04ee8fa4715ac6a1fc2667de4f8264f8763b43a249a88357a2c50b1eb99c6333
@@ -7,13 +7,22 @@ on:
7
7
  jobs:
8
8
  release:
9
9
  name: Release
10
- runs-on: ubuntu-18.04
10
+ runs-on: ubuntu-latest
11
11
  steps:
12
12
  - name: Checkout
13
- uses: actions/checkout@v2
13
+ uses: actions/checkout@v3
14
14
  with:
15
- fetch-depth: 0
15
+ submodules: true
16
16
  persist-credentials: false
17
+ - name: Set up Ruby
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: ${{ matrix.ruby }}
21
+ - name: Build
22
+ run: |
23
+ gem install bundler
24
+ git submodule update --init --recursive
25
+ bundle install --jobs 4 --retry 3
17
26
  - name: Setup Node.js
18
27
  uses: actions/setup-node@v2
19
28
  with:
@@ -6,10 +6,12 @@ jobs:
6
6
  fail-fast: false
7
7
  matrix:
8
8
  os: [ ubuntu-latest ]
9
- ruby: [ '2.5', '2.6', '2.7', '3.0', '3.1' ]
9
+ ruby: [ '2.6', '2.7', '3.0', '3.1' ]
10
10
  runs-on: ${{ matrix.os }}
11
11
  steps:
12
12
  - uses: actions/checkout@v3
13
+ with:
14
+ submodules: true
13
15
  - name: Set up Ruby
14
16
  uses: ruby/setup-ruby@v1
15
17
  with:
@@ -17,7 +19,7 @@ jobs:
17
19
  - name: Build and test with Rake
18
20
  run: |
19
21
  gem install bundler
20
- git submodule update --init
22
+ git submodule update --init --recursive
21
23
  bundle install --jobs 4 --retry 3
22
24
  bundle exec rake
23
25
  publish:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  tracking_number changelog
2
2
 
3
+ # [1.4.0](https://github.com/jkeen/tracking_number/compare/v1.3.5...v1.4.0) (2023-05-15)
4
+
5
+
6
+ ### Features
7
+
8
+ * add partnership support with tracking_number_data 1.5 ([75fe530](https://github.com/jkeen/tracking_number/commit/75fe5304e933679aff89a91a93d2b7cf58c1fe5c))
9
+ * update to tracking number data 1.5 ([237ad3c](https://github.com/jkeen/tracking_number/commit/237ad3c82230d39b415df56eb8c8c9eeb22ba15c))
10
+
11
+ ## [1.3.5](https://github.com/jkeen/tracking_number/compare/v1.3.4...v1.3.5) (2023-01-09)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * modify release process to include submodules, the lack of which caused the 1.3.2 gem release to not work at all ([578af83](https://github.com/jkeen/tracking_number/commit/578af83d1b9da51c6edb8400d3aba8b195b66629))
17
+
3
18
  ## [1.3.2](https://github.com/jkeen/tracking_number/compare/v1.3.1...v1.3.2) (2022-12-23)
4
19
 
5
20
  # Changelog
data/README.md CHANGED
@@ -92,6 +92,28 @@ t = TrackingNumber.new("012345000000002")
92
92
  t.package_type #=> "case/carton"
93
93
  ```
94
94
 
95
+ #### Tracking URL
96
+ Get the tracking url from the shipper
97
+ ```ruby
98
+ t = TrackingNumber.new("1Z6072AF0320751583")
99
+ t.tracking_url #=> ""https://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=1Z6072AF0320751583"
100
+ ```
101
+
102
+ #### All the info we have
103
+ Get a object of all the info we have on the thing
104
+ ```ruby
105
+ t = TrackingNumber.new("1Z6072AF0320751583")
106
+ t.info #=> @courier=#<TrackingNumber::Info:0x000000010a45fed8 @code=:ups, @name="UPS">,
107
+ # @decode={:serial_number=>"6072AF032075158", :shipper_id=>"6072AF", :service_type=>"03", :package_id=>"2075158", :check_digit=>"3"},
108
+ # @destination_zip=nil,
109
+ # @package_type=nil,
110
+ # @partners=nil,
111
+ # @service_description=nil,
112
+ # @service_type="UPS United States Ground",
113
+ # @shipper_id="6072AF",
114
+ # @tracking_url="https://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=1Z6072AF0320751583">
115
+ ```
116
+
95
117
  #### Decoding
96
118
  Most tracking numbers have a format where each part of the number has meaning. `decode` splits up the number into its known named parts.
97
119
  ```ruby
@@ -107,6 +129,32 @@ Most tracking numbers have a format where each part of the number has meaning. `
107
129
  # }
108
130
  ```
109
131
 
132
+ #### Multiple shippers / Partnerships
133
+ Some tracking numbers match multiple carriers, because they belong to multiple carriers. Some shipments like Fedex Smartpost contract the "last mile" out to USPS.
134
+
135
+ ```ruby
136
+ # Search defaults to only showing numbers that fulfill the carrier side of the relationship
137
+ # (if a partnership exists at all), as this is the end a consumer would most likely be interested in.
138
+
139
+ results = TrackingNumber.search('420112139261290983497923666238')
140
+ => [#<TrackingNumber::USPS91:0x26ac0 420112139261290983497923666238>]
141
+
142
+ all_results = TrackingNumber.search('420112139261290983497923666238', match: :all)
143
+ => [#<TrackingNumber::FedExSmartPost:0x30624 420112139261290983497923666238>, #<TrackingNumber::USPS91:0x26ac0 420112139261290983497923666238>]
144
+
145
+ tn = results.first
146
+ tn.shipper? #=> false
147
+ tn.carrier? #=> true
148
+ tn.partnership? #=> true
149
+ tn.partners
150
+ #=> <struct TrackingNumber::Base::PartnerStruct
151
+ # shipper=#<TrackingNumber::FedExSmartPost:0x30624 420112139261290983497923666238>,
152
+ # carrier=#<TrackingNumber::USPS91:0x2f1fc 420112139261290983497923666238>>
153
+
154
+ tn.partners.shipper #=> #<TrackingNumber::FedExSmartPost:0x30624 420112139261290983497923666238>
155
+ tn.partners.carrier == tn #=> true
156
+ ```
157
+
110
158
  ## ActiveModel validation
111
159
 
112
160
  For Rails 3 (or any ActiveModel client), validate your fields as a tracking number:
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'tracking_number'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "Amazon",
3
+ "courier_code": "amazon",
4
+ "tracking_numbers": [
5
+ {
6
+ "name": "Amazon Logistics",
7
+ "id": "amazon_logistics",
8
+ "regex": [
9
+ "\\s*T\\s*B\\s*A\\s*(?<SerialNumber>([0-9]\\s*){12,12})\\s*"
10
+ ],
11
+ "validation": {},
12
+ "test_numbers": {
13
+ "valid": [
14
+ "TBA000000000000",
15
+ "TBA010000000000",
16
+ "TBA 000000000000",
17
+ "TBA502887274000"
18
+ ],
19
+ "invalid": [
20
+ "TBA50288727400A",
21
+ "000000000000000",
22
+ "000000000000",
23
+ "TBB000000000000"
24
+ ]
25
+ }
26
+ },
27
+ {
28
+ "name": "Amazon International",
29
+ "id": "amazon_international",
30
+ "regex": [
31
+ "\\s*[AFC]\\s*(?<SerialNumber>([0-9]\\s*){10,10})\\s*"
32
+ ],
33
+ "validation": {},
34
+ "test_numbers": {
35
+ "valid": [
36
+ "C1004444443",
37
+ "C1004444444"
38
+ ],
39
+ "invalid": [
40
+ "D1234567890"
41
+ ]
42
+ }
43
+ }
44
+ ]
45
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "Canada Post",
3
+ "courier_code": "canada_post",
4
+ "tracking_numbers": [
5
+ {
6
+ "name": "Canada Post (16)",
7
+ "id": "canada_post",
8
+ "regex": "\\s*(?<SerialNumber>(?<OriginId>([0-9]\\s*){7})([0-9]\\s*){8})(?<CheckDigit>[0-9]\\s*)",
9
+ "validation": {
10
+ "checksum": {
11
+ "name": "mod10",
12
+ "evens_multiplier": 3,
13
+ "odds_multiplier": 1
14
+ }
15
+ },
16
+ "tracking_url": "https://www.canadapost-postescanada.ca/track-reperage/en#/search?searchFor=%s",
17
+ "test_numbers": {
18
+ "valid": [
19
+ "0073938000549297",
20
+ "7035114477138472",
21
+ "4002847016405018"
22
+ ],
23
+ "invalid": [
24
+ "0073938000549292",
25
+ "7035114477138471",
26
+ "5002847016405018"
27
+ ]
28
+ }
29
+ }
30
+ ]
31
+ }
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "DHL",
3
+ "courier_code": "dhl",
4
+ "tracking_numbers": [
5
+ {
6
+ "name": "DHL Express",
7
+ "id": "dhl_express",
8
+ "regex": "\\s*(?<SerialNumber>(J[A-Z][A-Z][A-Z])?([0-9])?([0-9]\\s*){9})(?<CheckDigit>([0-9]\\s*))",
9
+ "validation": {
10
+ "checksum": {
11
+ "name": "mod7"
12
+ }
13
+ },
14
+ "tracking_url": "http://www.dhl.com/en/express/tracking.html?brand=DHL&AWB=%s",
15
+ "test_numbers": {
16
+ "valid": [
17
+ "JVGL0999999990",
18
+ "3318810025",
19
+ "73891051146",
20
+ "8487135506",
21
+ "3318810036",
22
+ "3318810014"
23
+ ],
24
+ "invalid": [
25
+ "3318810010",
26
+ "3318810034",
27
+ "JVGL3099999999",
28
+ "3318810011"
29
+ ]
30
+ }
31
+ },
32
+ {
33
+ "name": "DHL E-Commerce",
34
+ "id": "dhl_ecommerce",
35
+ "regex": "\\s*((GM)|(LX)|(RX)|(UV)|(CN)|(SG)|(TH)|(IN)|(HK)|(MY))\\s*(?<SerialNumber>([0-9]\\s*){10,39})",
36
+ "validation": {},
37
+ "tracking_url": "http://www.dhl.com/en/express/tracking.html?brand=DHL&AWB=%s",
38
+ "test_numbers": {
39
+ "valid": [
40
+ "GM2951173225174494",
41
+ "GM 2 9 5 117 32 25 1 7 44 9 4",
42
+ "GM295117494011169042"
43
+ ],
44
+ "invalid": [
45
+ "GS295117494011169041",
46
+ "GR295117494011169045"
47
+ ]
48
+ }
49
+ }
50
+ ]
51
+ }