relaton-ogc 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/grammars/ogc.rng ADDED
@@ -0,0 +1,149 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
+ <!--
4
+ Currently we inherit from a namespaced grammar, isostandard. Until we inherit from isodoc,
5
+ we cannot have a new default namespace: we will end up with a grammar with two different
6
+ namespaces, one for isostandard and one for csand additions. And we do not want that.
7
+ -->
8
+ <include href="isostandard.rng">
9
+ <start>
10
+ <ref name="ogc-standard"/>
11
+ </start>
12
+ <define name="figure">
13
+ <element name="figure">
14
+ <attribute name="id">
15
+ <data type="ID"/>
16
+ </attribute>
17
+ <optional>
18
+ <ref name="tname"/>
19
+ </optional>
20
+ <choice>
21
+ <ref name="image"/>
22
+ <ref name="pre"/>
23
+ <oneOrMore>
24
+ <ref name="subfigure"/>
25
+ </oneOrMore>
26
+ </choice>
27
+ <zeroOrMore>
28
+ <ref name="fn"/>
29
+ </zeroOrMore>
30
+ <optional>
31
+ <ref name="dl"/>
32
+ </optional>
33
+ <zeroOrMore>
34
+ <ref name="note"/>
35
+ </zeroOrMore>
36
+ </element>
37
+ </define>
38
+ <define name="subfigure">
39
+ <element name="figure">
40
+ <attribute name="id">
41
+ <data type="ID"/>
42
+ </attribute>
43
+ <optional>
44
+ <ref name="tname"/>
45
+ </optional>
46
+ <choice>
47
+ <ref name="image"/>
48
+ <ref name="pre"/>
49
+ </choice>
50
+ </element>
51
+ </define>
52
+ <define name="DocumentType">
53
+ <choice>
54
+ <value>abstract-specification</value>
55
+ <value>best-practice</value>
56
+ <value>candidate-standard</value>
57
+ <value>conformance-class</value>
58
+ <value>change-request</value>
59
+ <value>community-practice</value>
60
+ <value>community-standard</value>
61
+ <value>discussion-paper</value>
62
+ <value>draft-discussion-paper</value>
63
+ <value>interoperability-program-report</value>
64
+ <value>implementation-standard</value>
65
+ <value>implementation-standard-corrigendum</value>
66
+ <value>extension-package-standard</value>
67
+ <value>notes</value>
68
+ <value>ogc-reference-model</value>
69
+ <value>profile-corrigendum</value>
70
+ <value>public-engineering-report</value>
71
+ <value>policy</value>
72
+ <value>policy-name-type-specification</value>
73
+ <value>primer</value>
74
+ <value>profile</value>
75
+ <value>request-for-comment</value>
76
+ <value>retired</value>
77
+ <value>standard-application-profile</value>
78
+ <value>test-suite</value>
79
+ <value>whitepaper</value>
80
+ <value>approved-technical-baseline</value>
81
+ <value>recommendation-paper</value>
82
+ </choice>
83
+ </define>
84
+ <define name="editorialgroup">
85
+ <element name="editorialgroup">
86
+ <ref name="committee"/>
87
+ <optional>
88
+ <ref name="subcommittee"/>
89
+ </optional>
90
+ <optional>
91
+ <ref name="workgroup"/>
92
+ </optional>
93
+ </element>
94
+ </define>
95
+ <define name="BibDataExtensionType">
96
+ <optional>
97
+ <ref name="doctype"/>
98
+ </optional>
99
+ <ref name="editorialgroup"/>
100
+ <zeroOrMore>
101
+ <ref name="ics"/>
102
+ </zeroOrMore>
103
+ </define>
104
+ <define name="preface">
105
+ <element name="preface">
106
+ <optional>
107
+ <ref name="preface_abstract"/>
108
+ </optional>
109
+ <ref name="foreword"/>
110
+ <optional>
111
+ <ref name="submitters"/>
112
+ </optional>
113
+ </element>
114
+ </define>
115
+ </include>
116
+ <define name="submitters">
117
+ <element name="submitters">
118
+ <ref name="Basic-Section"/>
119
+ </element>
120
+ </define>
121
+ <define name="committee">
122
+ <element name="committee">
123
+ <choice>
124
+ <value>technical</value>
125
+ <value>planning</value>
126
+ <value>strategic-member-advisory</value>
127
+ </choice>
128
+ </element>
129
+ </define>
130
+ <define name="ogc-standard">
131
+ <element name="ogc-standard">
132
+ <ref name="bibdata"/>
133
+ <zeroOrMore>
134
+ <ref name="termdocsource"/>
135
+ </zeroOrMore>
136
+ <optional>
137
+ <ref name="boilerplate"/>
138
+ </optional>
139
+ <ref name="preface"/>
140
+ <oneOrMore>
141
+ <ref name="sections"/>
142
+ </oneOrMore>
143
+ <zeroOrMore>
144
+ <ref name="annex"/>
145
+ </zeroOrMore>
146
+ <ref name="bibliography"/>
147
+ </element>
148
+ </define>
149
+ </grammar>
data/grammars/reqt.rng ADDED
@@ -0,0 +1,165 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
+ <!--
4
+ Presupposes isodoc.rnc, is included in it
5
+ include "isodoc.rnc" { }
6
+ -->
7
+ <define name="requirement">
8
+ <element name="requirement">
9
+ <ref name="RequirementType"/>
10
+ </element>
11
+ </define>
12
+ <define name="recommendation">
13
+ <element name="recommendation">
14
+ <ref name="RequirementType"/>
15
+ </element>
16
+ </define>
17
+ <define name="permission">
18
+ <element name="permission">
19
+ <ref name="RequirementType"/>
20
+ </element>
21
+ </define>
22
+ <define name="RequirementType">
23
+ <optional>
24
+ <attribute name="obligation">
25
+ <ref name="ObligationType"/>
26
+ </attribute>
27
+ </optional>
28
+ <optional>
29
+ <attribute name="unnumbered">
30
+ <data type="boolean"/>
31
+ </attribute>
32
+ </optional>
33
+ <optional>
34
+ <attribute name="subsequence"/>
35
+ </optional>
36
+ <attribute name="id">
37
+ <data type="ID"/>
38
+ </attribute>
39
+ <optional>
40
+ <attribute name="filename"/>
41
+ </optional>
42
+ <optional>
43
+ <ref name="reqtitle"/>
44
+ </optional>
45
+ <optional>
46
+ <ref name="label"/>
47
+ </optional>
48
+ <optional>
49
+ <ref name="subject"/>
50
+ </optional>
51
+ <optional>
52
+ <ref name="reqinherit"/>
53
+ </optional>
54
+ <zeroOrMore>
55
+ <ref name="classification"/>
56
+ </zeroOrMore>
57
+ <zeroOrMore>
58
+ <choice>
59
+ <ref name="measurementtarget"/>
60
+ <ref name="specification"/>
61
+ <ref name="verification"/>
62
+ <ref name="import"/>
63
+ <ref name="description"/>
64
+ </choice>
65
+ </zeroOrMore>
66
+ <optional>
67
+ <ref name="reqt_references"/>
68
+ </optional>
69
+ <zeroOrMore>
70
+ <choice>
71
+ <ref name="requirement"/>
72
+ <ref name="recommendation"/>
73
+ <ref name="permission"/>
74
+ </choice>
75
+ </zeroOrMore>
76
+ </define>
77
+ <define name="reqtitle">
78
+ <element name="title">
79
+ <ref name="FormattedString"/>
80
+ </element>
81
+ </define>
82
+ <define name="label">
83
+ <element name="label">
84
+ <text/>
85
+ </element>
86
+ </define>
87
+ <define name="subject">
88
+ <element name="subject">
89
+ <text/>
90
+ </element>
91
+ </define>
92
+ <define name="reqinherit">
93
+ <element name="inherit">
94
+ <text/>
95
+ </element>
96
+ </define>
97
+ <define name="measurementtarget">
98
+ <element name="measurement-target">
99
+ <ref name="RequirementSubpart"/>
100
+ </element>
101
+ </define>
102
+ <define name="specification">
103
+ <element name="specification">
104
+ <ref name="RequirementSubpart"/>
105
+ </element>
106
+ </define>
107
+ <define name="verification">
108
+ <element name="verification">
109
+ <ref name="RequirementSubpart"/>
110
+ </element>
111
+ </define>
112
+ <define name="import">
113
+ <element name="import">
114
+ <ref name="RequirementSubpart"/>
115
+ </element>
116
+ </define>
117
+ <define name="description">
118
+ <element name="description">
119
+ <ref name="RequirementSubpart"/>
120
+ </element>
121
+ </define>
122
+ <define name="reqt_references">
123
+ <element name="references">
124
+ <oneOrMore>
125
+ <ref name="bibitem"/>
126
+ </oneOrMore>
127
+ </element>
128
+ </define>
129
+ <define name="RequirementSubpart">
130
+ <optional>
131
+ <attribute name="type"/>
132
+ </optional>
133
+ <optional>
134
+ <attribute name="exclude">
135
+ <data type="boolean"/>
136
+ </attribute>
137
+ </optional>
138
+ <oneOrMore>
139
+ <ref name="BasicBlock"/>
140
+ </oneOrMore>
141
+ </define>
142
+ <define name="ObligationType">
143
+ <choice>
144
+ <value>requirement</value>
145
+ <value>recommendation</value>
146
+ <value>permission</value>
147
+ </choice>
148
+ </define>
149
+ <define name="classification">
150
+ <element name="classification">
151
+ <ref name="classification_tag"/>
152
+ <ref name="classification_value"/>
153
+ </element>
154
+ </define>
155
+ <define name="classification_tag">
156
+ <element name="tag">
157
+ <text/>
158
+ </element>
159
+ </define>
160
+ <define name="classification_value">
161
+ <element name="value">
162
+ <text/>
163
+ </element>
164
+ </define>
165
+ </grammar>
@@ -1,12 +1,14 @@
1
1
  require "faraday"
