relaton-iso-bib 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/lib/relaton_iso_bib/editorial_group.rb +22 -5
- data/lib/relaton_iso_bib/hash_converter.rb +39 -9
- data/lib/relaton_iso_bib/ics.rb +9 -2
- data/lib/relaton_iso_bib/iso_bibliographic_item.rb +24 -14
- data/lib/relaton_iso_bib/structured_identifier.rb +12 -1
- data/lib/relaton_iso_bib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 637ffa327aa126a02134f1bb84d39f2dc431b42e
|
4
|
+
data.tar.gz: dccdaced7cd3ad6ec9a6ca863c3f64bf2e6d64c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe9f3b30ceb708660084d33fde87934c3f42446d97a6aa15fc8fbd6baf3bf02ac4e3e5cd1c31d378d504fdfba3f16ece1d24b1b91d4366827721950100908d36
|
7
|
+
data.tar.gz: 2cdb6f97d9377e6e08061b97cb931bb04851abd162f1411dc570ff02651e95333bdad4c0df63dbc7ff37cad608c76a57f61a45313ec1fe80727ec175838da800
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
relaton-iso-bib (0.3.
|
4
|
+
relaton-iso-bib (0.3.3)
|
5
5
|
isoics (~> 0.1.6)
|
6
6
|
relaton-bib (~> 0.3.0)
|
7
7
|
ruby_deep_clone (~> 0.8.0)
|
@@ -24,7 +24,7 @@ GEM
|
|
24
24
|
json (2.2.0)
|
25
25
|
method_source (0.9.2)
|
26
26
|
mini_portile2 (2.4.0)
|
27
|
-
nokogiri (1.10.
|
27
|
+
nokogiri (1.10.4)
|
28
28
|
mini_portile2 (~> 2.4.0)
|
29
29
|
pry (0.12.2)
|
30
30
|
coderay (~> 1.1.0)
|
@@ -34,7 +34,7 @@ GEM
|
|
34
34
|
pry (~> 0.10)
|
35
35
|
public_suffix (3.1.1)
|
36
36
|
rake (10.5.0)
|
37
|
-
relaton-bib (0.3.
|
37
|
+
relaton-bib (0.3.4)
|
38
38
|
addressable
|
39
39
|
nokogiri (~> 1.10)
|
40
40
|
rspec (3.8.0)
|
@@ -6,13 +6,13 @@ module RelatonIsoBib
|
|
6
6
|
# @return [Array<RelatonIsoBib::IsoSubgroup>]
|
7
7
|
attr_reader :technical_committee
|
8
8
|
|
9
|
-
# @return [RelatonIsoBib::IsoSubgroup]
|
9
|
+
# @return [Array<RelatonIsoBib::IsoSubgroup>]
|
10
10
|
attr_reader :subcommittee
|
11
11
|
|
12
|
-
# @return [RelatonIsoBib::IsoSubgroup]
|
12
|
+
# @return [Array<RelatonIsoBib::IsoSubgroup>]
|
13
13
|
attr_reader :workgroup
|
14
14
|
|
15
|
-
# @return [String]
|
15
|
+
# @return [String, NilClass]
|
16
16
|
attr_reader :secretariat
|
17
17
|
|
18
18
|
# @param technical_committee [Array<Hash, RelatonIsoBib::IsoSubgroup>]
|
@@ -44,7 +44,7 @@ module RelatonIsoBib
|
|
44
44
|
@secretariat = args[:secretariat]
|
45
45
|
end
|
46
46
|
|
47
|
-
# rubocop:disable Metrics/AbcSize
|
47
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
48
48
|
|
49
49
|
# @param builder [Nokogiri::XML::Builder]
|
50
50
|
def to_xml(builder)
|
@@ -63,7 +63,16 @@ module RelatonIsoBib
|
|
63
63
|
builder.secretariat secretariat if secretariat
|
64
64
|
end
|
65
65
|
end
|
66
|
-
# rubocop:enable Metrics/AbcSize
|
66
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
67
|
+
|
68
|
+
# @return [Hash]
|
69
|
+
def to_hash
|
70
|
+
hash = { technical_committee: technical_committee.map(&:to_hash) }
|
71
|
+
hash[:subcommittee] = subcommittee.map(&:to_hash) if subcommittee&.any?
|
72
|
+
hash[:workgroup] = workgroup.map(&:to_hash) if workgroup&.any?
|
73
|
+
hash[:secretariat] = secretariat if secretariat
|
74
|
+
hash
|
75
|
+
end
|
67
76
|
end
|
68
77
|
|
69
78
|
# ISO subgroup.
|
@@ -92,5 +101,13 @@ module RelatonIsoBib
|
|
92
101
|
builder.parent[:type] = type if type
|
93
102
|
builder.text name
|
94
103
|
end
|
104
|
+
|
105
|
+
# @return [Hash]
|
106
|
+
def to_hash
|
107
|
+
hash = { name: name }
|
108
|
+
hash[:type] = type if type
|
109
|
+
hash[:number] = number if number
|
110
|
+
hash
|
111
|
+
end
|
95
112
|
end
|
96
113
|
end
|
@@ -44,23 +44,51 @@ module RelatonIsoBib
|
|
44
44
|
|
45
45
|
private
|
46
46
|
|
47
|
+
#
|
48
|
+
# Ovverides superclass's method
|
49
|
+
#
|
50
|
+
# @param ret [Hash]
|
47
51
|
def title_hash_to_bib(ret)
|
48
52
|
return unless ret[:title]
|
49
53
|
|
50
54
|
ret[:title] = array(ret[:title])
|
51
|
-
ret[:title] = ret[:title].
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
55
|
+
ret[:title] = ret[:title].reduce([]) do |a, t|
|
56
|
+
if t.is_a?(String)
|
57
|
+
a << split_title(t)
|
58
|
+
elsif t.is_a?(Hash) && t[:type]
|
59
|
+
idx = a.index { |i| i[:language] == t[:language] }
|
60
|
+
title_key = t[:type].sub("-", "_").to_sym
|
61
|
+
if idx
|
62
|
+
a[idx][title_key] = t[:content]
|
63
|
+
a
|
64
|
+
else
|
65
|
+
a << { title_key => t[:content], language: t[:language], script: t[:script] }
|
66
|
+
end
|
67
|
+
elsif t.is_a?(Hash) && t[:content]
|
68
|
+
a << split_title(t[:content], t[:language], t[:script])
|
60
69
|
end
|
61
70
|
end
|
62
71
|
end
|
63
72
|
|
73
|
+
#
|
74
|
+
# Ovverides superclass's method
|
75
|
+
#
|
76
|
+
# @param item [Hash]
|
77
|
+
# @retirn [RelatonIsoBib::IsoBibliographicItem]
|
78
|
+
def bib_item(item)
|
79
|
+
IsoBibliographicItem.new(item)
|
80
|
+
end
|
81
|
+
|
82
|
+
#
|
83
|
+
# Ovverides superclass's method
|
84
|
+
#
|
85
|
+
# @param title [Hash]
|
86
|
+
# @return [RelatonIsoBib::TypedTitleString]
|
87
|
+
def typed_title_strig(title)
|
88
|
+
TypedTitleString.new title
|
89
|
+
end
|
90
|
+
|
91
|
+
# @param ret [Hash]
|
64
92
|
def editorialgroup_hash_to_bib(ret)
|
65
93
|
eg = ret[:editorialgroup]
|
66
94
|
return unless eg
|
@@ -73,12 +101,14 @@ module RelatonIsoBib
|
|
73
101
|
)
|
74
102
|
end
|
75
103
|
|
104
|
+
# @param ret [Hash]
|
76
105
|
def ics_hash_to_bib(ret)
|
77
106
|
ret[:ics] = ret.fetch(:ics, []).map do |ics|
|
78
107
|
ics[:code] ? Ics.new(ics[:code]) : Ics.new(ics)
|
79
108
|
end
|
80
109
|
end
|
81
110
|
|
111
|
+
# @param ret [Hash]
|
82
112
|
def structuredidentifier_hash_to_bib(ret)
|
83
113
|
return unless ret[:structuredidentifier]
|
84
114
|
|
data/lib/relaton_iso_bib/ics.rb
CHANGED
@@ -10,7 +10,7 @@ module RelatonIsoBib
|
|
10
10
|
raise ArgumentError, "wrong arguments (should be string or { fieldcode: [String] }"
|
11
11
|
end
|
12
12
|
|
13
|
-
field, group, subgroup = code.split
|
13
|
+
field, group, subgroup = code.split "." if code
|
14
14
|
super fieldcode: field, groupcode: group, subgroupcode: subgroup
|
15
15
|
end
|
16
16
|
|
@@ -21,5 +21,12 @@ module RelatonIsoBib
|
|
21
21
|
builder.text_ description
|
22
22
|
end
|
23
23
|
end
|
24
|
+
|
25
|
+
# @return [Hash]
|
26
|
+
def to_hash
|
27
|
+
hash = {}
|
28
|
+
hash[:code] = code if code
|
29
|
+
hash
|
30
|
+
end
|
24
31
|
end
|
25
|
-
end
|
32
|
+
end
|
@@ -125,8 +125,8 @@ module RelatonIsoBib
|
|
125
125
|
# @raise [ArgumentError]
|
126
126
|
def initialize(**args)
|
127
127
|
check_type args[:type]
|
128
|
-
#check_language args.fetch(:language, [])
|
129
|
-
#check_script args.fetch(:script, [])
|
128
|
+
# check_language args.fetch(:language, [])
|
129
|
+
# check_script args.fetch(:script, [])
|
130
130
|
|
131
131
|
super_args = args.select do |k|
|
132
132
|
%i[id docnumber language script docstatus date abstract contributor
|
@@ -245,25 +245,35 @@ module RelatonIsoBib
|
|
245
245
|
end
|
246
246
|
end
|
247
247
|
|
248
|
+
# @return [Hash]
|
249
|
+
def to_hash
|
250
|
+
hash = super
|
251
|
+
hash[:editorialgroup] = editorialgroup.to_hash if editorialgroup
|
252
|
+
hash[:ics] = ics.map(&:to_hash) if ics&.any?
|
253
|
+
hash[:structuredidentifier] = structuredidentifier.to_hash if structuredidentifier
|
254
|
+
hash[:type] = doctype if doctype
|
255
|
+
hash
|
256
|
+
end
|
257
|
+
|
248
258
|
private
|
249
259
|
|
250
260
|
# @param language [Array<String>]
|
251
261
|
# @raise ArgumentError
|
252
|
-
def check_language(language)
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
end
|
262
|
+
# def check_language(language)
|
263
|
+
# language.each do |lang|
|
264
|
+
# unless %w[en fr].include? lang
|
265
|
+
# raise ArgumentError, "invalid language: #{lang}"
|
266
|
+
# end
|
267
|
+
# end
|
268
|
+
# end
|
259
269
|
|
260
270
|
# @param script [Array<String>]
|
261
271
|
# @raise ArgumentError
|
262
|
-
def check_script(script)
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
end
|
272
|
+
# def check_script(script)
|
273
|
+
# script.each do |scr|
|
274
|
+
# raise ArgumentError, "invalid script: #{scr}" unless scr == "Latn"
|
275
|
+
# end
|
276
|
+
# end
|
267
277
|
|
268
278
|
# @param script [String]
|
269
279
|
# @raise ArgumentError
|
@@ -26,7 +26,7 @@ module RelatonIsoBib
|
|
26
26
|
@project_number = args[:project_number]
|
27
27
|
@part = args[:part]
|
28
28
|
@subpart = args[:subpart]
|
29
|
-
@prefix = args[:prefix]
|
29
|
+
# @prefix = args[:prefix]
|
30
30
|
@type = args[:type]
|
31
31
|
end
|
32
32
|
|
@@ -67,5 +67,16 @@ module RelatonIsoBib
|
|
67
67
|
end
|
68
68
|
xml[:type] = type if type
|
69
69
|
end
|
70
|
+
|
71
|
+
# @return [Hash]
|
72
|
+
def to_hash
|
73
|
+
hash = {}
|
74
|
+
hash[:tc_document_number] = tc_document_number if tc_document_number
|
75
|
+
hash[:project_number] = project_number if project_number
|
76
|
+
hash[:part] = part if part
|
77
|
+
hash[:subpart] = subpart if subpart
|
78
|
+
hash[:type] = type if type
|
79
|
+
hash
|
80
|
+
end
|
70
81
|
end
|
71
82
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-iso-bib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
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-08-
|
11
|
+
date: 2019-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|