relaton 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +5 -1
- data/lib/relaton/db.rb +15 -3
- data/lib/relaton/processor.rb +1 -0
- data/lib/relaton/version.rb +1 -1
- data/relaton.gemspec +3 -3
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5289c73f7ef9ea82c84ece5379a949d288a60f13cab353b1c5f8b17a580bb3c
|
4
|
+
data.tar.gz: a363758952c22241d932442061fc777d2486d08296797248d59577b0693d7f63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6afe15dbf35ef71b7bc632165f836158413954f4763c04e79f9d47246048c203076e22ff490d40ae2a25a956772e6c95f1e0942ecc08b6ec1aff6e2207bc282
|
7
|
+
data.tar.gz: 7a2dd8e987ba0f042ad8bc09b2ab661328d8644b968029046f3277bd78e5a889a2efd90c3c2d120859c05e2384d444d0833c6e024ec38d6f0c32ecf7bb8b35d3
|
data/README.adoc
CHANGED
@@ -32,6 +32,7 @@ The gem can be extended to use other standards-specific gems. Standards-specific
|
|
32
32
|
* `@short`, the name of the gem
|
33
33
|
* `@prefix`, the regex which scopes the identifier, and constrains it to belong to a particular standards class.
|
34
34
|
* `@defaultprefix`, the identifier prefixes which can be recognised without a scope wrapper.
|
35
|
+
* `@idtype`, the type assigned to document identifiers for the standard class.
|
35
36
|
* `get(code, date, opts)`, which takes a standards code, a year, and a hash of options, and returns an iso-bib-item bibliographic entry
|
36
37
|
** `date == nil`: an ISO reference is treated as a generic reference to the latest available version of the reference. The latest
|
37
38
|
version retrieved has its date of publicatipn stripped. The dated reference is retained as an `instanceOf` relation to the reference.
|
@@ -50,7 +51,7 @@ e.g. `get("ISO 19115-1", "2014", all_parts: true)` is transformed into a referen
|
|
50
51
|
* If a cached ISO entry has no date, and was last retrieved more than 60 days ago, the gem fetches it again, in case there is a newer edition of the standard available.
|
51
52
|
* Entries are always saved to the cache with a scope-wrapped identifier; e.g. under `ISO(ISO 639-1)`, and not `ISO 639-1`.
|
52
53
|
* Note that the gem does not currently support the totality of the Relaton model; it will only support the information available in the source websites. We do not expect to support cartographic information, for example.
|
53
|
-
* Document identifiers are returned with a scope indication; for example, `<docidentifier type="IETF">RFC 8000</docidentifier>`. It is up to the client whether to render this with the scope indication (_IETF RFC 8000_) or without (_RFC 8000_).
|
54
|
+
* Document identifiers are returned with a scope indication (`@idtype`); for example, `<docidentifier type="IETF">RFC 8000</docidentifier>`. It is up to the client whether to render this with the scope indication (_IETF RFC 8000_) or without (_RFC 8000_).
|
54
55
|
|
55
56
|
== Usage
|
56
57
|
|
@@ -86,6 +87,9 @@ x = db.fetch("ISO 19011", "2011", allparts: true)
|
|
86
87
|
fetching ISO 19011...
|
87
88
|
=> #<IsoBibItem::IsoBibliographicItem:...>
|
88
89
|
|
90
|
+
x = db.docid_type("CN(GB/T 1.1)")
|
91
|
+
=> ["Chinese Standard", "GB/T 1.1"]
|
92
|
+
|
89
93
|
x.to_xml
|
90
94
|
=> "<bib-item type=\"international-standard\" id=\"ISO19011\">...."
|
91
95
|
|
data/lib/relaton/db.rb
CHANGED
@@ -41,6 +41,13 @@ module Relaton
|
|
41
41
|
check_bibliocache(code, year, opts, stdclass)
|
42
42
|
end
|
43
43
|
|
44
|
+
# The document identifier class corresponding to the given code
|
45
|
+
def docid_type(code)
|
46
|
+
stdclass = standard_class(code) or return [nil, code]
|
47
|
+
prefix, code = strip_id_wrapper(code, stdclass)
|
48
|
+
[@registry.processors[stdclass].idtype, code]
|
49
|
+
end
|
50
|
+
|
44
51
|
# @param key [String]
|
45
52
|
# @return [Hash]
|
46
53
|
def load_entry(key)
|
@@ -60,7 +67,7 @@ module Relaton
|
|
60
67
|
@local_db.nil? or @local_db.transaction { @local_db[key] = value }
|
61
68
|
end
|
62
69
|
|
63
|
-
# list all
|
70
|
+
# list all entries as a serialization
|
64
71
|
def to_xml
|
65
72
|
return nil if @db.nil?
|
66
73
|
@db.transaction do
|
@@ -89,14 +96,19 @@ module Relaton
|
|
89
96
|
|
90
97
|
# TODO: i18n
|
91
98
|
def std_id(code, year, opts, stdclass)
|
92
|
-
prefix =
|
93
|
-
code = code.sub(/^#{prefix}\((.+)\)$/, "\\1")
|
99
|
+
prefix, code = strip_id_wrapper(code, stdclass)
|
94
100
|
ret = code
|
95
101
|
ret += ":#{year}" if year
|
96
102
|
ret += " (all parts)" if opts[:all_parts]
|
97
103
|
["#{prefix}(#{ret})", code]
|
98
104
|
end
|
99
105
|
|
106
|
+
def strip_id_wrapper(code, stdclass)
|
107
|
+
prefix = @registry.processors[stdclass].prefix
|
108
|
+
code = code.sub(/^#{prefix}\((.+)\)$/, "\\1")
|
109
|
+
[prefix, code]
|
110
|
+
end
|
111
|
+
|
100
112
|
def bib_retval(entry)
|
101
113
|
entry["bib"] == "not_found" ? nil : entry["bib"]
|
102
114
|
end
|
data/lib/relaton/processor.rb
CHANGED
data/lib/relaton/version.rb
CHANGED
data/relaton.gemspec
CHANGED
@@ -28,9 +28,9 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
29
29
|
|
30
30
|
spec.add_dependency "algoliasearch"
|
31
|
-
spec.add_dependency "gbbib", "~> 0.3.
|
32
|
-
spec.add_dependency "isobib", "~> 0.3.
|
33
|
-
spec.add_dependency "ietfbib", "~> 0.4.
|
31
|
+
spec.add_dependency "gbbib", "~> 0.3.1"
|
32
|
+
spec.add_dependency "isobib", "~> 0.3.1"
|
33
|
+
spec.add_dependency "ietfbib", "~> 0.4.1"
|
34
34
|
spec.add_dependency 'iso-bib-item', '~> 0.3.0'
|
35
35
|
|
36
36
|
spec.add_development_dependency "bundler", "~> 1.15"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: algoliasearch
|
@@ -30,42 +30,42 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.3.
|
33
|
+
version: 0.3.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.3.
|
40
|
+
version: 0.3.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: isobib
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.3.
|
47
|
+
version: 0.3.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.3.
|
54
|
+
version: 0.3.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: ietfbib
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.4.
|
61
|
+
version: 0.4.1
|
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: 0.4.
|
68
|
+
version: 0.4.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: iso-bib-item
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|