relaton-omg 1.16.0 → 1.16.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09695948d1a4ddc939f6b1d693c32c941461e1df4fa0cd450529dfad4e693730'
4
- data.tar.gz: c854b94cd8198b8694ddf3b23b361491290d2f1e34755ac0c1600f7aa65305b1
3
+ metadata.gz: bf765669d79fa3b144851fb1ed70d7a07e42001ec1db537042582caccad95eef
4
+ data.tar.gz: 796eede5c6f75112df5b0c410705cbda8381958b81e44fd58e2fa895547254c1
5
5
  SHA512:
6
- metadata.gz: 65505aeb7a4433c99880b155fee9edff0f3371daf48bb456cab07d8e4823de6b8829c4683ed470c90b8f49161f4957e2576cd04fcfe16b9c85250dee7693dd1f
7
- data.tar.gz: 3ea62121336fe256c32dfbd78d4b6f26209de6f8a0efc5b3469b345e28cbc29ac6ccb21c0e58c3c8d33b296bd80aa77e02aeec4b83aae5e3f5dc85651535ec5d
6
+ metadata.gz: fbc567d8ce33479788dd18d656c6310185e15eabde27e687ffbe9baf85e3f11f3f0652e19950599cb2a279b79fe8512b20cfb7698eb739637cfceff0d0586982
7
+ data.tar.gz: af419bb675586598d1a04a3de0d00de23b1ad5b484f70acbddbc9b143167ca595737730fc6bca03d5601a8cb24e0191e54b48838efe18f9a33a4792b2edf802d
data/README.adoc CHANGED
@@ -31,6 +31,20 @@ Or install it yourself as:
31
31
 
32
32
  == Usage
33
33
 
34
+ === Configuration
35
+
36
+ Configuration is optional. The available option is `logger` which is a `Logger` instance. By default, the logger is `Logger.new($stderr)` with `Logger::WARN` level. To change the logger level, use `RelatonOmg.configure` block.
37
+
38
+ [source,ruby]
39
+ ----
40
+ require 'relaton_omg'
41
+ => true
42
+
43
+ RelatonOmg.configure do |config|
44
+ config.logger.level = Logger::DEBUG
45
+ end
46
+ ----
47
+
34
48
  === Search document
35
49
 
36
50
  Reference format is `OMG + {ACRONYM} + {VERSION}`
@@ -40,16 +54,16 @@ Reference format is `OMG + {ACRONYM} + {VERSION}`
40
54
 
41
55
  [source,ruby]
42
56
  ----
43
- require 'relaton_omg'
44
- => true
45
-
46
57
  item = RelatonOmg::OmgBibliography.get 'OMG AMI4CCM 1.0'
47
- => #<RelatonOmg::OmgBibliographicItem:0x007fda17eab2f0
58
+ [relaton-omg] (OMG AMI4CCM 1.0) Fetching from www.omg.org ...
59
+ [relaton-omg] (OMG AMI4CCM 1.0) Found: `AMI4CCM 1.0`
60
+ => #<RelatonOmg::OmgBibliographicItem:0x000000010435a520
48
61
  ...
49
62
 
50
63
  # Return nil if the document doesn't exist.
51
64
  RelatonOmg::OmgBibliography.get 'OMG 1111'
52
- [relaton-omg] no document found for "OMG 1111" reference.
65
+ [relaton-omg] (OMG 1111) Fetching from www.omg.org ...
66
+ [relaton-omg] (OMG 1111) Not found.
53
67
  => nil
54
68
  ----
55
69
 
@@ -0,0 +1,10 @@
1
+ module RelatonOmg
2
+ module Config
3
+ include RelatonBib::Config
4
+ end
5
+ extend Config
6
+
7
+ class Configuration < RelatonBib::Configuration
8
+ PROGNAME = "relaton-omg".freeze
9
+ end
10
+ end
@@ -15,7 +15,14 @@ module RelatonOmg
15
15
  # @param opts [Hash] options
