kabosu 0.6.11.1-aarch64-linux → 0.6.11.3-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: 462efa031fdd677b5cec78e45b23b5826e55987ed178c713fd9cd5ec15cea976
4
+ data.tar.gz: 7f2abe0539c31985ca7b021327151e87055319a807ca326ae076a23d64a49703
5
5
  SHA512:
6
- metadata.gz: 634c923333d1898f4d52f9da0d6b1d8de49f4bcfba1a140906c00f30880765bb8f5099388d7f58002f9e3b6af01b273e240569e2b03f5cc5b149beeb48b26407
7
- data.tar.gz: f20088ee2e5e2982efefedd4d8c7ae52f7ff66dd0f021a7df313e2a0e6905bf6c2b4271aa9fc7dd124c1370564faa8e233e277d616b7dbb489a169fe96a02a81
6
+ metadata.gz: af5c6416171b22c0a3c4533061c2cfd5d256696f4bd31fe1cb200094401e7ba2cf767924eea8d8f643fa46e3b48257076bde0db427f834ff1e1ebf2ba166c388
7
+ data.tar.gz: 9ce86eca4e2f3def2d4eec240a62acb3f34c0196dd4ef41ca84f78d0f4c351ec29fdc5813872aba8e97006ee9d73bfe4a22794fdd74b1cf6816a4ceb2c79f380
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,17 +313,37 @@ 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
+ # Both layouts are flattened into dest_dir, which is already
321
+ # `sudachi-dictionary-{version}`.
322
+ #
323
+ # Legacy zips nest their contents under a `sudachi-dictionary-{version}/`
324
+ # directory of their own, so joining the entry name to dest_dir landed
325
+ # the dictionary at `sudachi-dictionary-{version}/sudachi-dictionary-{version}/system_core.dic`
326
+ # and every install of a pre-v20260723 release failed with "expected
327
+ # ... after extraction, but file not found". It went unnoticed because a
328
+ # machine that already had a dictionary never re-installs one.
329
+ #
330
+ # Wheels nest differently again (`sudachidict_{edition}/resources/system.dic`)
331
+ # and name the file `system.dic`, so that one is renamed to carry the
332
+ # edition. Taking the basename handles both, and there is nothing in
333
+ # these archives whose structure is worth keeping: a `.dic`, a LEGAL and
334
+ # a licence.
335
+ target_name = File.basename(entry.name)
336
+ target_name = "system_#{edition}.dic" if edition && target_name == "system.dic"
337
+
338
+ next if entry.directory?
339
+
340
+ target = File.join(dest_dir, target_name)
257
341
  # Guard against zip-slip — refuse entries that escape dest_dir.
258
342
  unless File.expand_path(target).start_with?(File.expand_path(dest_dir) + File::SEPARATOR)
259
343
  raise DownloadError, "Refusing to extract entry outside dest_dir: #{entry.name}"
260
344
  end
261
345
 
262
- FileUtils.mkdir_p(File.dirname(target))
346
+ FileUtils.mkdir_p(dest_dir)
263
347
  entry.extract(target) { true } # overwrite existing
264
348
  end
265
349
  end
@@ -1,3 +1,3 @@
1
1
  module Kabosu
2
- VERSION = "0.6.11.1".freeze
2
+ VERSION = "0.6.11.3".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.3
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