iso-bib-item 0.1.7 → 0.1.8

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
- SHA1:
3
- metadata.gz: 28b47902774baa20582877c3f4bb40b511858665
4
- data.tar.gz: 0b91cba1d8b30a5b725ef4cb5c6945ac17fdc197
2
+ SHA256:
3
+ metadata.gz: 5d664c071e9428da35d9ec460b4a8b34abadbf03abd1d1a8c202ea757e498418
4
+ data.tar.gz: 5434689ba3040c366a40f6c1049ed87c26cfed7fe8adeb076698171b880dffa5
5
5
  SHA512:
6
- metadata.gz: 9fe3106f7ce849ad2f8687abb31c936ab782e9cb143c8a6cd94a0e276ace015fd9289bce6fb1426537dcd5aa9d0c2998c58087d7888252cbdcef23ca52e04bc4
7
- data.tar.gz: 7a8de9331fa305198f6f63c04a93f913d34a276687dd9ff164d7575ef1648ce5900bd594d3b879d26fc6d198ec5abec633870eb3fa1b378471e4d57ebd9f087e
6
+ metadata.gz: 8a29fd83d139dc5b077a7f5118925ef700d6e0b9a71487358d0a59a09226576f3d2b9ec09444f4f20a6534724beedad12325dbb3897f9a81b2bb2c3785950790
7
+ data.tar.gz: 80e6797f1387d1bc7823f5d4c32d7849ecf91d82aff99e55cdcb44df5058d82063387d0b64c025020881dd42c85331c881edb01583348c07bc2f7bcced02b0aa
data/Gemfile CHANGED
@@ -1,3 +1,6 @@
1
+ Encoding.default_external = Encoding::UTF_8
2
+ Encoding.default_internal = Encoding::UTF_8
3
+
1
4
  source "https://rubygems.org"
2
5
 
3
6
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
@@ -57,7 +57,7 @@ item = IsoBibItem::IsoBibliographicItem.new(
57
57
  url: "www.iso.org", abbreviation: "ISO"
58
58
  }, roles: ["publisher"]}],
