relaton-bib 1.18.5 → 1.19.1

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: 78cb618453b32794d9e5583b0985965b7dbd449655a86350e3e768bae2ce62fc
4
- data.tar.gz: c9588e46e7bac0c6af6253d871642a607be7760a25c723f963bb9abb445fbbc8
3
+ metadata.gz: 20fdd20c795644afb49d384f59a61147d4161e0f10de362996a6537976bf1e2e
4
+ data.tar.gz: 1d5f51e63402f944d4fad44e1884f8661af541a3cab52b37e46d2713acbf5d57
5
5
  SHA512:
6
- metadata.gz: 0434d911a3c19805872da208af341c8750d12bbede958d18e24bece3b74b3852ac9623675aa50b01a9d525639578b314e73f00560dc735ed5c375f951e612582
7
- data.tar.gz: ec8c14e1e5da20d4c4fed885acb055e5bb28a38c2019bef254fc3381644deb8e1fff85c873e7dbd67a496aff52cc99d575b9bfc7a15437721af8fb0523704947
6
+ metadata.gz: e069c6c9ee0b670b354f0409993de0ded12e11515bc771b5da1b178345669b48d3328ffd13d14e30ebf5dbe56380500e7f7c1912d75482b438c0348f6b402021
7
+ data.tar.gz: ba884104669e91900dfaca9ddbfa4ac6449b0bff33c6296f6bcb71947c3455c31e725eee3baeda12974a82e9861c3546ab45556a6c98aedc9f5f2812046ff8eb
@@ -11,3 +11,5 @@ on:
11
11
  jobs:
12
12
  rake:
13
13
  uses: relaton/support/.github/workflows/rake.yml@main
14
+ secrets:
15
+ pat_token: ${{ secrets.RELATON_CI_PAT_TOKEN }}
data/README.adoc CHANGED
@@ -27,24 +27,13 @@ Or install it yourself as:
27
27
 
28
28
  == Usage
29
29
 
30
- === Configuration
31
-
32
- 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 `RelatonBib.configure` block.
30
+ === Create bibliographic item
33
31
 
34
32
  [source,ruby]
35
33
  ----
36
34
  require 'relaton_bib'
37
35
  => true
38
36
 
39
- RelatonBib.configure do |config|
40
- config.logger.level = Logger::DEBUG
41
- end
42
- ----
43
-
44
- === Create bibliographic item
45
-
46
- [source,ruby]
47
- ----
48
37
  hash = YAML.load_file "spec/examples/bib_item.yml"
49
38
  => {"id"=>"ISOTC211",
50
39
  "fetched"=>"2022-05-02",
@@ -304,6 +293,10 @@ item.to_bibxml
304
293
  </reference>"
305
294
  ----
306
295
 
296
+ === Logging
297
+
298
+ RelatonBib uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the https://github.com/relaton/relaton-logger#usage[relaton-logger] documentation.
299
+
307
300
  == Development
308
301
 
309
302
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -244,6 +244,9 @@
244
244
  <data type="ID"/>
245
245
  </attribute>
246
246
  <attribute name="reviewer"/>
247
+ <optional>
248
+ <attribute name="type"/>
249
+ </optional>
247
250
  <optional>
248
251
  <attribute name="date">
249
252
  <data type="dateTime"/>
@@ -1,9 +1,9 @@
1
1
  {
2
- "relaton-models": "v1.2.8",
3
- "basicdoc-models": "v1.1.2",
2
+ "relaton-models": "v1.2.9",
3
+ "basicdoc-models": "v1.1.3",
4
4
  "metanorma-requirements-models": "v1.0.1",
5
5
  "relaton-model-ieee": "v1.0.1",
6
- "relaton-model-iso": "v1.0.0",
6
+ "relaton-model-iso": "v1.0.3",
7
7
  "relaton-model-iec": "v1.0.0",
8
8
  "relaton-model-bsi": "v1.0.2",
9
9
  "relaton-model-gb": "v1.0.0",
@@ -29,6 +29,6 @@
29
29
  "relaton-model-oasis": "v1.0.1",
30
30
  "relaton-model-jis": "v0.0.1",
31
31
  "relaton-model-etsi": "v0.0.3",
32
- "metanorma-model": "v1.2.11",
33
- "date": "2024-01-04T03:55:06Z"
32
+ "metanorma-model": "v1.3.0",
33
+ "date": "2024-02-21T18:15:14Z"
34
34
  }
@@ -18,7 +18,7 @@ module RelatonBib
18
18
  whole|table|annex|figure|note|list|example|volume|issue|time|anchor|
19
19
  locality:[a-zA-Z0-9_]+}x
20
20
  unless type&.match? type_ptrn
21
- Util.warn "WARNING: invalid locality type: `#{type}`"
21
+ Util.warn "Invalid locality type: `#{type}`"
22
22
  end