2
2
  require "relaton_ogc/hit"
3
+ require "fileutils"
3
4
 
4
5
  module RelatonOgc
5
6
  class HitCollection < RelatonBib::HitCollection
6
7
  ENDPOINT = "https://raw.githubusercontent.com/opengeospatial/"\
7
8
  "NamingAuthority/master/incubation/bibliography/bibliography.json".freeze
8
- DATAFILE = File.expand_path "data/bibliography.json", __dir__
9
- ETAGFILE = File.expand_path "data/etag.txt", __dir__
9
+ DATADIR = File.expand_path ".relaton/ogc/", Dir.home
10
+ DATAFILE = File.expand_path "bibliography.json", DATADIR
11
+ ETAGFILE = File.expand_path "etag.txt", DATADIR
10
12
 
11
13
  # @param ref [Strig]
12
14
  # @param year [String]
@@ -50,8 +52,9 @@ module RelatonOgc
50
52
  def fetch_data
51
53
  resp = Faraday.new(ENDPOINT, headers: { "If-None-Match" => etag }).get
52
54
  # return if there aren't any changes since last fetching
53
- return unless resp.status == 200
55
+ raise RelatonBib::RequestError, "Could not access #{ENDPOINT}" unless resp.status == 200
54
56
 
57
+ FileUtils.mkdir_p DATADIR unless Dir.exist? DATADIR
55
58
  self.etag = resp[:etag]
