relaton-bib 1.17.1 → 1.17.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: a507a7fa74bc5be4e5148c8f80f91dc77a602b356187168d412beb958d30ad67
4
- data.tar.gz: 41d821df9469b709f76d98288d6ec80fa0959d3d6e7ab867f08095283ed3eaf9
3
+ metadata.gz: 46d18122233ea0790d42f293b18648a094be8739cac59714cdf2419a5510062b
4
+ data.tar.gz: 918ef1f018e38e6cdfc0f0cafdf886311794910af463a08f15e5d21088e21062
5
5
  SHA512:
6
- metadata.gz: 0d1daace14ed81e05633e2340d26c1f591afcb8d5ea8b742c3cabe66e74f92def40966a20fadbd182b1b4808e6cbfa3cae9f1abb3dd40035ad2c2bc118392d85
7
- data.tar.gz: a08ae4ae1f9c3563c242d8940172cf44bd23e182237b39d91a37f572719694695bbaf9b5805bfcafb76e201eaead8506a8bd878ec8f0aed7722c7d6815e19441
6
+ metadata.gz: 61a55508abb720be6180365bbd839987eeadcdc38ccc6160d9c03453303f38ba4b4b16731d03236db4e5b767871bdb00b29aa5eab91ca70bf6b9e69eeab0b22f
7
+ data.tar.gz: 5e4400c78c97db49cbd30d4bf4f105dfa365ecc570a876a594c10389913190c2d5536412f76cc41458c18ea78ea3f0f5e90681a698f99213076a2995ced94a51
@@ -30,5 +30,5 @@
30
30
  "relaton-model-jis": "v0.0.1",
31
31
  "relaton-model-etsi": "v0.0.3",
32
32
  "metanorma-model": "v1.2.9",
33
- "date": "2023-12-02T16:19:25Z"
33
+ "date": "2023-12-04T16:12:14Z"
34
34
  }
@@ -78,54 +78,50 @@ module RelatonBib
78
78
 
79
79
  # @param bibtex [BibTeX::Entry]
80
80
  # @return [Array<Hash>]
81
- def fetch_contributor(bibtex) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
82
- contributor = []
83
- fetch_person(bibtex["author"]).each do |entity|
84
- contributor << { entity: entity, role: [{ type: "author" }] }
85
- end
81
+ def fetch_contributor(bibtex) # rubocop:disable Metrics/AbcSize
82
+ contribs = []
83
+ fetch_person(bibtex, "author") { |author| contribs << author }
84
+ fetch_person(bibtex, "editor") { |editor| contribs << editor }
86
85
 
87
- fetch_person(bibtex["editor"]).each do |entity|
88
- contributor << { entity: entity, role: [{ type: "editor" }] }
89
- end
86
+ fetch_org(bibtex["publisher"], "publisher") { |pub| contribs << pub }
87
+ fetch_org(bibtex["institution"], "distributor", "sponsor") { |distr| contribs << distr }
88
+ fetch_org(bibtex["organization"], "distributor", "sponsor") { |org| contribs << org }
89
+ fetch_org(bibtex["school"], "distributor", "sponsor") { |school| contribs << school }
90
90
 
91
- if bibtex["publisher"]
92
- contributor << { entity: { name: bibtex.publisher.to_s }, role: [{ type: "publisher" }] }
93
- end
91
+ fetch_howpublished(bibtex) { |pub| contribs << pub }
94
92
 
95
- if bibtex["institution"]
96
- contributor << {
97
- entity: { name: bibtex.institution.to_s },
98
- role: [{ type: "distributor", description: ["sponsor"] }],
99
- }
100
- end
93
+ contribs
94
+ end
101
95
 
102
- if bibtex["organization"]
103
- contributor << {
104
- entity: { name: bibtex.organization.to_s },
105
- role: [{ type: "distributor", description: ["sponsor"] }],
106
- }
107
- end
96
+ def fetch_howpublished(bibtex, &_)
97
+ return unless bibtex["howpublished"]
108
98
 
109
- if bibtex["school"]
110
- contributor << {
111
- entity: { name: bibtex.school.to_s },
112
- role: [{ type: "distributor", description: ["sponsor"] }],
113
- }
114
- end
115
- contributor
99
+ /\\publisher\{(?<name>.+)\},\\url\{(?<url>.+)\}/ =~ bibtex.howpublished.to_s
100
+ return unless name && url
101
+
102
+ name.gsub!(/\{\\?([^\\]+)\}/, '\1')
103
+ org = Organization.new(name: name, url: url)
104
+ yield entity: org, role: [{ type: "publisher" }]
105
+ end
106
+
107
+ def fetch_org(org, type, desc = nil, &_)
108
+ return unless org
109
+
110
+ role = { type: type }
111
+ role[:description] = [desc] if desc
112
+ yield entity: Organization.new(name: org.to_s), role: [role]
116
113
  end
117
114
 
118
115
  # @param bibtex [BibTeX::Entry]
119
116
  # @return [Array<RelatonBib::Person>]
120
- def fetch_person(person)
121
- return [] unless person
122
-
123
- person.map do |name|
117
+ def fetch_person(bibtex, role, &_) # rubocop:disable Metrics/AbcSize
118
+ bibtex[role]&.each do |name|
124
119
  parts = name.split ", "
125
120
  surname = LocalizedString.new parts.first
126
121
  fname = parts.size > 1 ? parts[1].split : []
127
122
  forename = fname.map { |fn| Forename.new content: fn }
128
- Person.new name: FullName.new(surname: surname, forename: forename)
123
+ name = FullName.new(surname: surname, forename: forename)
124
+ yield entity: Person.new(name: name), role: [{ type: role }]
129
125
  end
130
126
  end
131
127
 
@@ -147,7 +143,7 @@ module RelatonBib
147
143
 
148
144
  # @param bibtex [BibTeX::Entry]
149
145
  # @return [RelatonBib::BiblioNoteCollection]
150
- def fetch_note(bibtex)
146
+ def fetch_note(bibtex) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
151
147
  bibtex.select do |k, _v|
152
148
  %i[annote howpublished comment note content].include? k
153
149
  end.reduce(BiblioNoteCollection.new([])) do |mem, note|
@@ -156,6 +152,8 @@ module RelatonBib
156
152
  when :content then "tableOfContents"
157
153
  else note[0].to_s
158
154
  end
155
+ next mem if type == "howpublished" && note[1].to_s.match?(/^\\publisher\{.+\},\\url\{.+\}$/)
156
+
159
157
  mem << BiblioNote.new(type: type, content: note[1].to_s)
160
158
  end
161
159
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonBib
2
- VERSION = "1.17.1".freeze
2
+ VERSION = "1.17.2".freeze
3
3
  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.17.1
4
+ version: 1.17.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-12-03 00:00:00.000000000 Z
11
+ date: 2023-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable