relaton-core 0.0.11 → 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: 5354feb75eac4e721a544831fc979cddaea15463aee96b6438782e832391ec02
4
- data.tar.gz: c09c53ba1f08adb6f7bb763947b2e3336271000de2960a5fb22d37f6b6eec18e
3
+ metadata.gz: 9dead65db427dc877d76ca902de6a029447fca540a79fd906817acc38b3e79ba
4
+ data.tar.gz: 6c8fa5f6bfe487660cfbba79d0a0496ace2d22afc28cf99e6aa75a3452b71b25
5
5
  SHA512:
6
- metadata.gz: 0a932957250c2a7b25b8f4ae3e7eff6aa16345ee5597be56677d6cb113af10b209ed191cc172c7413c0d3d66bafbc8bfaaf639430c262453740715cd5da8de0d
7
- data.tar.gz: be100629f5a0014a873a1e0c98dd63c7448ecb0235af63c330e464af48bc7cb9737dd112468c68a9d18b928f2e682b693615e555d9bdca9548e0baa5f67e51df
6
+ metadata.gz: 5e5a7584b4d7dfa733f474d860b5d549cbf766e726863a986b42c47bc5ffcc377b243a687a5178cdc55c39e49fccc390b1995dd0149aeba1a02668a7f90a1b94
7
+ data.tar.gz: acc985743c00f072b50f8a3cc16336a8f717dba9ff3a6aa48a9fdaa59bc4fbff5655f2b3db1c3e41ff54fab33f5bb55785024e8f0b66dd08132850c4ba2fd7e6
@@ -1,90 +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
- 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
+ File.join @output, "#{docid.downcase.gsub(/[.\s\/:-]+/, '-')}.#{@ext}"
66
+ end
66
67
 
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
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
77
78
 
78
- def to_yaml(bib)
79
- raise NotImplementedError, "#{self.class}#to_yaml method must be implemented"
80
- end
79
+ def to_yaml(bib)
80
+ raise NotImplementedError, "#{self.class}#to_yaml method must be implemented"
81
+ end
81
82
 
82
- def to_xml(bib)
83
- raise NotImplementedError, "#{self.class}#to_xml method must be implemented"
84
- end
83
+ def to_xml(bib)
84
+ raise NotImplementedError, "#{self.class}#to_xml method must be implemented"
85
+ end
85
86
 
86
- def to_bibxml(bib)
87
- 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
88
90
  end
89
91
  end
90
92
  end
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Core
3
- VERSION = "0.0.11".freeze
3
+ VERSION = "0.0.12".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.