iso-bib-item 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 5d664c071e9428da35d9ec460b4a8b34abadbf03abd1d1a8c202ea757e498418
4
- data.tar.gz: 5434689ba3040c366a40f6c1049ed87c26cfed7fe8adeb076698171b880dffa5
2
+ SHA1:
3
+ metadata.gz: 2e3ded14d469f9734fdab09cb033b9a0318d4862
4
+ data.tar.gz: 5a329772e2c0d75d0285a877195b7d28122f6e5a
5
5
  SHA512:
6
- metadata.gz: 8a29fd83d139dc5b077a7f5118925ef700d6e0b9a71487358d0a59a09226576f3d2b9ec09444f4f20a6534724beedad12325dbb3897f9a81b2bb2c3785950790
7
- data.tar.gz: 80e6797f1387d1bc7823f5d4c32d7849ecf91d82aff99e55cdcb44df5058d82063387d0b64c025020881dd42c85331c881edb01583348c07bc2f7bcced02b0aa
6
+ metadata.gz: a4858b2a74995529c1d6f80021bdba641ed9af66de133600872a13e5f66404bbecacc4b9394a528444f472ea6345037a7248332ea0ac8cf9d6e36675e9c5ec09
7
+ data.tar.gz: 521ace1e261b7a2de9ca37d819fcf6b7e6d15b9bbb0913dbb7d3106aa1b207ca8627c0915c3ebf1536a8998bfc32138c4a51611bdbdc3434f7763037d23280e9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- iso-bib-item (0.1.7)
4
+ iso-bib-item (0.1.9)
5
5
  duplicate
6
6
  isoics (~> 0.1.6)
7
7
  nokogiri
@@ -3,6 +3,7 @@
3
3
  require 'iso_bib_item/formatted_string'
4
4
  require 'iso_bib_item/contribution_info'
5
5
  require 'iso_bib_item/bibliographic_date'
6
+ require 'iso_bib_item/series'
6
7
 
7
8
  module IsoBibItem
8
9
  # module BibItemType
@@ -27,8 +28,18 @@ module IsoBibItem
27
28
  # @return [String]
28
29
  attr_reader :type
29
30
 
30
- def initialize(id)
31
- @id = id
31
+ def initialize(id:, type:)
32
+ @id = id
33
+ @type = type
34
+ end
35
+
36
+ #
37
+ # Add docidentifier xml element
38
+ #
39
+ # @param [Nokogiri::XML::Builder] builder
40
+ #
41
+ def to_xml(builder)
42
+ builder.docidentifier(id, type: type)
32
43
  end
33
44
  end
34
45
 
@@ -131,23 +142,29 @@ module IsoBibItem
131
142
  # @return [IsoBibItem::DocRelationCollection]
132
143
  attr_reader :relations
133
144
 
145
+ # @return [Array<IsoBibItem::Series>]
146
+ attr_reader :series
147
+
134
148
  # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
135
149
  # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
136
150
 
137
- # @param id [Arrat<IsoBibItem::DocumentIdentifier>]
151
+ # @param id [String]
138
152
  # @param title [Array<IsoBibItem::FormattedString>]
153
+ # @param docid [Array<IsoBibItem::DocumentIdentifier]
139
154
  # @param language [Arra<String>]
140
155
  # @param script [Array<String>]
156
+ # @param docstatus [IsoBibItem::DocumentStatus, NilClass]
141
157
  # @param dates [Array<Hash{type=>String, from=>String, to=>String}>]
142
158
  # @param contributors [Array<Hash{entity=>Hash{name=>String, url=>String,
143
159
  # abbreviation=>String}, roles=>Array<String>}>]
144
160
  # @param abstract [Array<Hash{content=>String, language=>String,
145
161
  # script=>String, type=>String}>]
146
162
  # @param relations [Array<Hash{type=>String, identifier=>String}>]
163
+ # @param series [Array<IsoBibItem::Series>]
147
164
  def initialize(**args)
148
165
  @id = args[:id]
149
166
  @title = (args[:titles] || []).map { |t| FormattedString.new t }
150
- @docidentifier = []
167
+ @docidentifier = args[:docid] || []
151
168
  @dates = (args[:dates] || []).map do |d|
152
169
  d.is_a?(Hash) ? BibliographicDate.new(d) : d
153
170
  end
@@ -158,11 +175,13 @@ module IsoBibItem
158
175
  @notes = []
159
176
  @language = args[:language]
160
177
  @script = args[:script]
178
+ @status = args[:docstatus]
161
179
  @abstract = (args[:abstract] || []).map do |a|
162
180
  FormattedString.new(a)
163
181
  end
164
182
  @relations = DocRelationCollection.new(args[:relations] || [])
165
183
  @source = args[:source].map { |s| TypedUri.new(s) }
184
+ @series = args[:series]
166
185
  end
167
186
  # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
168
187
  # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
@@ -177,12 +196,15 @@ module IsoBibItem
177
196
  end
178
197
  end
179
198
 
199
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
200
+
180
201
  # @return [String]
181
202
  def to_xml
182
203
  Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
183
204
  xml.bibitem(id: id) do
184
205
  title.each { |t| xml.title { t.to_xml xml } }
185
206
  source.each { |s| s.to_xml xml }
207
+ docidentifier.each { |di| di.to_xml xml }
186
208
  dates.each { |d| d.to_xml xml }
187
209
  contributors.each do |c|
188
210
  xml.contributor do
@@ -191,8 +213,11 @@ module IsoBibItem
191
213
  end
192
214
  end
193
215
  language.each { |l| xml.language l }
216
+ status&.to_xml xml
217
+ series.each { |s| s.to_xml xml } if series
194
218
  end
195
219
  end.doc.root.to_xml
196
220
  end
221
+ # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
197
222
  end
