relaton-core 0.0.11 → 0.0.13

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: 5354feb75eac4e721a544831fc979cddaea15463aee96b6438782e832391ec02
4
- data.tar.gz: c09c53ba1f08adb6f7bb763947b2e3336271000de2960a5fb22d37f6b6eec18e
3
+ metadata.gz: 50461ecf6c0d414d4317dc8af5acbf111a928065de2be091654b4f4fcff95b4a
4
+ data.tar.gz: 1c9dab8791b8b339c022ba1e136033b731a0462a7004bb6c7b8d3d1d1049648d
5
5
  SHA512:
6
- metadata.gz: 0a932957250c2a7b25b8f4ae3e7eff6aa16345ee5597be56677d6cb113af10b209ed191cc172c7413c0d3d66bafbc8bfaaf639430c262453740715cd5da8de0d
7
- data.tar.gz: be100629f5a0014a873a1e0c98dd63c7448ecb0235af63c330e464af48bc7cb9737dd112468c68a9d18b928f2e682b693615e555d9bdca9548e0baa5f67e51df
6
+ metadata.gz: 358e0f3c2939eddd86d7c8e3eaee86ed6405ce1920886d9ab4e14aff8e5e380d8e010d43ca5aa4abf6323e7e94ff5e0e479d417d8984b0dd4d8132e36480e70e
7
+ data.tar.gz: 1bc8b1ef574817e1b4639398cc4cd3527af6448ffacef97a41173809732db6960959114815ab330ca5a21d8bcd379dbff4439e1ab230368d65d2744d7fe1911b
@@ -1,90 +1,93 @@
1
1
  require "fileutils"
2
2
 
3
- module Relaton::Core
4
- class DataFetcher
5
- # attr_accessor :docs
6
- #
7
- # Initialize fetcher
8
- #
9
- # @param [String] output path to output directory
10
- # @param [String] format output format (yaml, xml, bibxml)
11
- #
12
- def initialize(output, format)
13
- @output = output
14
- @format = format
15
- @ext = format.sub "bibxml", "xml"
16
- @files = Set.new
17
- # @docs = []
18
- @errors = Hash.new(true)
19
- end
3
+ module Relaton
4
+ module Core
5
+ class DataFetcher
6
+ # attr_accessor :docs
7
+ #
8
+ # Initialize fetcher
9
+ #
10
+ # @param [String] output path to output directory
11
+ # @param [String] format output format (yaml, xml, bibxml)
12
+ #
13
+ def initialize(output, format)
14
+ @output = output
15
+ @format = format
16
+ @ext = format.sub "bibxml", "xml"
17
+ @files = Set.new
18
+ # @docs = []
19
+ @errors = Hash.new(true)
20
+ end
20
21
 
21
- # API method for external service
22
- def self.fetch(source = nil, output: "data", format: "yaml")
23
- t1 = Time.now
24
- puts "Started at: #{t1}"
25
- FileUtils.mkdir_p output
26
- new(output, format).fetch(source)
27
- t2 = Time.now
28
- puts "Stopped at: #{t2}"
29
- puts "Done in: #{(t2 - t1).round} sec."
30
- end
22
+ # API method for external service
23
+ def self.fetch(source = nil, output: "data", format: "yaml")
24
+ t1 = Time.now
25
+ puts "Started at: #{t1}"
26
+ FileUtils.mkdir_p output
27
+ new(output, format).fetch(source)
28
+ t2 = Time.now
29
+ puts "Stopped at: #{t2}"
30
+ puts "Done in: #{(t2 - t1).round} sec."
31
+ end
31
32
 
32
- def fetch(source = nil)
33
- raise NotImplementedError, "#{self.class}#fetch method must be implemented"
34
- end
33
+ def fetch(source = nil)
34
+ raise NotImplementedError, "#{self.class}#fetch method must be implemented"
35
+ end
35
36
 
36
- def gh_issue
37
- return @gh_issue if defined? @gh_issue
37
+ def gh_issue
38
+ return @gh_issue if defined? @gh_issue
38
39
 
