kabosu 0.6.11.1-aarch64-linux → 0.6.11.2-aarch64-linux

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c7cc03641802c2a17cad952e91f1d028119480c1d19543bf842a10f8d5ebae6
4
- data.tar.gz: c1ed95738feb9ab1acfa34b07756408537cce9d065a4c78411439065a734b12f
3
+ metadata.gz: 6310222bef7890fd2ae5882d39f312a656d2bbfbb115d41a9dff80ac94b11932
4
+ data.tar.gz: f6d831203d5a58c208f7fee1b21f0036b9d0c344fc16652f8cf1e5fe7ef38e46
5
5
  SHA512:
6
- metadata.gz: 634c923333d1898f4d52f9da0d6b1d8de49f4bcfba1a140906c00f30880765bb8f5099388d7f58002f9e3b6af01b273e240569e2b03f5cc5b149beeb48b26407
7
- data.tar.gz: f20088ee2e5e2982efefedd4d8c7ae52f7ff66dd0f021a7df313e2a0e6905bf6c2b4271aa9fc7dd124c1370564faa8e233e277d616b7dbb489a169fe96a02a81
6
+ metadata.gz: f945a86f63e3694fb8bb4a199dbb83470977ed77f1e0d0ae41f66482986e9ff4d9acf148affb77e7e7a4487f512924f54884f92d0155d85cb0787494dd9d825f
7
+ data.tar.gz: 3a85e6084607c95ff81d0a1807813c625b1a4d9d84ae28c21626ae97d8b501b1a38131306cd38b8cd2939d1fb0e8acbe763cb415c9cb7fc80c44d5a027b775fc
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -46,13 +46,32 @@ module Kabosu
46
46
  return dic_path
47
47
  end
48
48
 
49
- url = release_asset_url(version, edition)
50
- zip_path = File.join(@dir, "sudachi-dictionary-#{version}-#{edition}.zip")
51
-
52
49
  FileUtils.mkdir_p(@dir)
53
- download(url, zip_path)
54
- extract(zip_path, @dir)
55
- FileUtils.rm_f(zip_path)
50
+
51
+ # SudachiDict switched to Python-only release assets in v20260723:
52
+ # https://github.com/WorksApplications/SudachiDict/releases/tag/v20260723
53
+ # The legacy `sudachi-dictionary-{version}-{edition}.zip` is gone; the
54
+ # new releases ship `sudachidict_{edition}-{version}-py3-none-any.whl`
55
+ # (a PEP 427 wheel). Pick whichever exists, preferring the legacy zip
56
+ # when both are present (older releases kept both formats in flight).
57
+ sources = pick_release_sources(version, edition)
58
+ raise DownloadError, "No downloadable assets for #{version}/#{edition}" if sources.empty?
59
+
60
+ sources.each do |source|
61
+ begin
62
+ download(source.fetch(:url), source.fetch(:archive_path))
63
+ extract(source.fetch(:archive_path), dest_dir, edition: edition)
64
+ FileUtils.rm_f(source.fetch(:archive_path))
65
+ break
66
+ rescue DownloadError => e
67
+ FileUtils.rm_f(source.fetch(:archive_path)) if File.exist?(source.fetch(:archive_path))
68
+ # Try the next candidate (e.g. wheel if the zip 404s). If this was
69
+ # the last one, surface the original error.
70
+ raise if sources.last.equal?(source)
71
+
72
+ warn " falling back: #{e.message}"
73
+ end
74
+ end
56
75
 
57
76
  raise DownloadError, "Expected #{dic_path} after extraction, but file not found" unless File.exist?(dic_path)
58
77
 
@@ -181,6 +200,51 @@ module Kabosu
181
200
  edition
182
201
  end
183
202
 
203
+ # Look up the GitHub release for `version` and return an ordered list of
204
+ # candidate download sources. The legacy `sudachi-dictionary-{version}-{edition}.zip`
205
+ # is preferred when present (matches the layout every other consumer
206
+ # assumes); otherwise we fall back to the SudachiDict Python wheel,
207
+ # which is what v20260723+ ship and which carries `system.dic` inside
208
+ # `sudachidict_{edition}/resources/`.
209
+ #
210
+ # On GitHub API failure we degrade to the legacy zip URL alone: an old
211
+ # release that 404s on the zip *also* 404s on the wheel, so falling back
212
+ # to "guessed" candidates costs nothing and keeps the code path simple
213
+ # for offline / no-network callers.
214
+ def pick_release_sources(version, edition)
215
+ candidates = []
216
+ zip = release_asset_url(version, edition)
217
+ candidates << { url: zip, archive_path: File.join(@dir, "sudachi-dictionary-#{version}-#{edition}.zip"), format: :zip }
218
+
219
+ begin
220
+ release = fetch_release(version)
221
+ if release
222
+ wheel_name = "sudachidict_#{edition}-#{version}-py3-none-any.whl"
223
+ wheel = release["assets"].to_a.find { |a| a["name"] == wheel_name }
224
+ if wheel && wheel["browser_download_url"]
225
+ candidates << {
226
+ url: wheel.fetch("browser_download_url"),
227
+ archive_path: File.join(@dir, wheel_name),
228
+ format: :wheel
229
+ }
230
+ end
231
+ end
232
+ rescue DownloadError
233
+ # API failure is fine: keep the legacy-zip candidate; the user will
234
+ # see a clean 404 if neither asset actually exists on disk.
235
+ end
236
+
237
+ candidates
238
+ end
239
+
240
+ def fetch_release(version)
241
+ uri = URI("#{GITHUB_API}/repos/#{GITHUB_REPO}/releases/tags/v#{version}")
242
+ response = http_get(uri, headers: { "Accept" => "application/json" })
243
+ return nil unless response.is_a?(Net::HTTPSuccess)
244
+
245
+ JSON.parse(response.body)
246
+ end
247
+
184
248
  def release_asset_url(version, edition)
185
249
  "https://github.com/#{GITHUB_REPO}/releases/download/v#{version}/sudachi-dictionary-#{version}-#{edition}.zip"
186
250
  end
@@ -249,11 +313,22 @@ module Kabosu
249
313
  end
250
314
  end
251
315
 
252
- def extract(zip_path, dest_dir)
316
+ def extract(zip_path, dest_dir, edition: nil)
253
317
  warn "Extracting..."
254
318
  Zip::File.open(zip_path) do |archive|
255
319
  archive.each do |entry|
256
- target = File.join(dest_dir, entry.name)
320
+ # Wheels (`sudachidict_{edition}/resources/system.dic`) carry the
321
+ # edition in the top-level directory; legacy zips name the file
322
+ # `system_{edition}.dic` already. When the entry is a `system.dic`
323
+ # inside a wheel and `edition:` was passed, land it at
324
+ # `dest_dir/system_{edition}.dic` so `find`/`installed` keep working
325
+ # without a separate code path.
326
+ target_name = entry.name
327
+ if edition && File.basename(entry.name) == "system.dic"
328
+ target_name = "system_#{edition}.dic"
329
+ end
330
+
331
+ target = File.join(dest_dir, target_name)
257
332
  # Guard against zip-slip — refuse entries that escape dest_dir.
258
333
  unless File.expand_path(target).start_with?(File.expand_path(dest_dir) + File::SEPARATOR)
259
334
  raise DownloadError, "Refusing to extract entry outside dest_dir: #{entry.name}"
@@ -1,3 +1,3 @@
1
1
  module Kabosu
2
- VERSION = "0.6.11.1".freeze
2
+ VERSION = "0.6.11.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kabosu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.11.1
4
+ version: 0.6.11.2
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - davafons
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-06-30 00:00:00.000000000 Z
11
+ date: 2026-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip