relaton-plateau 1.19.3 → 1.19.4

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: 564c9b97d0c81b9479fe0c6bd4fcff8004b61821efffd19beda099fba6e72cbb
4
- data.tar.gz: 3e80de9a63e4a4c4e9439ec5b3ab9ce05b57710ffea486b6e8b669fb167bf7be
3
+ metadata.gz: 9440584ea13e611d6139c74cd9ba79bbde532c76e2ba43d2fbc47c4fbe00388c
4
+ data.tar.gz: cdb45b8fbb9a1d27d7c3580788056a3f9fa38b727d69444b1789ada6bd203e8b
5
5
  SHA512:
6
- metadata.gz: 89c7bea4e9de29a64b9436f8c824cd8364a82658f2250fd882c31cc560a3c674ff402db657046e4cb7a4cedeba10a1fff6fd689285e40cc979c416b9402cb41e
7
- data.tar.gz: 68b6f8bf152cad146f811458f8e421beb7a22772e4999623f10e3a2a39a03d89689178c905e02c13f516910b7a2acc6796f5f7288b006aa335ac92fa8af26137
6
+ metadata.gz: 6ea8f22a10154239a499e018756b3cfb8d84a7647860881f3b81c7ba4732d374d6a6db5f464d916fd6ceda68aaed023e7b5914399cbdbc8c07d3992906ce9914
7
+ data.tar.gz: b380d9c2cdd1e311fd5e66948aedcf95e1645aa8c14abdb3d4140289cf48b3523325aa401fc34a85d8a22b1d41670f78e1b0a9083af91d1415ec43d67c9695a7
data/README.adoc CHANGED
@@ -33,13 +33,36 @@ Or install it yourself as:
33
33
 
34
34
  === Fetching
35
35
 
36
+ ==== Fetching Technical Reports
37
+
36
38
  [source,ruby]
37
39
  ----
38
40
  require "relaton/plateau"
