vehicles 0.1.0 → 0.1.1
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 +4 -4
- data/CHANGELOG.md +11 -0
- data/lib/vehicles/refresher.rb +7 -2
- data/lib/vehicles/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5972a6647d3cfa0383634d95002c4aae94d405bc00d6354e4cc0d5a7bd57901e
|
|
4
|
+
data.tar.gz: b06cfd87bdc9b80466296b1cc7e7492bcb4f4a45610dd9c0c3e777e16278ee89
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 507c5b6ee9f310969f9efa78d617e3676165bf6153cc8acf13786409bcaf76459607778609019c684aba48dbc8c37b57b16996c7b512409adf2af699b38098d8
|
|
7
|
+
data.tar.gz: 873795cf18b656ab8936c7412b3249e73200a25f3a976849b9ef16f278ac58952cd6ec83111099b4f5ed56c68bafccb6b24aca23c84ee62510f38705d31e9be9
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.1] - 2026-06-23
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- **Data refresh** now handles real HTTP responses correctly. `Net::HTTP` returns
|
|
14
|
+
an ASCII-8BIT body (e.g. gzip-decompressed); with multibyte UTF-8 data and
|
|
15
|
+
`Encoding.default_internal = UTF-8` (as Rails sets), the cache write raised
|
|
16
|
+
`Encoding::UndefinedConversionError` and the refresh silently failed (falling
|
|
17
|
+
back to the bundled snapshot). The fetched body is now tagged UTF-8 and the
|
|
18
|
+
cache is written with `File.binwrite` (no transcoding). `Vehicles.refresh!`
|
|
19
|
+
works under Rails.
|
|
20
|
+
|
|
10
21
|
## [0.1.0] - 2026-06-23
|
|
11
22
|
|
|
12
23
|
Initial release.
|
data/lib/vehicles/refresher.rb
CHANGED
|
@@ -75,7 +75,10 @@ module Vehicles
|
|
|
75
75
|
response = http.get(uri.request_uri, "Accept" => "application/json")
|
|
76
76
|
case response
|
|
77
77
|
when Net::HTTPSuccess
|
|
78
|
-
|
|
78
|
+
# Net::HTTP hands back an ASCII-8BIT body (e.g. after gzip decompression);
|
|
79
|
+
# our datasets are UTF-8 JSON, so label it correctly. Otherwise downstream
|
|
80
|
+
# writes/parses can transcode-raise under Encoding.default_internal = UTF-8.
|
|
81
|
+
response.body&.dup&.force_encoding(Encoding::UTF_8)
|
|
79
82
|
when Net::HTTPRedirection
|
|
80
83
|
return nil if redirects_left <= 0
|
|
81
84
|
|
|
@@ -87,7 +90,9 @@ module Vehicles
|
|
|
87
90
|
require "fileutils"
|
|
88
91
|
FileUtils.mkdir_p(File.dirname(path))
|
|
89
92
|
tmp = "#{path}.#{Process.pid}.tmp"
|
|
90
|
-
|
|
93
|
+
# Binary write: persist the exact bytes, never transcode. Robust regardless
|
|
94
|
+
# of the body's encoding or the app's Encoding.default_internal.
|
|
95
|
+
File.binwrite(tmp, body)
|
|
91
96
|
File.rename(tmp, path) # atomic on the same filesystem
|
|
92
97
|
end
|
|
93
98
|
end
|
data/lib/vehicles/version.rb
CHANGED