16
16
  # @return [RelatonOmg::OmgBibliographicItem]
17
17
  def get(code, _year = nil, _opts = {})
18
- search code
18
+ Util.warn "(#{code}) Fetching from www.omg.org ..."
19
+ result = search code
20
+ if result
21
+ Util.warn "(#{code}) Found: `#{result.docidentifier.first.id}`"
22
+ else
23
+ Util.warn "(#{code}) Not found."
24
+ end
25
+ result
19
26
  end
20
27
  end
21
28
  end
@@ -14,12 +14,9 @@ module RelatonOmg
14
14
  doc = Nokogiri::HTML OpenURI.open_uri(url, open_timeout: 10)
15
15
  OmgBibliographicItem.new(**item(doc, acronym))
16
16
  rescue OpenURI::HTTPError, URI::InvalidURIError, Net::OpenTimeout => e
17
- if e.is_a?(URI::InvalidURIError) || e.io.status[0] == "404"
18
- warn %{[relaton-omg] no document found for "#{ref}" reference.}
19
- return
20
- end
17
+ return if e.is_a?(URI::InvalidURIError) || e.io.status[0] == "404"
21
18
 
22
- raise RelatonBib::RequestError, "Unable acces #{url} (#{e.io.status.join(" ")}"
19
+ raise RelatonBib::RequestError, "Unable acces #{url} (#{e.io.status.join(' ')}"
23
20
  end
24
21
 
25
22
  private
@@ -121,4 +118,4 @@ module RelatonOmg
121
118
  end
122
119
  end
123
120
  end
124
- end
121
+ end
@@ -0,0 +1,9 @@
1
+ module RelatonOmg
2
+ module Util
3
+ extend RelatonBib::Util
4
+
5
+ def self.logger
6
+ RelatonOmg.configuration.logger
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module RelatonOmg
2
- VERSION = "1.16.0".freeze
2
+ VERSION = "1.16.2".freeze
3
3
  end
data/lib/relaton_omg.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require "nokogiri"
2
2
  require "relaton_bib"
3
3
  require "relaton_omg/version"
4
+ require "relaton_omg/config"
5
+ require "relaton_omg/util"
4
6
  require "relaton_omg/scrapper"
5
7
  require "relaton_omg/omg_bibliography"
6
8
  require "relaton_omg/omg_bibliographic_item"
@@ -11,9 +13,9 @@ module RelatonOmg
11
13
  # Returns hash of XML reammar
12
14
  # @return [String]
13
15
  def self.grammar_hash
14
- gem_path = File.expand_path "..", __dir__
15
- grammars_path = File.join gem_path, "grammars", "*"
16
- grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
17
- Digest::MD5.hexdigest grammars
16
+ # gem_path = File.expand_path "..", __dir__
17
+ # grammars_path = File.join gem_path, "grammars", "*"
18
+ # grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
19
+ Digest::MD5.hexdigest RelatonOmg::VERSION + RelatonBib::VERSION # grammars
18
20
  end
19
- end
21
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-omg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.0
4
+ version: 1.16.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-03 00:00:00.000000000 Z
11
+ date: 2023-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: relaton-bib
@@ -51,11 +51,13 @@ files:
51
51
  - grammars/relaton-omg-compile.rng
52
52
  - grammars/relaton-omg.rng
53
53
  - lib/relaton_omg.rb
54
+ - lib/relaton_omg/config.rb
54
55
  - lib/relaton_omg/hash_converter.rb
55
56
  - lib/relaton_omg/omg_bibliographic_item.rb
56
57
  - lib/relaton_omg/omg_bibliography.rb
57
58
  - lib/relaton_omg/processor.rb
58
59
  - lib/relaton_omg/scrapper.rb
60
+ - lib/relaton_omg/util.rb
59
61
  - lib/relaton_omg/version.rb
60
62
  - lib/relaton_omg/xml_parser.rb
61
63
  - relaton_omg.gemspec