metanorma-release 0.2.19 → 0.2.21

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: bd193b321dc862e5773523c57a82a37966b93a087cd6354486ad067b50d2b992
4
- data.tar.gz: 40f1dd74b4409040d1cd625477d0787b07f6fc29eed1e98c6210e4f229ce2464
3
+ metadata.gz: 870b32feb3cf51fae8f217ca433e725d783904cd986947264f886e16bc30e03b
4
+ data.tar.gz: f37c695d3ed8bd4becde735a1eb7f0d598ac2e1c946a047c3574d910eff08596
5
5
  SHA512:
6
- metadata.gz: dc2f1951bded304c45d587a0b57ebc2d4946aae4633748f6008588a5aa764a99c20f7a04a3ef8b8eb0034ac605ff582106cc621592c20710c7c6d5e3ec2a9963
7
- data.tar.gz: 51c29d6cf3d483e33dca8c5a13bf4f4564e1f25077b306015ec0bc09cc77dde50382c3767d2fc76b346d794413ba8060af756f4a3b556ba4d26a49626d47385f
6
+ metadata.gz: 8d3292688c6e9043a2c05c75704fc3362e07344285c2d928e2aa85b3e48592aed79ed573424c36ca583e977e745640d44609887849511bb5853d093c38ae40e3
7
+ data.tar.gz: 20c61ff249f15acc7022c24acf13206dfc4d08193168a9597d96a4c32df98166e54c1ab7f1a339e894f1bd43fc42d9e2fca43cbb11544551c3629002267d1010
@@ -99,6 +99,7 @@ module Metanorma
99
99
  topic: @config.topic,
100
100
  repos: @config.repos,
101
101
  token: @config.token,
102
+ cache_dir: @config.cache_dir,
102
103
  )
103
104
 
104
105
  metadata_filter = MetadataFilter.new(
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "digest"
4
+
3
5
  module Metanorma
4
6
  module Release
5
7
  module Platform
@@ -13,8 +15,9 @@ module Metanorma
13
15
  class ReleaseFetcher
14
16
  include Metanorma::Release::ReleaseFetcher
15
17
 
16
- def initialize(client:)
18
+ def initialize(client:, download_cache_dir: nil)
17
19
  @client = client
20
+ @download_cache_dir = download_cache_dir
18
21
  end
19
22
 
20
23
  def fetch(repo, etag: nil)
@@ -67,11 +70,28 @@ module Metanorma
67
70
  end
68
71
 
69
72
  def download_asset(url)
70
- @client.get(url, accept: "application/octet-stream")
73
+ cache_path = cache_file_path(url)
74
+ if cache_path && File.exist?(cache_path)
75
+ return File.binread(cache_path)
76
+ end
77
+
78
+ data = @client.get(url, accept: "application/octet-stream")
79
+ if cache_path && data
80
+ FileUtils.mkdir_p(File.dirname(cache_path))
81
+ File.binwrite(cache_path, data)
82
+ end
83
+ data
71
84
  rescue StandardError => e
72
85
  warn "Warning: Failed to download asset #{url}: #{e.message}"
73
86
  nil
74
87
  end
88
+
89
+ def cache_file_path(url)
90
+ return nil unless @download_cache_dir
91
+
92
+ hash = Digest::SHA256.hexdigest(url)
93
+ File.join(@download_cache_dir, hash)
94
+ end
75
95
  end
76
96
  end
77
97
  end
@@ -31,9 +31,12 @@ module Metanorma
31
31
  )
32
32
  end
33
33
 
34
+ download_cache = opts[:cache_dir] ? File.join(opts[:cache_dir], "downloads") : nil
35
+
34
36
  {
35
37
  discoverer: discoverer,
36
- fetcher: Platform::GitHub::ReleaseFetcher.new(client: client),
38
+ fetcher: Platform::GitHub::ReleaseFetcher.new(client: client,
39
+ download_cache_dir: download_cache),
37
40
  manifest_reader: Platform::GitHub::ManifestReader.new(client: client),
38
41
  }
39
42
  },
@@ -304,8 +304,8 @@ module Metanorma
304
304
  date = bib.date&.find { |d| d.type == "published" } || bib.date&.first
305
305
  return nil unless date
306
306
 
307
- on = date.on
308
- on.respond_to?(:content) ? on.content.to_s : on.to_s
307
+ val = date.at
308
+ val ? val.to_s : nil
309
309
  rescue StandardError
310
310
  nil
311
311
  end
@@ -99,6 +99,7 @@ module Metanorma
99
99
  "channels" => doc["channels"] || [],
100
100
  "formats" => formats,
101
101
  "files" => doc["files"] || [],
102
+ "bibliographic" => bib,
102
103
  }
103
104
  add_format_flags(base, formats)
104
105
  add_display_category(base, doctype)
@@ -110,6 +111,7 @@ module Metanorma
110
111
  hash["has_html"] = formats.include?("html")
111
112
  hash["has_pdf"] = formats.include?("pdf")
112
113
  hash["has_xml"] = formats.include?("xml")
114
+ hash["has_rxl"] = formats.include?("rxl")
113
115
  end
114
116
 
115
117
  def add_display_category(hash, doctype)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Metanorma
4
4
  module Release
5
- VERSION = "0.2.19"
5
+ VERSION = "0.2.21"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-release
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.19
4
+ version: 0.2.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-05-19 00:00:00.000000000 Z
11
+ date: 2026-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: relaton-bib