23
23
 
24
24
  @type = type
@@ -207,7 +207,7 @@ module RelatonBib
207
207
  # @option link [String] :content
208
208
  def initialize(**args)
209
209
  if args[:type] && !TYPES.include?(args[:type])
210
- Util.warn %{WARNING: type `#{args[:type]}` is invalid.}
210
+ Util.warn %{Type `#{args[:type]}` is invalid.}
211
211
  end
212
212
 
213
213
  @title = if args[:title].is_a?(TypedTitleStringCollection)
@@ -10,18 +10,6 @@ module RelatonBib
10
10
  end
11
11
 
12
12
  class Configuration
13
- PROGNAME = "relaton-bib".freeze
14
-
15
- attr_accessor :logger
16
-
17
- def initialize
18
- @logger = ::Logger.new $stderr
19
- @logger.level = ::Logger::WARN
20
- @logger.progname = self.class::PROGNAME
21
- @logger.formatter = proc do |_severity, _datetime, progname, msg|
22
- "[#{progname}] #{msg}\n"
23
- end
24
- end
25
13
  end
26
14
 
27
15
  extend Config
@@ -22,7 +22,7 @@ module RelatonBib
22
22
  # @param description [Array<String>]
23
23
  def initialize(**args)
24
24
  if args[:type] && !TYPES.include?(args[:type])