198
223
  end
@@ -82,6 +82,7 @@ module IsoBibItem
82
82
  @description = []
83
83
  end
84
84
 
85
+ # @params builder [Nokogiri::XML::Builder]
85
86
  def to_xml(builder)
86
87
  builder.affilation do
87
88
  builder.name { name.to_xml builder } if name
@@ -111,6 +112,7 @@ module IsoBibItem
111
112
  @uri.to_s
112
113
  end
113
114
 
115
+ # @params builder [Nokogiri::XML::Builder]
114
116
  def to_xml(builder)
115
117
  contacts.each { |contact| contact.to_xml builder }
116
118
  end
@@ -13,6 +13,7 @@ module IsoBibItem
13
13
  @status = status
14
14
  end
15
15
 
16
+ # @param [Nokogiri::XML::Builder]
16
17
  def to_xml(builder)
17
18
  builder.status do
18
19
  # FormattedString.instance_method(:to_xml).bind(status).call builder
@@ -28,6 +28,7 @@ module IsoBibItem
28
28
  content
29
29
  end
30
30
 
31
+ # @param builder [Nokogiri::XML::Builder]
31
32
  def to_xml(builder)
32
33
  builder.parent['language'] = language.join(',') if language.any?
33
34
  builder.parent['script'] = script.join(',') if script.any?
@@ -49,17 +49,17 @@ module IsoBibItem
49
49
  @identifiers = []
50
50
  end
51
51
 
52
- # rubocop:disable Metrics/AbcSize
53
52
  # @return [String]
54
53
  def to_xml(builder)
55
54
  builder.organization do
56
55
  builder.name { |b| name.to_xml b }
57
- builder.abbreviation { |a| abbreviation.to_xml a } if abbreviation
56
+ # unless abbreviati.content.nil? || abbreviation.content.empty?
57
+ builder.abbreviation { |a| abbreviation.to_xml a }
58
+ # end
58
59
  builder.uri uri.to_s if uri
59
60
  identifiers.each { |identifier| identifier.to_xml builder }
60
61
  super
61
62
  end
62
63
  end
63
- # rubocop:enable Metrics/AbcSize
64
64
  end
65
65
  end
@@ -95,10 +95,12 @@ module IsoBibItem
95
95
  @identifiers = []
96
96
  end
97
97
 
98
+ # @param builder [Nokogiri::XML::Builder]
98
99
  def to_xml(builder)
99
100
  builder.person do
100
101
  name.to_xml builder
101
102
  affilation.each { |a| a.to_xml builder }
103
+ contacts.each { |contact| contact.to_xml builder }
102
104
  end
103
105
  end
104
106
  end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module IsoBibItem
4
+ #
5
+ # Series class.
6
+ #
7
+ class Series
8
+ # @return [String] allowed values: "main" or "alt"
9
+ attr_reader :type
10
+
11
+ # @return [IsoBibItem::FormattedString] title
12
+ attr_reader :title
13
+
14
+ # @return [String]
15
+ attr_reader :place
16
+
17
+ # @return [String]
18
+ attr_reader :organization
19
+
20
+ # @return [IsoBibItem::LocalizedString]
21
+ attr_reader :abbreviation
22
+
23
+ # @return [String] date or year
24
+ attr_reader :from
25
+
26
+ # @return [String] date or year
27
+ attr_reader :to
28
+
29
+ # @return [String]
30
+ attr_reader :number
31
+
32
+ # @return [String]
33
+ attr_reader :part_number
34
+
35
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
36
+
37
+ # @param [Hash] **args <description>
38
+ def initialize(**args)
39
+ unless args[:title].is_a? IsoBibItem::FormattedString
40
+ raise ArgumentError, 'Parametr `title` shoud present'
41
+ end
42
+ @type = args[:type] if %w[main alt].include? args[:type]
43
+ @title = args[:title]
44
+ @place = args[:place]
45
+ @organization = args[:organization]
46
+ @abbreviation = args[:abbreviation]
47
+ @from = args[:from]
48
+ @to = args[:to]
49
+ @number = args[:number]
50
+ @part_number = args[:part_number]
51
+ end
52
+ # rubocop:enable Metrics/MethodLength
53
+
54
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
55
+
56
+ # @param builder [Nokogiri::XML::Builder]
57
+ def to_xml(builder)
58
+ builder.series type: type do
59
+ builder.title { title.to_xml builder } if title
60
+ builder.place place if place
61
+ builder.organization organization if organization
62
+ builder.abbreviation { abbreviation.to_xml builder } if abbreviation
63
+ builder.from from if from
64
+ builder.to to if to
65
+ builder.number number if number
66
+ builder.part_number part_number if part_number
67
+ end
68
+ end
69
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
70
+ # rubocop:enable Metrics/PerceivedComplexity
71
+ end
72
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module IsoBibItem
4
- VERSION = '0.1.8'.freeze
4
+ VERSION = '0.1.9'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iso-bib-item
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-25 00:00:00.000000000 Z
11
+ date: 2018-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -156,6 +156,7 @@ files:
156
156
  - lib/iso_bib_item/localized_string.rb
157
157
  - lib/iso_bib_item/organization.rb
158
158
  - lib/iso_bib_item/person.rb
159
+ - lib/iso_bib_item/series.rb
159
160
  - lib/iso_bib_item/version.rb
160
161
  homepage: https://github.com/riboseinc/gdbib
161
162
  licenses:
@@ -177,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
178
  version: '0'
178
179
  requirements: []
179
180
  rubyforge_project:
180
- rubygems_version: 2.7.6
181
+ rubygems_version: 2.6.12
181
182
  signing_key:
182
183
  specification_version: 4
183
184
  summary: 'IsoBibItem: Ruby ISOXMLDOC impementation.'