relaton-ogc 1.9.2 → 1.9.3
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 +4 -4
- data/README.adoc +1 -1
- data/grammars/ogc.rng +13 -13
- data/lib/relaton_ogc/data_fetcher.rb +2 -0
- data/lib/relaton_ogc/hit.rb +12 -1
- data/lib/relaton_ogc/hit_collection.rb +39 -31
- data/lib/relaton_ogc/ogc_bibliography.rb +2 -1
- data/lib/relaton_ogc/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 98e672b4b0d18f3feb9eb6d825d7111e40f3ee97d3886fb452c30c41f4a1dcc0
|
|
4
|
+
data.tar.gz: c9d939a8086f497f95390fd927bb1dee14986bf1b24825a4d0394a3467d9ec3c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: de8f29ea78226046ce2138ebacbe2625b0f2b07a6b402d24c3eb5ffb4f9dec2f88062ea185eeb34c04ee363f138664df040342257d04bdbc44a5b5dab3fb2497
|
|
7
|
+
data.tar.gz: d158cfaa42d1ea4cca7bc60463414723d7f78e81a0d8671a9fe647f8d17fb6cf88098d1d46085999a4712f7ffc989a6bf8ad65b20303f949ec1718774e02b3f9
|
data/README.adoc
CHANGED
|
@@ -39,7 +39,7 @@ require 'relaton_ogc'
|
|
|
39
39
|
=> true
|
|
40
40
|
|
|
41
41
|
hits = RelatonOgc::OgcBibliography.search("OGC 19-025r1")
|
|
42
|
-
=> <RelatonOgc::HitCollection:0x007fcc8e085ba8 @ref=OGC 19-025r1 @fetched=
|
|
42
|
+
=> <RelatonOgc::HitCollection:0x007fcc8e085ba8 @ref=OGC 19-025r1 @fetched=true>
|
|
43
43
|
|
|
44
44
|
tem = hits[0].fetch
|
|
45
45
|
=> #<RelatonOgc::OgcBibliographicItem:0x007fcab3cb4758
|
data/grammars/ogc.rng
CHANGED
|
@@ -62,6 +62,19 @@
|
|
|
62
62
|
</optional>
|
|
63
63
|
</element>
|
|
64
64
|
</define>
|
|
65
|
+
<define name="DocumentSubtype">
|
|
66
|
+
<choice>
|
|
67
|
+
<value>conceptual-model</value>
|
|
68
|
+
<value>conceptual-model-and-encoding</value>
|
|
69
|
+
<value>conceptual-model-and-implementation</value>
|
|
70
|
+
<value>encoding</value>
|
|
71
|
+
<value>extension</value>
|
|
72
|
+
<value>implementation</value>
|
|
73
|
+
<value>profile</value>
|
|
74
|
+
<value>profile-with-extension</value>
|
|
75
|
+
<value>general</value>
|
|
76
|
+
</choice>
|
|
77
|
+
</define>
|
|
65
78
|
</include>
|
|
66
79
|
<define name="TextElement" combine="choice">
|
|
67
80
|
<ref name="hi"/>
|
|
@@ -79,19 +92,6 @@
|
|
|
79
92
|
</zeroOrMore>
|
|
80
93
|
</element>
|
|
81
94
|
</define>
|
|
82
|
-
<define name="DocumentSubtype">
|
|
83
|
-
<choice>
|
|
84
|
-
<value>conceptual-model</value>
|
|
85
|
-
<value>conceptual-model-and-encoding</value>
|
|
86
|
-
<value>conceptual-model-and-implementation</value>
|
|
87
|
-
<value>encoding</value>
|
|
88
|
-
<value>extension</value>
|
|
89
|
-
<value>implementation</value>
|
|
90
|
-
<value>profile</value>
|
|
91
|
-
<value>profile-with-extension</value>
|
|
92
|
-
<value>general</value>
|
|
93
|
-
</choice>
|
|
94
|
-
</define>
|
|
95
95
|
<define name="submitters">
|
|
96
96
|
<element name="submitters">
|
|
97
97
|
<ref name="Basic-Section"/>
|
data/lib/relaton_ogc/hit.rb
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
module RelatonOgc
|
|
2
2
|
class Hit < RelatonBib::Hit
|
|
3
|
+
#
|
|
4
|
+
# <Description>
|
|
5
|
+
#
|
|
6
|
+
# @param [RelatonOgc::OgcBibliographicItem] bibitem
|
|
7
|
+
# @param [RelatonOgc::HitCollection, nil] hitcoll
|
|
8
|
+
#
|
|
9
|
+
def initialize(bibitem, hitcoll = nil)
|
|
10
|
+
super({ id: bibitem.docidentifier[0].id}, hitcoll)
|
|
11
|
+
@fetch = bibitem
|
|
12
|
+
end
|
|
13
|
+
|
|
3
14
|
# Parse page.
|
|
4
15
|
# @return [RelatonNist::NistBliographicItem]
|
|
5
16
|
def fetch
|
|
6
|
-
@fetch ||= Scrapper.parse_page @hit
|
|
17
|
+
@fetch # ||= Scrapper.parse_page @hit
|
|
7
18
|
end
|
|
8
19
|
end
|
|
9
20
|
end
|
|
@@ -4,63 +4,71 @@ require "fileutils"
|
|
|
4
4
|
|
|
5
5
|
module RelatonOgc
|
|
6
6
|
class HitCollection < RelatonBib::HitCollection
|
|
7
|
-
include DataFetcher::Utils
|
|
7
|
+
# include DataFetcher::Utils
|
|
8
8
|
|
|
9
9
|
# ENDPOINT = "https://raw.githubusercontent.com/opengeospatial/"\
|
|
10
10
|
# "NamingAuthority/master/incubation/bibliography/"\
|
|
11
11
|
# "bibliography.json".freeze
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
ENDPOINT = "https://raw.githubusercontent.com/relaton/relaton-data-ogc/main/data/".freeze
|
|
13
|
+
# DATADIR = File.expand_path ".relaton/ogc/", Dir.home
|
|
14
|
+
# DATAFILE = File.expand_path "bibliography.json", DATADIR
|
|
14
15
|
# ETAGFILE = File.expand_path "etag.txt", DATADIR
|
|
15
16
|
|
|
16
|
-
# @param
|
|
17
|
+
# @param code [Strig]
|
|
17
18
|
# @param year [String]
|
|
18
19
|
# @param opts [Hash]
|
|
19
|
-
def initialize(
|
|
20
|
+
def initialize(code, year = nil)
|
|
20
21
|
super
|
|
21
|
-
@etagfile = File.expand_path "etag.txt", DATADIR
|
|
22
|
-
@array = from_json(ref).sort_by do |hit|
|
|
23
|
-
|
|
24
|
-
rescue ArgumentError
|
|
25
|
-
|
|
26
|
-
end.reverse
|
|
22
|
+
# @etagfile = File.expand_path "etag.txt", DATADIR
|
|
23
|
+
# @array = from_json(ref).sort_by do |hit|
|
|
24
|
+
# hit.hit["date"] ? Date.parse(hit.hit["date"]) : Date.new
|
|
25
|
+
# rescue ArgumentError
|
|
26
|
+
# Date.parse "0000-01-01"
|
|
27
|
+
# end.reverse
|
|
28
|
+
resp = Faraday.get "#{ENDPOINT}#{code.upcase.gsub(/[\s:.]/, '_')}.yaml"
|
|
29
|
+
@array = case resp.status
|
|
30
|
+
when 200
|
|
31
|
+
bib = OgcBibliographicItem.from_hash YAML.safe_load(resp.body)
|
|
32
|
+
[Hit.new(bib, self)]
|
|
33
|
+
else []
|
|
34
|
+
end
|
|
27
35
|
end
|
|
28
36
|
|
|
29
|
-
private
|
|
37
|
+
# private
|
|
30
38
|
|
|
31
39
|
#
|
|
32
40
|
# Fetch data form json
|
|
33
41
|
#
|
|
34
42
|
# @param docid [String]
|
|
35
|
-
def from_json(docid, **_opts)
|
|
36
|
-
|
|
37
|
-
|
|
43
|
+
# def from_json(docid, **_opts)
|
|
44
|
+
# ref = docid.sub(/^OGC\s/, "").strip
|
|
45
|
+
# return [] if ref.empty?
|
|
38
46
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
end
|
|
47
|
+
# data.select do |_k, doc|
|
|
48
|
+
# doc["type"] != "CC" && doc["identifier"].include?(ref)
|
|
49
|
+
# end.map { |_k, h| Hit.new(h, self) }
|
|
50
|
+
# end
|
|
43
51
|
|
|
44
52
|
#
|
|
45
53
|
# Fetches json data
|
|
46
54
|
#
|
|
47
55
|
# @return [Hash]
|
|
48
|
-
def data
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
end
|
|
56
|
+
# def data
|
|
57
|
+
# ctime = File.ctime DATAFILE if File.exist? DATAFILE
|
|
58
|
+
# fetch_data if !ctime || ctime.to_date < Date.today
|
|
59
|
+
# @data ||= JSON.parse File.read(DATAFILE, encoding: "UTF-8")
|
|
60
|
+
# end
|
|
53
61
|
|
|
54
62
|
#
|
|
55
63
|
# fetch data form server and save it to file.
|
|
56
64
|
#
|
|
57
|
-
def fetch_data
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
# def fetch_data
|
|
66
|
+
# json = get_data
|
|
67
|
+
# return unless json
|
|
60
68
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
end
|
|
69
|
+
# FileUtils.mkdir_p DATADIR unless Dir.exist? DATADIR
|
|
70
|
+
# @data = json
|
|
71
|
+
# File.write DATAFILE, @data.to_json, encoding: "UTF-8"
|
|
72
|
+
# end
|
|
65
73
|
end
|
|
66
74
|
end
|
|
@@ -4,7 +4,8 @@ module RelatonOgc
|
|
|
4
4
|
# @param text [String]
|
|
5
5
|
# @return [RelatonOgc::HitCollection]
|
|
6
6
|
def search(text, year = nil, _opts = {})
|
|
7
|
-
|
|
7
|
+
code = text.sub(/^OGC\s/, "")
|
|
8
|
+
HitCollection.new code, year
|
|
8
9
|
rescue Faraday::ConnectionFailed
|
|
9
10
|
raise RelatonBib::RequestError, HitCollection::ENDPOINT
|
|
10
11
|
end
|
data/lib/relaton_ogc/version.rb
CHANGED