asciichem 0.31.13 → 0.31.14

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: 13b35ffffbfa3349f95961b56e7dae9e74d55a116554a76c1175f3f74e347183
4
- data.tar.gz: ea78a952280a73728fbd27cff80af8e3eebf163e45b8428ece6171a588471b55
3
+ metadata.gz: 380b64ab12e3ccc18a554a5d1dc7793046bfa7ea5ba80d51330bb5d713ea618f
4
+ data.tar.gz: 4b3ec1535d5854626b5e2976adb060b4432bfb7f9d20331e79717ae0db4cdf73
5
5
  SHA512:
6
- metadata.gz: 538a97d2151764c9c84026ecccf32380ca82393158ac56d85af050aceab459ca47eb23a7828fb48bb5ed9fbe8289b11d2a5583bd8bd8b96f40ee20002247d5d8
7
- data.tar.gz: 6edff89d3e29935de3227db81ef9126d6d7ce46cf0c39d58343114522d88205de9d969d99f760e6bd8602bc71f85fd80310b8730684769c31ec9aa21fa8f0413
6
+ metadata.gz: 49ca402649027d0091acb25b77848e46a9ffaa5bf876e16512f14378d507a3bf32a6dbbb6245967bc54d1eb6728f0672a530db0e92c8db476ca9bfbdb87497f6
7
+ data.tar.gz: 1741914b553ebe4f1828fa3a294c3ed0249a22072dd90f57185d92aafea717a97eaded37236c97ac3b406032f2919cd449818ba6cf7a6094fdd37a81c7f5c44e
data/CHANGELOG.md CHANGED
@@ -3,6 +3,15 @@
3
3
  All notable changes to AsciiChem are documented here.
4
4
  This project follows [Semantic Versioning](https://semver.org/).
5
5
 
6
+ ## [0.31.14] - 2026-11-12
7
+
8
+ ### Added
9
+ - The Common Chemistry adapter accepts a user-provided API key:
10
+ `CommonChemistry.new(api_key: ...)` or the
11
+ `COMMON_CHEMISTRY_API_KEY` environment variable (sent as the
12
+ `apikey` query parameter). CAS key-gated the API — without a key
13
+ live lookups answer 401 and the resolver skips the source.
14
+
6
15
  ## [0.31.13] - 2026-11-11
7
16
 
8
17
  ### Fixed
data/README.adoc CHANGED
@@ -103,6 +103,11 @@ AsciiChem::Resolver.resolve(value: "50-78-2", convention: "cas",
103
103
  sources: [:pubchem, :opsin])
104
104
  ----
105
105
 
106
+ CAS key-gated the Common Chemistry API: live lookups there need a
107
+ key (request one at cas.org/services/commonchemistry-api) exported
108
+ as `COMMON_CHEMISTRY_API_KEY`. Without it, that source answers 401
109
+ and is skipped — PubChem and OPSIN keep resolving.
110
+
106
111
  === Citations: dataset bibitems with provenance
107
112
 
108
113
  [source,ruby]
@@ -14,14 +14,32 @@ module AsciiChem
14
14
  # that must stay NC-free limit sources with the
15
15
  # `asciichem-sources` attribute (metanorma-plugin-asciichem) or
16
16
  # `Resolver.resolve(sources:)`.
17
+ #
18
+ # API access: CAS key-gated the API (401 without a key; request
19
+ # one at cas.org/services/commonchemistry-api — the exact contract
20
+ # arrives with the access email). The adapter sends the key as the
21
+ # `apikey` query parameter; set it per instance (`api_key:`) or
22
+ # through COMMON_CHEMISTRY_API_KEY, which the resolver's own
23
+ # instantiation picks up. Without a key, live lookups answer 401
24
+ # and the resolver skips this source (the other sources still
25
+ # resolve; seeded caches keep working).
17
26
  class CommonChemistry < Adapter
18
27
  source_name :common_chemistry
19
28
  supports "cas"
20
29
 
21
30
  BASE = "https://commonchemistry.cas.org/api/detail"
22
31
 
32
+ attr_reader :api_key
33
+
34
+ def initialize(api_key: ENV.fetch("COMMON_CHEMISTRY_API_KEY", nil))
35
+ super()
36
+ @api_key = api_key
37
+ end
38
+
23
39
  def fetch_record(value:, convention:, fetch:)
24
- body = fetch.get("#{BASE}?cas_rn=#{CGI.escape(value.to_s)}")
40
+ url = "#{BASE}?cas_rn=#{CGI.escape(value.to_s)}"
41
+ url = "#{url}&apikey=#{CGI.escape(api_key)}" if api_key
42
+ body = fetch.get(url)
25
43
  return nil unless body
26
44
 
27
45
  data = JSON.parse(body)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AsciiChem
4
- VERSION = "0.31.13"
4
+ VERSION = "0.31.14"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciichem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.13
4
+ version: 0.31.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.