pandoc_wasm 1.0.1 → 1.0.2

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: c0063243b94e4afa0d3096dddd8e847c17aade7dd6e4438a9f64b1cc642f1deb
4
- data.tar.gz: 8784fba916dfee431ee8acf71dd4066ffeeaa466cfaabf69b8b23dff3269a25a
3
+ metadata.gz: 5e2a92cf9f4e9346c16d9a6afd6601837b50919fffb585796649448998e9c8fb
4
+ data.tar.gz: 2a7e0869dc0b5687582af570f870b2e3577be3259ae7f00f3c62377014b5e33a
5
5
  SHA512:
6
- metadata.gz: 0f575fb1d1afc2bbbd449bcfbe36a4d0ba99ac9ae4570ee7247f92761209dfb2b481f9bbe86a71be5851b43d34113cd14c874b8b7aa386ee7cb5dc9ccc7bad17
7
- data.tar.gz: f12f2da145a5cf848bc61d00448867ef73d5fefdcd749ce2eeeabe9d41ba7e8a8545c01074a90643efcc9dc1239c26e382b16556cd17e937f3f0d7e7a0f4c0c9
6
+ metadata.gz: 188d20ae2dc70cbd91bffacc364810ab8f557f71d3e7f00926b8d93a728ba5608f5bb5ed782c36b0d7029adeb45ce3b5771de61a6e48a7c96b919ea0a61569b6
7
+ data.tar.gz: 8f5ac3435566cad7a936bfdd4b9b0df5d2ef77c6b51638df03dc4412c2df543c787974963594d534a0f7fff8fe0744ee72d0350d1ab3ec7473c6158797c39191
data/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.0.2] - 2026-02-12
11
+
12
+ ### Fixed
13
+
14
+ - Fix redirect handling in downloader that prevented asset downloads from GitHub Releases (HTTP 302 not followed).
15
+
10
16
  ## [1.0.1] - 2026-02-10
11
17
 
12
18
  ### Fixed
@@ -11,7 +11,10 @@ module PandocWasm
11
11
  REPO_NAME = 'pandoc-wasm'
12
12
  ASSET_NAME = 'pandoc.wasm'
13
13
 
14
- # Download pandoc.wasm from the latest GitHub Release.
14
+ # Download pandoc.wasm from the GitHub Release matching the gem version.
15
+ #
16
+ # The release tag is derived from PandocWasm::VERSION (e.g. "1.0.1" -> "v1.0.1"),
17
+ # so the downloaded binary always matches the installed gem version.
15
18
  #
16
19
  # @param to [String] absolute path where the binary will be written
17
20
  # @return [true] on success
@@ -21,7 +24,7 @@ module PandocWasm
21
24
  FileUtils.mkdir_p(File.dirname(target))
22
25
 
23
26
  begin
24
- tag = get_latest_release_tag
27
+ tag = release_tag
25
28
  download_asset(tag, target)
26
29
  true
27
30
  rescue StandardError => e
@@ -31,34 +34,15 @@ module PandocWasm
31
34
  end
32
35
  end
33
36
 
34
- private
35
-
36
- # Get the latest release tag from GitHub API
37
- def self.get_latest_release_tag
38
- uri = URI("https://api.github.com/repos/#{REPO_OWNER}/#{REPO_NAME}/releases/latest")
39
-
40
- http = Net::HTTP.new(uri.host, uri.port)
41
- http.use_ssl = true
42
- http.read_timeout = 30
43
-
44
- request = Net::HTTP::Get.new(uri)
45
- request['User-Agent'] = 'pandoc-wasm-ruby-downloader'
46
- request['Accept'] = 'application/vnd.github.v3+json'
47
-
48
- response = http.request(request)
49
-
50
- case response.code
51
- when '200'
52
- release = JSON.parse(response.body)
53
- release['tag_name']
54
- when '404'
55
- version = PandocWasm::VERSION
56
- "v#{version}"
57
- else
58
- raise "GitHub API returned status #{response.code}: #{response.body}"
59
- end
37
+ # Returns the GitHub release tag matching the current gem version.
38
+ #
39
+ # @return [String] e.g. "v1.0.1"
40
+ def self.release_tag
41
+ "v#{PandocWasm::VERSION}"
60
42
  end
61
43
 
44
+ private
45
+
62
46
  # Download the asset from a GitHub Release to the given target path
63
47
  def self.download_asset(tag, target)
64
48
  uri = URI("https://api.github.com/repos/#{REPO_OWNER}/#{REPO_NAME}/releases/tags/#{tag}")
@@ -95,6 +79,8 @@ module PandocWasm
95
79
 
96
80
  File.open(target, 'wb') do |file|
97
81
  loop do
82
+ redirected = false
83
+
98
84
  download_http = Net::HTTP.new(download_uri.host, download_uri.port)
99
85
  download_http.use_ssl = (download_uri.scheme == 'https')
100
86
  download_http.read_timeout = 300
@@ -109,17 +95,17 @@ module PandocWasm
109
95
  redirects += 1
110
96
  raise "Too many redirects" if redirects > max_redirects
111
97
  download_uri = URI(dl_response['location'])
112
- next
98
+ redirected = true
113
99
  when Net::HTTPSuccess
114
100
  dl_response.read_body do |chunk|
115
101
  file.write(chunk)
116
102
  end
117
103
  else
118
- raise "Failed to download asset: #{dl_response.code}"
104
+ raise "Failed to download asset: HTTP #{dl_response.code}"
119
105
  end
120
106
  end
121
107
 
122
- break
108
+ break unless redirected
123
109
  end
124
110
  end
125
111
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PandocWasm
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.2'
5
5
  end
data/lib/pandoc_wasm.rb CHANGED
@@ -30,7 +30,7 @@ module PandocWasm
30
30
  @runtime || 'wasmtime'
31
31
  end
32
32
 
33
- # Download the .wasm binary from the latest GitHub Release to binary_path.
33
+ # Download the .wasm binary from the GitHub Release matching the gem version.
34
34
  # Creates intermediate directories if needed.
35
35
  #
36
36
  # @return [true] on success
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pandoc_wasm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Himpens