25
- Util.warn %{WARNING: Contributor's type `#{args[:type]}` is invalid.}
25
+ Util.warn %{Contributor's type `#{args[:type]}` is invalid.}
26
26
  end
27
27
 
28
28
  @type = args[:type]
@@ -30,6 +30,12 @@ module RelatonBib
30
30
  @formatted_address = args[:formatted_address] unless args[:city] && args[:country]
31
31
  end
32
32
 
33
+ def ==(other)
34
+ street == other.street && city == other.city && state == other.state &&
35
+ country == other.country && postcode == other.postcode &&
36
+ formatted_address == other.formatted_address
37
+ end
38
+
33
39
  # @param doc [Nokogiri::XML::Document]
34
40
  def to_xml(doc) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
35
41
  doc.address do
@@ -100,6 +106,10 @@ module RelatonBib
100
106
  @value = value
101
107
  end
102
108
 
109
+ def ==(other)
110
+ type == other.type && subtype == other.subtype && value == other.value
111
+ end
112
+
103
113
  # @param builder [Nokogiri::XML::Document]
104
114
  def to_xml(builder)
105
115
  node = builder.send type, value
@@ -144,6 +154,10 @@ module RelatonBib
144
154
  @description = description
145
155
  end
146
156
 
157
+ def ==(other)
158
+ name == other.name && organization == other.organization && description == other.description
159
+ end
160
+
147
161
  # @param opts [Hash]
148
162
  # @option opts [Nokogiri::XML::Builder] :builder XML builder
149
163
  # @option opts [String] :lang language
@@ -224,6 +238,10 @@ module RelatonBib
224
238
  @contact = contact
225
239
  end
226
240
 
241
+ def ==(other)
242
+ uri == other.uri && contact == other.contact
243
+ end
244
+
227
245
  # Returns url.
228
246
  # @return [String]
229
247
  def url
@@ -46,7 +46,7 @@ module RelatonBib
46
46
  source_locality: [])
47
47
  type = "obsoletes" if type == "Now withdrawn"
48
48
  unless self.class::TYPES.include? type
49
- Util.warn "WARNING: invalid relation type: `#{type}`"
49
+ Util.warn "Invalid relation type: `#{type}`"
50
50
  end
51
51
  @type = type
52
52
  @description = description
@@ -16,6 +16,10 @@ module RelatonBib
16
16
  super content, language, script
17
17
  end
18
18
 
19
+ def ==(other)
20
+ super && initial == other.initial
21
+ end
22
+
19
23
  def to_s
20
24
  content.nil? ? initial : super
21
25
  end
@@ -25,6 +25,10 @@ module RelatonBib
25
25
  super(content, language, script)
26
26
  end
27
27
 
28
+ def ==(other)
29
+ super && format == other.format
30
+ end
31
+
28
32
  # @param builder [Nokogiri::XML::Builder]
29
33
  def to_xml(builder)
30
34
  builder.parent["format"] = format if format
@@ -37,6 +37,11 @@ module RelatonBib
37
37
  @completename = args[:completename]
38
38
  end
39
39
 
40
+ def ==(other)
41
+ surname == other.surname && abbreviation == other.abbreviation && completename == other.completename &&
42
+ forename == other.forename && initials == other.initials && addition == other.addition && prefix == other.prefix
43
+ end
44
+
40
45
  # @param opts [Hash]
41
46
  # @option opts [Nokogiri::XML::Builder] :builder XML builder
42
47
  # @option opts [String] :lang language
@@ -358,7 +358,7 @@ module RelatonBib
358
358
  if rel[:bibitem]
359
359
  rel[:bibitem] = bib_item hash_to_bib(rel[:bibitem])
360
360
  else
361
- Util.warn "WARNING: bibitem missing: `#{rel}`"
361
+ Util.warn "Bibitem missing: `#{rel}`"
362
362
  rel[:bibitem] = nil
363
363
  end
364
364
  end
@@ -29,6 +29,12 @@ module RelatonBib
29
29
  @longdesc = args[:longdesc]
30
30
  end
31
31
 
32
+ def ==(other)
33
+ other.is_a?(Image) && id == other.id && src == other.src && mimetype == other.mimetype &&
34
+ filename == other.filename && width == other.width && height == other.height &&
35
+ alt == other.alt && title == other.title && longdesc == other.longdesc
36
+ end
37
+
32
38
  #
33
39
  # Converts the image object to XML format.
34
40
  #
@@ -37,6 +37,12 @@ module RelatonBib
37
37
  end
38
38
  end
39
39
 
40
+ def ==(other)
41
+ return false unless other.is_a? LocalizedString
42
+
43
+ content == other.content && language == other.language && script == other.script
44
+ end
45
+
40
46
  #
41
47
  # String representation.
42
48
  #
@@ -25,6 +25,10 @@ module RelatonBib
25
25
  @value = value
26
26
  end
27
27
 
28
+ def ==(other)
29
+ type == other.type && value == other.value
30
+ end
31
+
28
32
  # @param builder [Nokogiri::XML::Builder]
29
33
  def to_xml(builder)
30
34
  builder.identifier(value, type: type)
@@ -90,6 +94,12 @@ module RelatonBib
90
94
  @logo = args[:logo]
91
95
  end
92
96
 
97
+ def ==(other)
98
+ name == other.name && abbreviation == other.abbreviation &&
99
+ subdivision == other.subdivision && identifier == other.identifier &&
100
+ logo == other.logo && super
101
+ end
102
+
93
103
  # @param opts [Hash]
94
104
  # @option opts [Nokogiri::XML::Builder] :builder XML builder
95
105
  # @option opts [String] :lang language
@@ -2,16 +2,15 @@ module RelatonBib
2
2
  module Util
3
3
  extend self
4
4
 
5
- def method_missing(...)
6
- logger.send(...)
7
- end
5
+ PROGNAME = "relaton-bib".freeze
8
6
 
9
- def respond_to_missing?(method_name, include_private = false)
10
- logger.respond_to?(method_name) || super
7
+ def method_missing(method_name, msg = nil, prog = nil, **opts, &block)
8
+ prog ||= self::PROGNAME
9
+ Relaton.logger_pool.send method_name, msg, prog, **opts, &block
11
10
  end
12
11
 
13
- def logger
14
- RelatonBib.configuration.logger
12
+ def respond_to_missing?(method_name, include_private = false)
13
+ Relaton.logger_pool.respond_to?(method_name) || super
15
14
  end
16
15
  end
17
16
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonBib
2
- VERSION = "1.18.5".freeze
2
+ VERSION = "1.19.1".freeze
3
3
  end
@@ -17,7 +17,7 @@ module RelatonBib
17
17
  if bibitem
18
18
  bib_item item_data(bibitem)
19
19
  else
20
- Util.warn "WARNING: can't find bibitem or bibdata element in the XML"
20
+ Util.warn "Can't find bibitem or bibdata element in the XML"
21
21
  nil
22
22
  end
23
23
  end
data/lib/relaton_bib.rb CHANGED
@@ -1,9 +1,9 @@
1
+ require "relaton/logger"
1
2
  require "forwardable"
2
3
  require "yaml"
3
4
  require "htmlentities"
4
5
  require "relaton_bib/version"
5
6
  require "relaton_bib/deep_dup"
6
- require "relaton_bib/config"
7
7
  require "relaton_bib/util"
8
8
  require "relaton_bib/localized_string"
9
9
  require "relaton_bib/forename"
data/relaton-bib.gemspec CHANGED
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency "htmlentities"
29
29
  spec.add_dependency "iso639"
30
30
  spec.add_dependency "nokogiri", "~> 1.16"
31
+ spec.add_dependency "relaton-logger", "~> 0.2.0"
31
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-bib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.5
4
+ version: 1.19.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-06-22 00:00:00.000000000 Z
11
+ date: 2024-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.16'
83
+ - !ruby/object:Gem::Dependency
84
+ name: relaton-logger
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.2.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.2.0
83
97
  description: 'RelatonBib: Ruby XMLDOC impementation.'
84
98
  email:
85
99
  - open.source@ribose.com