56
59
  @data = JSON.parse resp.body
57
60
  File.write DATAFILE, @data.to_json, encoding: "UTF-8"
@@ -1,11 +1,14 @@
1
1
  module RelatonOgc
2
2
  class OgcBibliographicItem < RelatonIsoBib::IsoBibliographicItem
3
3
  TYPES = %w[
4
- standard standard-with-suite
5
4
  abstract-specification best-practice candidate-standard conformance-class
6
- change-request community-standard discussion-paper draft-discussion-paper
7
- interoperability-program-report implementation-standard
8
- public-engineering-report
5
+ change-request community-practice community-standard discussion-paper
6
+ draft-discussion-paper interoperability-program-report implementation-standard
7
+ implementation-standard-corrigendum extension-package-standard notes
8
+ ogc-reference-model profile-corrigendum public-engineering-report policy
9
+ policy-name-type-specification primer profile request-for-comment retired
10
+ standard-application-profile test-suite whitepaper approved-technical-baseline
11
+ recommendation-paper
9
12
  ].freeze
10
13
  end
11
14
  end
@@ -29,5 +29,11 @@ module RelatonOgc
29
29
  item_hash = ::RelatonOgc::HashConverter.hash_to_bib(hash)
30
30
  ::RelatonOgc::OgcBibliographicItem.new item_hash
31
31
  end
32
+
33
+ # Returns hash of XML grammar
34
+ # @return [String]
35
+ def grammar_hash
36
+ @grammar_hash ||= ::RelatonOgc.grammar_hash
37
+ end
32
38
  end
33
39
  end
@@ -1,31 +1,34 @@
1
1
  module RelatonOgc