59
59
  workgroup: {
60
- name=>"International Organization for Standardization",
60
+ name: "International Organization for Standardization",
61
61
  abbreviation: "ISO",
62
62
  url: "www.iso.org",
63
63
  technical_committee: {
@@ -203,12 +203,73 @@ wg.uri
203
203
 
204
204
  [source,ruby]
205
205
  ----
206
- iso191152.relations
206
+ item.relations
207
207
  => [<IsoBibItem::DocumentRelation:0x007f983c3c2a18 @bib_locality=[], @identifier="ISO 19115:2003", @type="obsoletes", @url="/standard/26020.html">,
208
208
  <IsoBibItem::DocumentRelation:0x007f983c3c2950 @bib_locality=[], @identifier="ISO 19115:2003/Cor 1:2006", @type="obsoletes", @url="/standard/44361.html">,
209
209
  <IsoBibItem::DocumentRelation:0x007f983c3c28d8 @bib_locality=[], @identifier="ISO 19115-1:2014/Amd 1:2018", @type="updates", @url="/standard/73118.html">]
210
210
  ----
211
211
 
212
+ === Reference modification: convert to all parts reference
213
+
214
+ In ISO, an All Parts reference is a reference to all parts of a standard. If a standard consists of parts,
215
+ only those parts are referenced in the ISO web site (as retrieved by the isobib gem). A part reference is
216
+ converted to an All Parts reference by making the part reference a partOf relation to a new reference,
217
+ which strips the part number and part title of the original, and its abstract. The operation is destructive.
218
+
219
+ [source,ruby]
220
+ ----
221
+ item.to_all_parts
222
+ item.title(lang: "en")
223
+ => <IsoBibItem::IsoLocalizedTitle:0x007fd1d92e2b30
224
+ @language="en",
225
+ @script="Latn",
226
+ @title_intro="Geographic information",
227
+ @title_main="Metadata",
228
+ @title_part=nil>
229
+ item.shortref
230
+ => "ISO 19115:2014"
231
+ item.relations.last
232
+ => <IsoBibItem::DocumentRelation:0x00007f94009a2158 @type="partOf", @identifier=nil, @url=nil, @bib_locality=[],
233
+ @bibitem=#<IsoBibItem::IsoBibliographicItem:0x00007f94009f37d8
234
+ @id=nil,
235
+ @title=[#<IsoBibItem::IsoLocalizedTitle:0x00007f94009f3530
236
+ @title_intro="Geographic information",
237
+ @title_main="Metadata",
238
+ @title_part="Part 1: Fundamentals",
239
+ @language="en",
240
+ @script="Latn">
241
+ ....
242
+ ----
243
+
244
+ === Reference modification: convert to most recent reference
245
+
246
+ In ISO, an undated reference is interpreted as a _de dicto_ reference to the most recent instance of the
247
+ reference; if the document is read after a new version of the reference has been issued, the reference is taken
248
+ to refer to that new instance, even if that instance had not been published at the time the bibliography was authored.
249
+ All references on the ISO web site (as retrieved by the isobib gem) are dated. A dated reference is
250
+ converted to a Most Recent referece by making the dated reference an instance relation to a new reference,
251
+ which strips the date of publication of the original, and its abstract. The operation is destructive.
252
+
253
+ [source,ruby]
254
+ ----
255
+ item.dates
256
+ => [#<IsoBibItem::BibliographicDate:0x00007f9994977680 @type="published", @on=2014-01-04 00:00:00 +1100>]
257
+ item.to_most_recent_reference
258
+ item.dates
259
+ []
260
+ item.shortref
261
+ => "ISO 19115-1"
262
+ item.relations.last
263
+ => <IsoBibItem::DocumentRelation:0x00007f9a33976a60 @type="instance", @identifier=nil, @url=nil, @bib_locality=[],
264
+ @bibitem=#<IsoBibItem::IsoBibliographicItem:0x00007f9a3399ea60
265
+ @id=nil,
266
+ @title=[#<IsoBibItem::IsoLocalizedTitle:0x00007f9a3399e650 @title_intro="Geographic information", @title_main="Metadata", @title_part="Part 1: Fundamentals", @language="en", @script="Latn">, #<IsoBibItem::IsoLocalizedTitle:0x00007f9a3399e2e0 @title_intro="Information géographique", @title_main="Métadonnées", @title_part="Partie 1: Principes de base", @language="fr", @script="Latn">],
267
+ @docidentifier=#<IsoBibItem::IsoDocumentId:0x00007f9a3399e010 @project_number="19115", @part_number="1">,
268
+ @dates=[#<IsoBibItem::BibliographicDate:0x00007f9a3399dd90 @type="published", @on=2014-01-04 00:00:00 +1100>],
269
+ ....
270
+ ----
271
+
272
+
212
273
  === XML serialization
213
274
 
214
275
  [source,ruby]
@@ -130,14 +130,20 @@ module IsoBibItem
130
130
  @workgroup = IsoProjectGroup.new(args[:workgroup]) if args[:workgroup]
131
131
  @ics = args[:ics].map { |i| Ics.new(i) }
132
132
  @copyright = CopyrightAssociation.new args[:copyright] if args[:copyright]
133
+ @source = args[:source].map { |s| TypedUri.new(s) }
134
+ @id_attribute = true
133
135
  end
134
136
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
137
+
138
+ def disable_id_attribute
139
+ @id_attribute = false
140
+ end
135
141
 
136
142
  # convert ISO nnn-1 reference into an All Parts reference:
137
143
  # remove title part components and abstract
138
- # TODO: make nnn-1 partOf relation of the redacted document
139
144
  def to_all_parts
140
145
  me = Duplicate.duplicate(self)
146
+ me.disable_id_attribute
141
147
  @relations << DocumentRelation.new(type: "partOf", identifier: nil, url: nil, bibitem: me)
142
148
 
143
149
  @title.each(&:remove_part)
@@ -152,6 +158,7 @@ module IsoBibItem
152
158
  # of the redacated document
153
159
  def to_most_recent_reference
154
160
  me = Duplicate.duplicate(self)
161
+ me.disable_id_attribute
155
162
  @relations << DocumentRelation.new(type: "instance", identifier: nil, url: nil, bibitem: me)
156
163
  @abstract = []
157
164
  @dates = []
@@ -170,12 +177,13 @@ module IsoBibItem
170
177
  # @todo need to add ISO/IEC/IEEE
171
178
  # @return [String]
172
179
  def shortref(**opts)
173
- year = if opts[:all_parts] then ':All Parts'
174
- elsif opts[:no_year] then ''
175
- else ':' + @copyright.from&.year&.to_s
180
+ pubdate = dates.select { |d| d.type == "published" }
181
+ year = if opts[:no_year] || pubdate.empty? then ""
182
+ else ':' + pubdate&.first&.on&.year&.to_s
176
183
  end
184
+ year += ": All Parts" if opts[:all_parts] || @all_parts
177
185
 
178
- "#{id(' ')}#{year}"
186
+ "#{id(false, ' ')}#{year}"
179
187
  end
180
188
 
181
189
  # @param type [Symbol] type of url, can be :src/:obp/:rss
@@ -203,7 +211,8 @@ module IsoBibItem
203
211
  end
204
212
  end
205
213
 
206
- def id(delim = '')
214
+ def id(attribute, delim = '')
215
+ return nil if attribute && !@id_attribute
207
216
  contribs = publishers.map { |p| p&.entity&.abbreviation }.join '/'
208
217
  idstr = "#{contribs}#{delim}#{@docidentifier.project_number}"
209
218
  if @docidentifier.part_number&.size&.positive?
@@ -212,8 +221,15 @@ module IsoBibItem
212
221
  idstr.strip
213
222
  end
214
223
 
224
+ def xml_attrs(type)
225
+ attrs = { type: type }
226
+ attr_id = id(true)
227
+ attrs[:id] = attr_id if attr_id
228
+ attrs
229
+ end
230
+
215
231
  def render_xml(builder, **opts)
216
- builder.send(:bibitem, type: type, id: id) do
232
+ builder.send(:bibitem, xml_attrs(type)) do
217
233
  title.each { |t| t.to_xml builder }
218
234
  source.each { |s| s.to_xml builder }
219
235
  # docidentifier.to_xml builder
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module IsoBibItem
4
- VERSION = '0.1.7'.freeze
4
+ VERSION = '0.1.8'.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.7
4
+ version: 0.1.8
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-20 00:00:00.000000000 Z
11
+ date: 2018-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -177,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  version: '0'
178
178
  requirements: []
179
179
  rubyforge_project:
180
- rubygems_version: 2.6.12
180
+ rubygems_version: 2.7.6
181
181
  signing_key:
182
182
  specification_version: 4
183
183
  summary: 'IsoBibItem: Ruby ISOXMLDOC impementation.'