39
- channel = gh_issue_channel
40
- if channel[0]
41
- @gh_issue = Relaton::Logger::Channels::GhIssue.new(*channel)
42
- Relaton.logger_pool[:gh_issue] = Relaton::Logger::Log.new(@gh_issue, levels: [:error])
40
+ channel = gh_issue_channel
41
+ if channel[0]
42
+ @gh_issue = Relaton::Logger::Channels::GhIssue.new(*channel)
43
+ Relaton.logger_pool[:gh_issue] = Relaton::Logger::Log.new(@gh_issue, levels: [:error])
44
+ end
45
+ @gh_issue
43
46
  end
44
- @gh_issue
45
- end
46
47
 
47
- def gh_issue_channel
48
- [ENV.fetch("GITHUB_REPOSITORY", nil), "Error fetching documents"]
49
- end
48
+ def gh_issue_channel
49
+ [ENV.fetch("GITHUB_REPOSITORY", nil), "Error fetching documents"]
50
+ end
50
51
 
51
- def repot_errors
52
- gh_issue # register the channel before logging
53
- @errors.select { |_, v| v }.each_key { |k| log_error "Failed to fetch #{k}" }
54
- @gh_issue&.create_issue
55
- end
52
+ def report_errors
53
+ gh_issue # register the channel before logging
54
+ @errors.select { |_, v| v }.each_key { |k| log_error "Failed to fetch #{k}" }
55
+ @gh_issue&.create_issue
56
+ end
56
57
 
57
- def log_error(_msg)
58
- raise NoMatchingPatternError, "#{self.class}#log_error method must be implemented"
59
- end
58
+ def log_error(_msg)
59
+ raise NoMatchingPatternError, "#{self.class}#log_error method must be implemented"
60
+ end
60
61
 
61
- # @param [String] document ID
62
- # @return [String] filename based on PubID identifier
63
- def output_file(docid)
64
- File.join @output, "#{docid.downcase.gsub(/[.\s\/:-]+/, '-')}.#{@ext}"
65
- end
62
+ # @param [String] document ID
63
+ # @return [String] filename based on PubID identifier
64
+ def output_file(docid)
65
+ id = docid.downcase.gsub(/[.\s\/:()-]+/, "-").delete_suffix("-")
66
+ File.join @output, "#{id}.#{@ext}"
67
+ end
66
68
 
67
- #
68
- # Serialize bibliographic item
69
- #
70
- # @param [RelatonCcsds::BibliographicItem] bib <description>
71
- #
72
- # @return [String] serialized bibliographic item
73
- #
74
- def serialize(bib)
75
- send "to_#{@format}", bib
76
- end
69
+ #
70
+ # Serialize bibliographic item
71
+ #
72
+ # @param [RelatonCcsds::BibliographicItem] bib <description>
73
+ #
74
+ # @return [String] serialized bibliographic item
75
+ #
76
+ def serialize(bib)
77
+ send "to_#{@format}", bib
78
+ end
77
79
 
78
- def to_yaml(bib)
79
- raise NotImplementedError, "#{self.class}#to_yaml method must be implemented"
80
- end
80
+ def to_yaml(bib)
81
+ raise NotImplementedError, "#{self.class}#to_yaml method must be implemented"
82
+ end
81
83
 
82
- def to_xml(bib)
83
- raise NotImplementedError, "#{self.class}#to_xml method must be implemented"
84
- end
84
+ def to_xml(bib)
85
+ raise NotImplementedError, "#{self.class}#to_xml method must be implemented"
86
+ end
85
87
 
86
- def to_bibxml(bib)
87
- raise NotImplementedError, "#{self.class}#to_bibxml method must be implemented"
88
+ def to_bibxml(bib)
89
+ raise NotImplementedError, "#{self.class}#to_bibxml method must be implemented"
90
+ end
88
91
  end
89
92
  end
90
93
  end
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Core
3
- VERSION = "0.0.11".freeze
3
+ VERSION = "0.0.13".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.13
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-03-30 00:00:00.000000000 Z
11
+ date: 2026-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri