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 +4 -4
- data/CHANGELOG.md +9 -0
- data/README.adoc +5 -0
- data/lib/asciichem/resolver/common_chemistry.rb +19 -1
- data/lib/asciichem/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 380b64ab12e3ccc18a554a5d1dc7793046bfa7ea5ba80d51330bb5d713ea618f
|
|
4
|
+
data.tar.gz: 4b3ec1535d5854626b5e2976adb060b4432bfb7f9d20331e79717ae0db4cdf73
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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)
|
data/lib/asciichem/version.rb
CHANGED