relaton-w3c 0.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,11 @@
1
1
  module RelatonW3c
2
2
  class HashConverter < RelatonBib::HashConverter
3
+ class << self
4
+ # @param item_hash [Hash]
5
+ # @return [RelatonW3c::W3cBibliographicItem]
6
+ def bib_item(item_hash)
7
+ W3cBibliographicItem.new item_hash
8
+ end
9
+ end
3
10
  end
4
11
  end
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "fileutils"
4
+ require "yaml"
5
+
3
6
  module RelatonW3c
4
7
  # Page of hit collection.
5
8
  class HitCollection < RelatonBib::HitCollection
@@ -44,7 +44,7 @@ module RelatonW3c
44
44
  titles << { content: title, type: "main" }
45
45
  subtitle = doc.at("//h2[@id='subtitle']").text
46
46
  titles << { content: subtitle, tipe: "subtitle" }
47
- else
47
+ elsif hit["title"]
48
48
  titles << { content: hit["title"], type: "main" }
49
49
  end
50
50
  titles.map do |t|
@@ -166,7 +166,7 @@ module RelatonW3c
166
166
 
167
167
  hit = { "link" => link }
168
168
  item = parse_page hit
169
- [RelatonBib::DocumentRelation.new(type: "obsoleted", bibitem: item)]
169
+ [RelatonBib::DocumentRelation.new(type: "obsoletedBy", bibitem: item)]
170
170
  end
171
171
 
172
172
  # @param doc [Nokogiri::HTML::Document]
@@ -1,3 +1,3 @@
1
1
  module RelatonW3c
2
- VERSION = "0.1.0"
2
+ VERSION = "1.2.0".freeze
3
3
  end
@@ -12,8 +12,8 @@ module RelatonW3c
12
12
  if args[:doctype] && !TYPES.include?(args[:doctype])
13
13
  warn "[relaton-w3c] invalid document type: #{args[:doctype]}"
14
14
  end
15
- @doctype = args.delete :doctype
16
15
  super **args
16
+ # @doctype = args[:doctype]
17
17
  end
18
18
 
19
19
  # @param builder [Nokogiri::XML::Builder, NilClass]
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "net/http"
4
+
3
5
  module RelatonW3c
4
6
  # Class methods for search W3C standards.
5
7
  class W3cBibliography
@@ -10,7 +12,7 @@ module RelatonW3c
10
12
  HitCollection.new text
11
13
  rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET,
12
14
  EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
13
- Net::ProtocolError, OpenSSL::SSL::SSLError, Errno::ETIMEDOUT
15
+ Net::ProtocolError, Errno::ETIMEDOUT
14
16
  raise RelatonBib::RequestError,
15
17
  "Could not access #{HitCollection::DOMAIN}"
16
18
  end
@@ -1,19 +1,6 @@
1
1
  module RelatonW3c
2
2
  class XMLParser < RelatonBib::XMLParser
3
3
  class << self
4
- # @param xml [String]
5
- # @return [RelatonW3c::W3cBibliographicItem, NilClass]
6
- def from_xml(xml)
7
- doc = Nokogiri::XML xml
8
- doc.remove_namespaces!
9
- item = doc.at("/bibitem|/bibdata")
10
- if item
11
- W3cBibliographicItem.new(item_data(item))
12
- else
13
- warn "[relaton-w3c] can't find bibitem or bibdata element in the XML"
14
- end
15
- end
16
-
17
4
  private
18
5
 
19
6
  # Override RelatonBib::XMLParser.item_data method.
@@ -27,6 +14,12 @@ module RelatonW3c
27
14
  data[:doctype] = ext.at("./doctype")&.text
28
15
  data
29
16
  end
17
+
18
+ # @param item_hash [Hash]
19
+ # @return [RelatonBib::BibliographicItem]
20
+ def bib_item(item_hash)
21
+ W3cBibliographicItem.new item_hash
22
+ end
30
23
  end
31
24
  end
32
25
  end
@@ -9,9 +9,9 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ["open.source@ribose.com"]
10
10
 
11
11
  spec.summary = "RelatonIso: retrieve W3C Standards for bibliographic "\
12
- "use using the IsoBibliographicItem model"
12
+ "using the IsoBibliographicItem model"
13
13
  spec.description = "RelatonIso: retrieve W3C Standards for bibliographic "\
14
- "use using the IsoBibliographicItem model"
14
+ "using the IsoBibliographicItem model"
15
15
  spec.homepage = "https://github.com/relaton/relaton-wc3"
16
16
  spec.license = "BSD-2-Clause"
17
17
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
@@ -39,5 +39,5 @@ Gem::Specification.new do |spec|
39
39
  spec.add_development_dependency "vcr"
40
40
  spec.add_development_dependency "webmock"
41
41
 
42
- spec.add_dependency "relaton-bib", ">= 0.9.2"
42
+ spec.add_dependency "relaton-bib", ">= 1.2.0"
43
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-w3c
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.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: 2020-04-07 00:00:00.000000000 Z
11
+ date: 2020-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debase
@@ -114,15 +114,15 @@ dependencies:
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: 0.9.2
117
+ version: 1.2.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: 0.9.2
125
- description: 'RelatonIso: retrieve W3C Standards for bibliographic use using the IsoBibliographicItem
124
+ version: 1.2.0
125
+ description: 'RelatonIso: retrieve W3C Standards for bibliographic using the IsoBibliographicItem
126
126
  model'
127
127
  email:
128
128
  - open.source@ribose.com
@@ -144,6 +144,8 @@ files:
144
144
  - bin/console
145
145
  - bin/rspec
146
146
  - bin/setup
147
+ - grammars/basicdoc.rng
148
+ - grammars/biblio.rng
147
149
  - lib/relaton_w3c.rb
148
150
  - lib/relaton_w3c/hash_converter.rb
149
151
  - lib/relaton_w3c/hit.rb
@@ -178,6 +180,6 @@ requirements: []
178
180
  rubygems_version: 3.0.6
179
181
  signing_key:
180
182
  specification_version: 4
181
- summary: 'RelatonIso: retrieve W3C Standards for bibliographic use using the IsoBibliographicItem
183
+ summary: 'RelatonIso: retrieve W3C Standards for bibliographic using the IsoBibliographicItem
182
184
  model'
183
185
  test_files: []