2
2
  module Scrapper
3
3
  TYPES = {
4
- "AS" => "Abstract Specification",
5
- "BP" => "Best Practice",
6
- "CAN" => "Candidate Standard",
7
- "CC" => "Conformance Class",
8
- "CR" => "Change Request",
9
- "CS" => "Community Standard",
10
- "DP" => "Discussion Paper",
11
- "DP-Draft" => "Draft Discussion Paper",
12
- "IPR" => "Interoperability Program Report - Engineering Specification",
13
- "IS" => "Implementation Standard",
14
- "ISC" => "Implementation Standard Corrigendum",
15
- "ISx" => "Extension Package Standard",
16
- "Notes" => "Notes",
17
- "ORM" => "OGC Reference Model",
18
- "PC" => "Profile Corrigendum",
19
- "PER" => "Public Engineering Report",
20
- "POL" => "Policy",
21
- "POL-NTS" => "Policy - Name Type Specification",
22
- "Primer" => "Primer",
23
- "Profile" => "Profile",
24
- "RFC" => "Request for Comment",
25
- "Retired" => "Retired document",
26
- "SAP" => "Standard Application Profile",
27
- "TS" => "Test Suite",
28
- "WhitePaper" => "Whitepaper",
4
+ "AS" => "abstract-specification",
5
+ "BP" => "best-practice",
6
+ "CAN" => "candidate-standard",
7
+ "CC" => "conformance-class",
8
+ "CR" => "change-request",
9
+ "CP" => "community-practice",
10
+ "CS" => "community-standard",
11
+ "DP" => "discussion-paper",
12
+ "DP-Draft" => "draft-discussion-paper",
13
+ "IPR" => "interoperability-program-report",
14
+ "IS" => "implementation-standard",
15
+ "ISC" => "implementation-standard-corrigendum",
16
+ "ISx" => "extension-package-standard",
17
+ "Notes" => "notes",
18
+ "ORM" => "ogc-reference-model",
19
+ "PC" => "profile-corrigendum",
20
+ "PER" => "public-engineering-report",
21
+ "POL" => "policy",
22
+ "POLNTS" => "policy-name-type-specification",
23
+ "Primer" => "primer",
24
+ "Profile" => "profile",
25
+ "RFC" => "request-for-comment",
26
+ "Retired" => "retired",
27
+ "SAP" => "standard-application-profile",
28
+ "TS" => "test-suite",
29
+ "WhitePaper" => "whitepaper",
30
+ "ATB" => "approved-technical-baseline",
31
+ "RP" => "recommendation-paper",
29
32
  }.freeze
30
33
 
31
34
  class << self
@@ -44,11 +47,16 @@ module RelatonOgc
44
47
  language: ["en"],
45
48
  script: ["Latn"],
46
49
  date: fetch_date(hit["date"]),
50
+ editorialgroup: fetch_editorialgroup,
47
51
  )
48
52
  end
49
53
 
50
54
  private
51
55
 
56
+ def fetch_editorialgroup
57
+ EditorialGroup.new committee: "technical"
58
+ end
59
+
52
60
  # @param title [String]
53
61
  # @return [Array<RelatonIsoBib::TypedTitleString>]
54
62
  def fetch_title(title)
@@ -79,7 +87,7 @@ module RelatonOgc
79
87
  # @param type [String]
80
88
  # @return [String]
81
89
  def fetch_type(type)
82
- TYPES[type.sub(/^D-/, "")].downcase.gsub " ", "-"
90
+ TYPES[type.sub(/^D-/, "")]
83
91
  end
84
92
 
85
93
  # @param identifier [String]
@@ -1,3 +1,3 @@
1
1
  module RelatonOgc
2
- VERSION = "0.1.4".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
data/lib/relaton_ogc.rb CHANGED
@@ -7,8 +7,17 @@ require "relaton_ogc/scrapper"
7
7
  require "relaton_ogc/xml_parser"
8
8
  require "relaton_ogc/editorial_group"
9
9
  require "relaton_ogc/hash_converter"
10
+ require "digest/md5"
10
11
 
11
12
  module RelatonOgc
12
13
  class Error < StandardError; end
13
- # Your code goes here...
14
+
15
+ # Returns hash of XML reammar
16
+ # @return [String]
17
+ def self.grammar_hash
18
+ gem_path = File.expand_path "..", __dir__
19
+ grammars_path = File.join gem_path, "grammars", "*"
20
+ grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
21
+ Digest::MD5.hexdigest grammars
22
+ end
14
23
  end