41
+ Relaton::Plateau::Bibliography.get("PLATEAU Technical Report #00")
42
+ [relaton-plateau] INFO: (PLATEAU Technical Report #00) Fetching ...
43
+ [relaton-plateau] INFO: (PLATEAU Technical Report #00) Found `PLATEAU Technical Report #00`
44
+ => #<Relaton::Plateau::BibItem:0x00000001238cfc98
45
+ ...
46
+ ----
47
+
48
+ ==== Fetching Handbooks unversioned
49
+
50
+ [source,ruby]
51
+ ----
52
+ Relaton::Plateau::Bibliography.get("PLATEAU Handbook #00")
53
+ [relaton-plateau] INFO: (PLATEAU Handbook #00) Fetching ...
54
+ [relaton-plateau] INFO: (PLATEAU Handbook #00) Found `PLATEAU Handbook #00`
55
+ => #<Relaton::Plateau::BibItem:0x00000001238c7598
56
+ ...
57
+ ----
39
58
 
40
- bib = Relaton::Plateau::Bibliography.get("PLATEAU Handbook #00 第1.0版")
41
- [relaton-plateau] INFO: (PLATEAU Handbook #00 第1.0版) Fetching ...
42
- [relaton-plateau] INFO: (PLATEAU Handbook #00 第1.0版) Found `PLATEAU Handbook #00 第1.0版`
59
+ ==== Fetching Handbooks versioned
60
+
61
+ [source,ruby]
62
+ ----
63
+ bib = Relaton::Plateau::Bibliography.get("PLATEAU Handbook #00 1.0")
64
+ [relaton-plateau] INFO: (PLATEAU Handbook #00 1.0) Fetching ...
65
+ [relaton-plateau] INFO: (PLATEAU Handbook #00 1.0) Found `PLATEAU Handbook #00 1.0`
43
66
  => #<Relaton::Plateau::BibItem:0x0000000104afbcc0
44
67
  ...
45
68
  ----
@@ -52,15 +75,15 @@ bib = Relaton::Plateau::Bibliography.get("PLATEAU Handbook #00 第1.0版")
52
75
  ----
53
76
  # Render bibitem
54
77
  puts bib.to_xml
55
- <bibitem id="PLATEAUHandbook#00第1.0" type="standard" schema-version="v1.2.9">
78
+ <bibitem id="PLATEAUHandbook#001.0" type="standard" schema-version="v1.2.9">
56
79
  <title type="main" format="text/plain" language="ja" script="Jpan">3D都市モデルの導入ガイダンス</title>
57
80
  <title type="main" format="text/plain" language="en" script="Latn">Guidance on the Installation for 3D City Model</title>
58
81
  <uri type="pdf">https://www.mlit.go.jp/plateau/file/libraries/doc/plateau_doc_0000_ver01.pdf</uri>
59
- <docidentifier type="PLATEAU" primary="true">PLATEAU Handbook #00 1.0版</docidentifier>
82
+ <docidentifier type="PLATEAU" primary="true">PLATEAU Handbook #00 1.0</docidentifier>
60
83
  <date type="published">
61
84
  <on>2021-03-26</on>
62
85
  </date>
63
- <edition number="1.0">第1.0版</edition>
86
+ <edition number="1.0">1.0</edition>
64
87
  <abstract format="text/plain" language="ja" script="Jpan">地方自治体担当者や民間事業者等に向けた 3D都市モデル導入のためのガイダンス</abstract>
65
88
  </bibitem>
66
89
 
@@ -70,18 +93,18 @@ puts bib.to_xml(bibdata: true)
70
93
  <title type="main" format="text/plain" language="ja" script="Jpan">3D都市モデルの導入ガイダンス</title>
71
94
  <title type="main" format="text/plain" language="en" script="Latn">Guidance on the Installation for 3D City Model</title>
72
95
  <uri type="pdf">https://www.mlit.go.jp/plateau/file/libraries/doc/plateau_doc_0000_ver01.pdf</uri>
73
- <docidentifier type="PLATEAU" primary="true">PLATEAU Handbook #00 1.0版</docidentifier>
96
+ <docidentifier type="PLATEAU" primary="true">PLATEAU Handbook #00 1.</docidentifier>
74
97
  <date type="published">
75
98
  <on>2021-03-26</on>
76
99
  </date>
77
- <edition number="1.0">第1.0版</edition>
100
+ <edition number="1.0">1.0</edition>
78
101
  <abstract format="text/plain" language="ja" script="Jpan">地方自治体担当者や民間事業者等に向けた 3D都市モデル導入のためのガイダンス</abstract>
79
102
  <ext>
80
103
  <doctype>handbook</doctype>
81
104
  <structuredidentifier type="Handbook">
82
105
  <agency>PLATEAU</agency>
83
106
  <docnumber>00</docnumber>
84
- <edition>第1.0版</edition>
107
+ <edition>1.0</edition>
85
108
  </structuredidentifier>
86
109
  <cover>
87
110
  <image src="https://www.mlit.go.jp//plateau/uploads/2022/06/1@2x.jpg" mimetype="image/jpeg"/>
@@ -97,7 +120,7 @@ puts bib.to_xml(bibdata: true)
97
120
  puts bib.to_hash.to_yaml
98
121
  ---
99
122
  schema-version: v1.2.9
100
- id: PLATEAUHandbook#00第1.0
123
+ id: PLATEAUHandbook#001.0
101
124
  title:
102
125
  - content: 3D都市モデルの導入ガイダンス
103
126
  language:
@@ -118,14 +141,14 @@ link:
118
141
  type: pdf
119
142
  type: standard
120
143
  docid:
121
- - id: 'PLATEAU Handbook #00 1.0'
144
+ - id: 'PLATEAU Handbook #00 1.0'
122
145
  type: PLATEAU
123
146
  primary: true
124
147
  date:
125
148
  - type: published
126
149
  value: '2021-03-26'
127
150
  edition:
128
- content: 1.0
151
+ content: 1.0
129
152
  number: '1.0'
130
153
  revdate: '2021-03-26'
131
154
  abstract:
@@ -142,7 +165,7 @@ structuredidentifier:
142
165
  type: Handbook
143
166
  agency:
144
167
  - PLATEAU
145
- edition: 1.0
168
+ edition: 1.0
146
169
  ext:
147
170
  cover:
148
171
  image:
@@ -156,7 +179,7 @@ ext:
156
179
  [source,ruby]
157
180
  ----
158
181
  puts bib.to_bibxml
159
- <reference anchor="PLATEAU.Handbook.#00.第1.0">
182
+ <reference anchor="PLATEAU.Handbook.#00.1.0">
160
183
  <front>
161
184
  <title>3D都市モデルの導入ガイダンス</title>
162
185
  <date year="2021" month="March" day="26"/>
@@ -172,7 +195,7 @@ puts bib.to_bibxml
172
195
  puts bib.to_asciibib
173
196
  [%bibitem]
174
197
  == {blank}
175
- id:: PLATEAUHandbook#00第1.0
198
+ id:: PLATEAUHandbook#001.0
176
199
  title::
177
200
  title.type:: main
178
201
  title.content:: 3D都市モデルの導入ガイダンス
@@ -188,8 +211,8 @@ title.format:: text/plain
188
211
  type:: standard
189
212
  docid.type:: PLATEAU
190
213
  docid.primary:: true
191
- docid.id:: PLATEAU Handbook #00 1.0
192
- edition.content:: 1.0
214
+ docid.id:: PLATEAU Handbook #00 1.0
215
+ edition.content:: 1.0
193
216
  edition.number:: 1.0
194
217
  date.type:: published
195
218
  date.on:: 2021-03-26
@@ -203,7 +226,7 @@ doctype.type:: handbook
203
226
  structured_identifier.docnumber:: 00
204
227
  structured_identifier.agency:: PLATEAU
205
228
  structured_identifier.type:: Handbook
206
- structured_identifier.edition:: 1.0
229
+ structured_identifier.edition:: 1.0
207
230
  cover.image.src:: https://www.mlit.go.jp//plateau/uploads/2022/06/1@2x.jpg
208
231
  cover.image.mimetype:: image/jpeg
209
232
  filesize:: 18381880
@@ -11,7 +11,7 @@ module Relaton
11
11
  attr_reader :stagename
12
12
 
13
13
  # @return [Integer, nil]
14
- attr_reader :filesize
14
+ attr_accessor :filesize
15
15
 
16
16
  def initialize(**args)
17
17
  @cover = args.delete(:cover)
@@ -72,6 +72,20 @@ module Relaton
72
72
  output
73
73
  end
74
74
 
75
+ def to_all_editions(hits)
76
+ me = deep_clone
77
+ me.docidentifier.each(&:remove_edition)
78
+ me.id.sub!(/#{Regexp.escape(me.edition.content)}$/, "")
79
+ me.instance_variable_set :@edition, nil
80
+ me.date = []
81
+ me.instance_variable_set :@link, []
82
+ me.filesize = nil
83
+ hits.each do |h|
84
+ me.relation << RelatonBib::DocumentRelation.new(type: "hasEdition", bibitem: h.bibitem)
85
+ end
86
+ me
87
+ end
88
+
75
89
  private
76
90
 
77
91
  def has_ext_data?
@@ -24,20 +24,15 @@ module Relaton
24
24
  end
25
25
 
26
26
  def search(code)
27
- rows = index.search { |r| r[:id] == code }
27
+ all_editions = code.match?(/Handbook #\d+$/)
28
+ rows = index.search do |r|
29
+ id = all_editions ? r[:id].sub(/ \d+\.\d+$/, "") : r[:id]
30
+ id == code
31
+ end
28
32
  return unless rows.any?
29
33
 
30
- row = rows.sort_by { |r| r[:id] }.last
31
- fetch_doc code, **row
32
- end
33
-
34
- def fetch_doc(code, id:, file:)
35
- resp = Net::HTTP.get_response URI("#{GHURL}#{file}")
36
- return unless resp.is_a? Net::HTTPSuccess
37
-
38
- hash = YAML.load(resp.body)
39
- args = HashConverter.hash_to_bib hash
40
- BibItem.new(**args)
34
+ hits = rows.map { |r| Hit.new(**r) }
35
+ all_editions ? hits[0].bibitem.to_all_editions(hits) : hits[0].bibitem
41
36
  end
42
37
  end
43
38
  end
@@ -0,0 +1,9 @@
1
+ module Relaton
2
+ module Plateau
3
+ class Docidentifier < RelatonBib::DocumentIdentifier
4
+ def remove_edition
5
+ @id.sub!(/ \d+\.\d+$/, "")
6
+ end
7
+ end
8
+ end
9
+ end
@@ -15,11 +15,11 @@ module Relaton
15
15
  private
16
16
 
17
17
  def edition
18
- @edition ||= @version["title"].split.first
18
+ @edition ||= @version["title"].split.first.match(/[\d.]+/).to_s
19
19
  end
20
20
 
21
- def parse_docid
22
- super << create_docid("PLATEAU Handbook ##{@entry["slug"]} #{edition}")
21
+ def parse_docnumber
22
+ "Handbook ##{@entry["slug"]} #{edition}"
23
23
  end
24
24
 
25
25
  def parse_title
@@ -42,6 +42,10 @@ module Relaton
42
42
  BibItem.new(**item_hash)
43
43
  end
44
44
 
45
+ def create_docid(**args)
46
+ Docidentifier.new(**args)
47
+ end
48
+
45
49
  def create_doctype(**args)
46
50
  DocumentType.new(**args)
47
51
  end
@@ -0,0 +1,27 @@
1
+ module Relaton
2
+ module Plateau
3
+ class Hit
4
+ def initialize(**args)
5
+ @id = args[:id]
6
+ @file = args[:file]
7
+ end
8
+
9
+ def bibitem
10
+ return @bibitem if defined? @bibitem
11
+ @bibitem = fetch_doc
12
+ end
13
+
14
+ private
15
+
16
+ def fetch_doc
17
+ resp = Net::HTTP.get_response URI("#{Bibliography::GHURL}#{@file}")
18
+ return unless resp.is_a? Net::HTTPSuccess
19
+
20
+ hash = YAML.load(resp.body)
21
+ args = HashConverter.hash_to_bib hash
22
+ args[:fetched] = Date.today.to_s
23
+ BibItem.new(**args)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,7 +1,8 @@
1
1
  module Relaton
2
2
  module Plateau
3
+ # Base class for Plateau parsers
3
4
  class Parser
4
- ATTRIS = %i[docid title abstract cover edition type doctype subdoctype
5
+ ATTRIS = %i[docid docnumber title abstract cover edition type doctype subdoctype
5
6
  date link contributor filesize keyword structuredidentifier].freeze
6
7
 
7
8
  def initialize(item)
@@ -17,10 +18,14 @@ module Relaton
17
18
 
18
19
  private
19
20
 
20
- def parse_docid; [] end
21
+ def parse_docid
22
+ [create_docid("PLATEAU #{parse_docnumber}")]
23
+ end
24
+
25
+ def parse_docnumber; end
21
26
 
22
27
  def create_docid(id)
23
- RelatonBib::DocumentIdentifier.new(type: "PLATEAU", id: id, primary: true)
28
+ Docidentifier.new(type: "PLATEAU", id: id, primary: true)
24
29
  end
25
30
 
26
31
  def create_formatted_string(content, lang = "ja", script = "Jpan")
@@ -8,8 +8,8 @@ module Relaton
8
8
 
9
9
  private
10
10
 
11
- def parse_docid
12
- super << create_docid("PLATEAU Technical Report ##{@entry["slug"]}")
11
+ def parse_docnumber
12
+ "Technical Report ##{@entry["slug"]}"
13
13
  end
14
14
 
15
15
  def parse_abstract
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Relaton
4
4
  module Plateau
5
- VERSION = "1.19.3"
5
+ VERSION = "1.19.4"
6
6
  end
7
7
  end
@@ -54,6 +54,10 @@ module Relaton
54
54
  BibItem.new(**item_hash)
55
55
  end
56
56
 
57
+ def create_docid(**args)
58
+ Docidentifier.new(**args)
59
+ end
60
+
57
61
  def create_doctype(type)
58
62
  DocumentType.new type: type.text, abbreviation: type[:abbreviation]
59
63
  end
@@ -4,8 +4,10 @@ require "relaton/index"
4
4
  require "relaton_bib"
5
5
  require_relative "plateau/version"
6
6
  require_relative "plateau/util"
7
+ require_relative "plateau/docidentifier"
7
8
  require_relative "plateau/document_type"
8
9
  require_relative "plateau/bibitem"
10
+ require_relative "plateau/hit"
9
11
  require_relative "plateau/bibliography"
10
12
  require_relative "plateau/xml_parser"
11
13
  require_relative "plateau/hash_converter"
@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency "base64"
28
28
  spec.add_dependency "relaton-index", "~> 0.2.12"
29
29
  spec.add_dependency "relaton-logger", "~> 0.2.0"
30
- spec.add_dependency "relaton-bib", "~> 1.19.3"
30
+ spec.add_dependency "relaton-bib", "~> 1.19.4"
31
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-plateau
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.3
4
+ version: 1.19.4
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-08-20 00:00:00.000000000 Z
11
+ date: 2024-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.19.3
61
+ version: 1.19.4
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.19.3
68
+ version: 1.19.4
69
69
  description: Retrieve Project PLATEAU bibliographic items.
70
70
  email:
71
71
  - open.source@ribose.com
@@ -93,10 +93,12 @@ files:
93
93
  - lib/relaton/plateau/bibitem.rb
94
94
  - lib/relaton/plateau/bibliography.rb
95
95
  - lib/relaton/plateau/cover.rb
96
+ - lib/relaton/plateau/docidentifier.rb
96
97
  - lib/relaton/plateau/document_type.rb
97
98
  - lib/relaton/plateau/fetcher.rb
98
99
  - lib/relaton/plateau/handbook_parser.rb
99
100
  - lib/relaton/plateau/hash_converter.rb
101
+ - lib/relaton/plateau/hit.rb
100
102
  - lib/relaton/plateau/parser.rb
101
103
  - lib/relaton/plateau/processor.rb
102
104
  - lib/relaton/plateau/stagename.rb