relaton-core 0.0.10 → 0.0.12

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: d13d6988f523d9ebff1eb06a85102d821fed50cc9f7197a1c0ecf33409199032
4
- data.tar.gz: dd6baab05c3727ab3a0579cbcddb8cbf1df20bc15f8a2c3d628f04aab12cd30f
3
+ metadata.gz: 9dead65db427dc877d76ca902de6a029447fca540a79fd906817acc38b3e79ba
4
+ data.tar.gz: 6c8fa5f6bfe487660cfbba79d0a0496ace2d22afc28cf99e6aa75a3452b71b25
5
5
  SHA512:
6
- metadata.gz: a42b2edaa6de1f06cfb9b2a6473f83ca15b2718299881c9a764a9fdd05b5583a86e54101f3c3580835877bd2650457de24246334b594151d520e754996be1edf
7
- data.tar.gz: 27f33285d93a3747c219658932eee8e6635ce555cff64d44f0c8c1d571eb5b6be867cb1a4f1cf3c6ddba276b7f5a3784003e316433c38f875aea9adb0f06089c
6
+ metadata.gz: 5e5a7584b4d7dfa733f474d860b5d549cbf766e726863a986b42c47bc5ffcc377b243a687a5178cdc55c39e49fccc390b1995dd0149aeba1a02668a7f90a1b94
7
+ data.tar.gz: acc985743c00f072b50f8a3cc16336a8f717dba9ff3a6aa48a9fdaa59bc4fbff5655f2b3db1c3e41ff54fab33f5bb55785024e8f0b66dd08132850c4ba2fd7e6
@@ -1,87 +1,92 @@
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
- @gh_issue = Relaton::Logger::Channels::GhIssue.new(*gh_issue_channel)
40
- Relaton.logger_pool[:gh_issue] = Relaton::Logger::Log.new(@gh_issue, levels: [:error])
41
- @gh_issue
42
- end
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
46
+ end
43
47
 
44
- def gh_issue_channel
45
- raise NotImplementedError, "#{self.class}#gh_issue_channel method must be implemented"
46
- end
48
+ def gh_issue_channel
49
+ [ENV.fetch("GITHUB_REPOSITORY", nil), "Error fetching documents"]
50
+ end
47
51
 
48
- def repot_errors
49
- gh_issue # register the channel before logging
50
- @errors.select { |_, v| v }.each_key { |k| log_error "Failed to fetch #{k}" }
51
- gh_issue.create_issue
52
- 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
53
57
 
54
- def log_error(_msg)
55
- raise NoMatchingPatternError, "#{self.class}#log_error method must be implemented"
56
- end
58
+ def log_error(_msg)
59
+ raise NoMatchingPatternError, "#{self.class}#log_error method must be implemented"
60
+ end
57
61
 
58
- # @param [String] document ID
59
- # @return [String] filename based on PubID identifier
60
- def output_file(docid)
61
- File.join @output, "#{docid.downcase.gsub(/[.\s\/:-]+/, '-')}.#{@ext}"
62
- end
62
+ # @param [String] document ID
63
+ # @return [String] filename based on PubID identifier
64
+ def output_file(docid)
65
+ File.join @output, "#{docid.downcase.gsub(/[.\s\/:-]+/, '-')}.#{@ext}"
66
+ end
63
67
 
64
- #
65
- # Serialize bibliographic item
66
- #
67
- # @param [RelatonCcsds::BibliographicItem] bib <description>
68
- #
69
- # @return [String] serialized bibliographic item
70
- #
71
- def serialize(bib)
72
- send "to_#{@format}", bib
73
- end
68
+ #
69
+ # Serialize bibliographic item
70
+ #
71
+ # @param [RelatonCcsds::BibliographicItem] bib <description>
72
+ #
73
+ # @return [String] serialized bibliographic item
74
+ #
75
+ def serialize(bib)
76
+ send "to_#{@format}", bib
77
+ end
74
78
 
75
- def to_yaml(bib)
76
- raise NotImplementedError, "#{self.class}#to_yaml method must be implemented"
77
- end
79
+ def to_yaml(bib)
80
+ raise NotImplementedError, "#{self.class}#to_yaml method must be implemented"
81
+ end
78
82
 
79
- def to_xml(bib)
80
- raise NotImplementedError, "#{self.class}#to_xml method must be implemented"
81
- end
83
+ def to_xml(bib)
84
+ raise NotImplementedError, "#{self.class}#to_xml method must be implemented"
85
+ end
82
86
 
83
- def to_bibxml(bib)
84
- raise NotImplementedError, "#{self.class}#to_bibxml method must be implemented"
87
+ def to_bibxml(bib)
88
+ raise NotImplementedError, "#{self.class}#to_bibxml method must be implemented"
89
+ end
85
90
  end
86
91
  end
87
92
  end
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Core
3
- VERSION = "0.0.10".freeze
3
+ VERSION = "0.0.12".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.10
4
+ version: 0.0.12
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-27 00:00:00.000000000 Z
11
+ date: 2026-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri