relaton-iec 1.20.0 → 1.20.1

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: 7f20588ecb2038b53252427cb01e0993d843195c12ea912a274116787f20ce74
4
- data.tar.gz: 13f77733184dd0e26a46a83cf9b05838903818e6f6b68e91ce397c529370878f
3
+ metadata.gz: 075af8973d061da09f15b28a62c0fce39013f6c6e662c2fa1e3ac4566e31633b
4
+ data.tar.gz: d0c18b4633244d88b20ea2fa69bedbbaff2e74421736728cd5c6ed0e821228d5
5
5
  SHA512:
6
- metadata.gz: ca90f4613d002f0845e966e5c80f03bdb3e813daa11363d78c0c35540ed0e6ee2216e1da61dd0582393bd41d62666377ceec22a9cbc9be3313ce66cba02832c9
7
- data.tar.gz: 83025369d42c19658ac6948f92f8b41e07148a7c66f46e7e24a32e5504a675d188406152cddfa0aa155caa2218eb24821179d2092fbcaf947f17b0615e62c90a
6
+ metadata.gz: ae4e37b4b94b7d8f0708189183e54d4488d3144dcab2d000f7372ce9cd1c18d6150196604024c95cb201b24ec4bd26505c0b9278326ce4351d9206480a2bb06a
7
+ data.tar.gz: c2d717a267b3faf09d378fd0b6461107458fabb33ea2e55dba7715859f3aeeca4a5edce7538194468cc5e521c73cd9bfe0676279f9984d616edd59b65efd808f
data/CLAUDE.md ADDED
@@ -0,0 +1,49 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Build and Test Commands
6
+
7
+ ```bash
8
+ bundle install # Install dependencies
9
+ rake spec # Run all tests (or just `rspec`)
10
+ rspec spec/relaton_iec_spec.rb # Run single test file
11
+ rspec spec/relaton_iec_spec.rb:69 # Run test at specific line
12
+ bin/console # Interactive Ruby console with gem loaded
13
+ ```
14
+
15
+ ## Architecture Overview
16
+
17
+ relaton-iec is a Ruby gem that retrieves IEC (International Electrotechnical Commission) standards metadata. It's part of the Relaton family of bibliographic gems.
18
+
19
+ ### Data Flow
20
+
21
+ 1. **Search/Get requests** go through `IecBibliography.get(code, year, opts)` or `.search(ref, year)`
22
+ 2. `HitCollection` queries an index file from GitHub (relaton/relaton-data-iec)
23
+ 3. Individual `Hit` objects fetch full YAML documents from the same GitHub repository
24
+ 4. Results are parsed into `IecBibliographicItem` objects
25
+
26
+ ### Key Classes
27
+
28
+ - **IecBibliography** ([lib/relaton_iec/iec_bibliography.rb](lib/relaton_iec/iec_bibliography.rb)) - Main entry point for searching and fetching standards
29
+ - **IecBibliographicItem** ([lib/relaton_iec/iec_bibliographic_item.rb](lib/relaton_iec/iec_bibliographic_item.rb)) - Extends `RelatonIsoBib::IsoBibliographicItem` with IEC-specific attributes (function, updates_document_type, accessibility_color_inside, cen_processing, secretary, interest_to_committees)
30
+ - **HitCollection** ([lib/relaton_iec/hit_collection.rb](lib/relaton_iec/hit_collection.rb)) - Manages search results from the index
31
+ - **Hit** ([lib/relaton_iec/hit.rb](lib/relaton_iec/hit.rb)) - Single search result; fetches full document on demand from GitHub
32
+ - **DataFetcher** ([lib/relaton_iec/data_fetcher.rb](lib/relaton_iec/data_fetcher.rb)) - Fetches documents from IEC Harmonized API (requires credentials)
33
+ - **Processor** ([lib/relaton_iec/processor.rb](lib/relaton_iec/processor.rb)) - Relaton framework integration
34
+
35
+ ### URN Conversion
36
+
37
+ The module provides `RelatonIec.code_to_urn(code, lang)` and `RelatonIec.urn_to_code(urn)` for converting between document identifiers and URN format.
38
+
39
+ ### Testing
40
+
41
+ - Uses RSpec with VCR for HTTP interaction recording
42
+ - VCR cassettes stored in `spec/vcr_cassettes/`
43
+ - Tests use webmock for HTTP stubbing
44
+
45
+ ### DataFetcher Environment Variables
46
+
47
+ When fetching from IEC Harmonized API directly:
48
+ - `IEC_HAPI_PROJ_PUBS_KEY` - API key
49
+ - `IEC_HAPI_PROJ_PUBS_SECRET` - API secret
@@ -64,13 +64,11 @@ module RelatonIec
64
64
  # @return [RelatonIsoBib::StructuredIdentifier] structured identifier