data/relaton_ogc.gemspec CHANGED
@@ -30,10 +30,11 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency "rake", "~> 10.0"
31
31
  spec.add_development_dependency "rspec", "~> 3.0"
32
32
  spec.add_development_dependency "ruby-debug-ide"
33
+ spec.add_development_dependency "ruby-jing"
33
34
  spec.add_development_dependency "simplecov"
34
35
  spec.add_development_dependency "vcr"
35
36
  spec.add_development_dependency "webmock"
36
37
 
37
38
  spec.add_dependency "faraday"
38
- spec.add_dependency "relaton-iso-bib", "~> 0.3.0"
39
+ spec.add_dependency "relaton-iso-bib", "~> 0.4.0"
39
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-ogc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.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: 2019-10-31 00:00:00.000000000 Z
11
+ date: 2019-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: ruby-jing
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: simplecov
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +170,14 @@ dependencies:
156
170
  requirements:
157
171
  - - "~>"
158
172
  - !ruby/object:Gem::Version
159
- version: 0.3.0
173
+ version: 0.4.0
160
174
  type: :runtime
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
178
  - - "~>"
165
179
  - !ruby/object:Gem::Version
166
- version: 0.3.0
180
+ version: 0.4.0
167
181
  description: 'RelatonIso: retrieve ISO Standards for bibliographic use using the IsoBibliographicItem
168
182
  model'
169
183
  email:
@@ -172,21 +186,26 @@ executables: []
172
186
  extensions: []
173
187
  extra_rdoc_files: []
174
188
  files:
189
+ - ".github/workflows/macos.yml"
190
+ - ".github/workflows/ubuntu.yml"
191
+ - ".github/workflows/windows.yml"
175
192
  - ".gitignore"
176
193
  - ".rspec"
177
194
  - ".rubocop.yml"
178
- - ".travis.yml"
179
195
  - Gemfile
180
196
  - Gemfile.lock
181
197
  - LICENSE.txt
182
198
  - README.adoc
183
199
  - Rakefile
184
- - appveyor.yml
185
200
  - bin/console
186
201
  - bin/setup
202
+ - grammars/basicdoc.rng
203
+ - grammars/biblio.rng
204
+ - grammars/isodoc.rng
205
+ - grammars/isostandard.rng
206
+ - grammars/ogc.rng
207
+ - grammars/reqt.rng
187
208
  - lib/relaton_ogc.rb
188
- - lib/relaton_ogc/data/bibliography.json
189
- - lib/relaton_ogc/data/etag.txt
190
209
  - lib/relaton_ogc/editorial_group.rb
191
210
  - lib/relaton_ogc/hash_converter.rb
192
211
  - lib/relaton_ogc/hit.rb
data/.travis.yml DELETED
@@ -1,18 +0,0 @@
1
- # Auto-generated !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
3
- language: ruby
4
- cache: bundler
5
- os:
6
- - linux
7
- - osx
8
- rvm:
9
- - 2.6
10
- - 2.5
11
- - 2.4
12
- - ruby-head
13
- before_install:
14
- - gem install bundler -v "~> 2"
15
- - bundle update
16
- matrix:
17
- allow_failures:
18
- - rvm: ruby-head
data/appveyor.yml DELETED
@@ -1,37 +0,0 @@
1
- # Auto-generated !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
3
- version: '{build}'
4
-
5
- cache:
6
- - vendor/bundle
7
-
8
- environment:
9
- matrix:
10
- - RUBY_VERSION: 26
11
- - RUBY_VERSION: 25
12
- - RUBY_VERSION: 24
13
- - RUBY_VERSION: _trunk
14
-
15
- matrix:
16
- allow_failures:
17
- - RUBY_VERSION: _trunk
18
-
19
- install:
20
- - ps: . { iwr -useb https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/appveyor.ps1 } | iex
21
- - refreshenv
22
-
23
- build_script:
24
- - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
25
- - set GIT_TERMINAL_PROMPT=0
26
- - gem install bundler -v "~> 2"
27
- - bundle config --local path vendor/bundle
28
- - bundle update
29
- - bundle install
30
-
31
- before_test:
32
- - ruby -v
33
- - gem -v
34
- - bundle -v
35
-
36
- test_script:
37
- - bundle exec rake