relaton-bib 1.18.4 → 1.19.0

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: 8679abcdf3cc3df08c557a56be973ef54472d530eaa64369cad097d35a1a4066
4
- data.tar.gz: b75301c9af89e12b094d15353553ca25c6c4c455e83ee49b07f60f53852d1711
3
+ metadata.gz: '078eeaee528f7e51a51015dc49723903af554087be753a244d69ebb2d1c0ac83'
4
+ data.tar.gz: 1ab74dea087ac8a1a4366ed24630ca4869774cc8b8f938e275a3684e0a61ec69
5
5
  SHA512:
6
- metadata.gz: e9e3974f8afa4b5532fb792a9792e13679c9fa3bf45320f3339ad990c0a17325ca3f52696b24e27b0e06172af6bbe63cf53171d80572173c71f78899e39cde67
7
- data.tar.gz: 0befd12bbb263ead171ca64f1a0b698175801eb19a7ef29cd308a454d52fc06a4601e4b5255c933d0c1823c218ac4cefdd474a9ccad83807658f119f64c67754
6
+ metadata.gz: 62b65c967d716d9680b6e1ec1a361a3f1f2a0d48f032e793585b3630f1146a49897b2d2563c40e165bc04ceb437aeb7da70f7581945fb3f08a23563c79438e58
7
+ data.tar.gz: 34f6adc6c2998fe912879615f71079963331d83eb12cbb7d7bcff9c8ce4276da73b252aa8240cc105314a2f0aff786f401c99579a50a7df0255ac87673544059
@@ -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]
@@ -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
@@ -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
@@ -53,7 +53,7 @@ module RelatonBib
53
53
  # @param count [Integer] number of ids
54
54
  # @return [String]
55
55
  def to_asciibib(prefix = "", count = 1)
56
- pref = prefix.empty? ? prefix : prefix + "."
56
+ pref = prefix.empty? ? prefix : "#{prefix}."
57
57
  out = count > 1 ? "#{prefix}::\n" : ""
58
58
  out += "#{pref}type:: #{type}\n"
59
59
  out += "#{pref}value:: #{value}\n"
@@ -1,5 +1,6 @@
1
1
  module RelatonBib
2
2
  class Place
3
+
3
4
  # @return [String, nil]
4
5
  attr_reader :name, :city
5
6
 
@@ -76,24 +77,85 @@ module RelatonBib
76
77
  end
77
78
 
78
79
  class RegionType
80
+ STATES = {
81
+ "AK" => "Alaska",
82
+ "AL" => "Alabama",
83
+ "AR" => "Arkansas",
84
+ "AZ" => "Arizona",
85
+ "CA" => "California",
86
+ "CO" => "Colorado",
87
+ "CT" => "Connecticut",
88
+ "DC" => "District Of Columbia",
89
+ "DE" => "Delaware",
90
+ "FL" => "Florida",
91
+ "GA" => "Georgia",
92
+ "GU" => "Guam",
93
+ "HI" => "Hawaii",
94
+ "IA" => "Iowa",
95
+ "ID" => "Idaho",
96
+ "IL" => "Illinois",
97
+ "IN" => "Indiana",
98
+ "KS" => "Kansas",
99
+ "KY" => "Kentucky",
100
+ "LA" => "Louisiana",
101
+ "MA" => "Massachusetts",
102
+ "MD" => "Maryland",
103
+ "ME" => "Maine",
104
+ "MI" => "Michigan",
105
+ "MN" => "Minnesota",
106
+ "MO" => "Missouri",
107
+ "MS" => "Mississippi",
108
+ "MT" => "Montana",
109
+ "NC" => "North Carolina",
110
+ "ND" => "North Dakota",
111
+ "NE" => "Nebraska",
112
+ "NH" => "New Hampshire",
113
+ "NJ" => "New Jersey",
114
+ "NM" => "New Mexico",
115
+ "NV" => "Nevada",
116
+ "NY" => "New York",
117
+ "OH" => "Ohio",
118
+ "OK" => "Oklahoma",
119
+ "OR" => "Oregon",
120
+ "PA" => "Pennsylvania",
121
+ "PR" => "Puerto Rico",
122
+ "RI" => "Rhode Island",
123
+ "SC" => "South Carolina",
124
+ "SD" => "South Dakota",
125
+ "TN" => "Tennessee",
126
+ "TX" => "Texas",
127
+ "UT" => "Utah",
128
+ "VA" => "Virginia",
129
+ "VI" => "Virgin Islands",
130
+ "VT" => "Vermont",
131
+ "WA" => "Washington",
132
+ "WI" => "Wisconsin",
133
+ "WV" => "West Virginia",
134
+ "WY" => "Wyoming",
135
+ }.freeze
136
+
79
137
  # @return [Strign] name of region
80
138
  attr_reader :name
81
139
 
82
140
  # @return [Strign, nil] ISO code of region
83
141
  attr_reader :iso
84
142
 
85
- # @return [Boolean, nil] <description>
143
+ # @return [Boolean, nil]
86
144
  attr_reader :recommended
87
145
 
88
146
  #
89
- # Initialize region type.
147
+ # Initialize region type. Name or valid US state ISO code should be provided.
90
148
  #
91
- # @param [String] name name of region
149
+ # @param [String, nil] name name of region
92
150
  # @param [String, nil] iso ISO code of region
93
151
  # @param [Boolean, nil] recommended recommended region
94
152
  #
95
- def initialize(name:, iso: nil, recommended: nil)
96
- @name = name
153
+ def initialize(name: nil, iso: nil, recommended: nil)
154
+ unless name || STATES.key?(iso&.upcase)
155
+ raise ArgumentError, "`name` or valid US state ISO code should be provided"
156
+ end
157
+
158
+ @name = name || STATES[iso&.upcase]
97
159
  @iso = iso
98
160
  @recommended = recommended
99
161
  end
@@ -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.4".freeze
2
+ VERSION = "1.19.0".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
@@ -27,5 +27,6 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency "bibtex-ruby"
28
28
  spec.add_dependency "htmlentities"
29
29
  spec.add_dependency "iso639"
30
- spec.add_dependency "nokogiri", "~> 1.15.0"
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.4
4
+ version: 1.19.0
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-05-20 00:00:00.000000000 Z
11
+ date: 2024-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -72,14 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.15.0
75
+ version: '1.16'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.15.0
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