65
65
  #
66
66
  def structuredidentifier
67
- m = @pub["reference"].match(
68
- /(?<=\s)(?<project>\w+)(?:-(?<part>\w*)(?:-(?<subpart>\w*))?)?/,
69
- )
70
- RelatonIsoBib::StructuredIdentifier.new(
71
- project_number: m[:project], part: m[:part], subpart: m[:subpart],
72
- type: "IEC", id: @pub["reference"]
73
- )
67
+ urn = @pub.dig("project", "urn")
68
+ return unless urn
69
+
70
+ pnum = urn.split(":").last
71
+ RelatonIsoBib::StructuredIdentifier.new(project_number: pnum, type: "IEC")
74
72
  end
75
73
 
76
74
  #
@@ -122,9 +122,11 @@ module RelatonIec
122
122
  # @return [Hash] index content
123
123
  #
124
124
  def get_index_from_gh # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
125
- resp = Zip::InputStream.new URI("#{Hit::GHURL}index.zip").open
126
- zip = resp.get_next_entry
127
- yaml = zip.get_input_stream.read
125
+ url = "#{Hit::GHURL}index.zip"
126
+ resp = Mechanize.new.get(url)
127
+ zip = Zip::InputStream.new(StringIO.new(resp.body))
128
+ entry = zip.get_next_entry
129
+ yaml = entry.get_input_stream.read
128
130
  index = RelatonBib.parse_yaml yaml, [Symbol]
129
131
  File.write path, index.to_yaml, encoding: "UTF-8"
130
132
  index
@@ -1,3 +1,3 @@
1
1
  module RelatonIec
2
- VERSION = "1.20.0".freeze
2
+ VERSION = "1.20.1".freeze
3
3
  end
data/lib/relaton_iec.rb CHANGED
@@ -3,6 +3,7 @@ require "net/http"
3
3
  require "nokogiri"
4
4
  require "zip"
5
5
  require "open-uri"
6
+ require "mechanize"
6
7
  require "relaton/index"
7
8
  require "relaton_iso_bib"
8
9
  require "relaton_iec/hit"
data/relaton_iec.gemspec CHANGED
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.add_dependency "addressable"
27
27
  spec.add_dependency "base64"
28
+ spec.add_dependency "mechanize", "~> 2.8"
28
29
  spec.add_dependency "relaton-index", "~> 0.2.0"
29
30
  spec.add_dependency "relaton-iso-bib", "~> 1.20.0"
30
31
  spec.add_dependency "rubyzip"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-iec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.20.0
4
+ version: 1.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-12 00:00:00.000000000 Z
11
+ date: 2026-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mechanize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.8'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.8'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: relaton-index
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -93,6 +107,7 @@ files:
93
107
  - ".gitignore"
94
108
  - ".rspec"
95
109
  - ".rubocop.yml"
110
+ - CLAUDE.md
96
111
  - Gemfile
97
112
  - LICENSE.txt
98
113
  - README.adoc
@@ -158,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
173
  - !ruby/object:Gem::Version
159
174
  version: '0'
160
175
  requirements: []
161
- rubygems_version: 3.3.27
176
+ rubygems_version: 3.5.22
162
177
  signing_key:
163
178
  specification_version: 4
164
179
  summary: 'RelatonIec: retrieve IEC Standards for bibliographic use using the IecBibliographicItem