iso-bib-item 0.4.4 → 0.4.5

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
2
  SHA256:
3
- metadata.gz: ca79f41d3ca54902184130b6a7412f2fa789f980b02e11fa971f53c09b2198d8
4
- data.tar.gz: b7200cc75fe060f999f1bb45b75e88b2fdc9e8b7a53681d18809cecfc2006f96
3
+ metadata.gz: 93e9e966049ede92822f11ec8edb1af7a01a5a7d19c1ba5ec5db26191a0e6688
4
+ data.tar.gz: 9b2f5b360649b0ba149b05c5b90276c5a1c031a578fabbf10e822b002c928a17
5
5
  SHA512:
6
- metadata.gz: 4f77ce607e22d5ae4f3077b8197e6a44086ebeeeb490049be2781f52025e0bbcc2af87d05f9c11e32a372798633d85fc7d9ddcd80b481471f941296157983f89
7
- data.tar.gz: 6ce0d5f2ec69c816ecb3df5bb658e01747ec000c7bc2c16280e0c42623510f45c55252330639e088dd4b28a1c93c89b283190ad3d31019cde22c1db83c3f26b4
6
+ metadata.gz: 5cfcbff5e7d81f2cd893b3fce9a3d56293891ee3c4c7b8650b3b6f8d1d5bcd62c20f6a19354d987f763c442c7147404362fa44f0e6842911b4770abca030fdda
7
+ data.tar.gz: 5a0a92d527a0be5dc78b31f676a0de8611cc1398c8fe85826259fb82bd7ccc0cdb455ffb816d0d5c8102aa0624f80a5bab4b50a1d4c8fa1734569d8badd74b55
@@ -7,8 +7,8 @@ rvm:
7
7
  - 2.3
8
8
  - ruby-head
9
9
 
10
- before_install: gem install bundler -v 1.16.1
10
+ before_install: gem install bundler -v 2.0.1
11
11
 
12
12
  matrix:
13
13
  allow_failures:
14
- - rvm: ruby-head
14
+ - rvm: ruby-head
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- iso-bib-item (0.4.4)
4
+ iso-bib-item (0.4.5)
5
5
  isoics (~> 0.1.6)
6
6
  nokogiri (~> 1.8.4)
7
7
  ruby_deep_clone (~> 0.8.0)
@@ -9,14 +9,14 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- byebug (10.0.2)
12
+ byebug (11.0.1)
13
13
  coderay (1.1.2)
14
14
  diff-lcs (1.3)
15
15
  docile (1.3.1)
16
16
  equivalent-xml (0.6.0)
17
17
  nokogiri (>= 1.4.3)
18
18
  isoics (0.1.7)
19
- json (2.1.0)
19
+ json (2.2.0)
20
20
  method_source (0.9.2)
21
21
  mini_portile2 (2.3.0)
22
22
  nokogiri (1.8.5)
@@ -24,8 +24,8 @@ GEM
24
24
  pry (0.12.2)
25
25
  coderay (~> 1.1.0)
26
26
  method_source (~> 0.9.0)
27
- pry-byebug (3.6.0)
28
- byebug (~> 10.0)
27
+ pry-byebug (3.7.0)
28
+ byebug (~> 11.0)
29
29
  pry (~> 0.10)
30
30
  rake (10.5.0)
31
31
  rspec (3.8.0)
@@ -52,7 +52,7 @@ PLATFORMS
52
52
  ruby
53
53
 
54
54
  DEPENDENCIES
55
- bundler (~> 1.16)
55
+ bundler (~> 2.0.1)
56
56
  equivalent-xml (~> 0.6)
57
57
  iso-bib-item!
58
58
  pry-byebug
@@ -61,4 +61,4 @@ DEPENDENCIES
61
61
  simplecov
62
62
 
63
63
  BUNDLED WITH
64
- 1.17.1
64
+ 2.0.1
@@ -1,10 +1,10 @@
1
1
  = IsoBibItem
2
2
 
3
3
  image:https://img.shields.io/gem/v/iso-bib-item.svg["Gem Version", link="https://rubygems.org/gems/iso-bib-item"]
4
- image:https://img.shields.io/travis/riboseinc/iso-bib-item/master.svg["Build Status", link="https://travis-ci.org/riboseinc/iso-bib-item"]
5
- image:https://codeclimate.com/github/riboseinc/iso-bib-item/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/riboseinc/iso-bib-item"]
4
+ image:https://img.shields.io/travis/metanorma/iso-bib-item/master.svg["Build Status", link="https://travis-ci.com/metanorma/iso-bib-item"]
5
+ image:https://codeclimate.com/github/metanorma/iso-bib-item/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/iso-bib-item"]
6
6
 
7
- IsoBib is a Ruby gem that implements the https://github.com/riboseinc/isodoc-models#iso-bibliographic-item[IsoBibliographicItem model].
7
+ IsoBib is a Ruby gem that implements the https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibliographicItem model].
8
8
 
9
9
  == Installation
10
10
 
@@ -378,7 +378,7 @@ item.to_xml
378
378
 
379
379
  == BibliographicItem
380
380
 
381
- The ISO standards use a subset of the generic bibliographic fields specified in the https://github.com/riboseinc/isodoc-models#iso-bibliographic-item[IsoBibliographicItem model]:
381
+ The ISO standards use a subset of the generic bibliographic fields specified in the https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibliographicItem model]:
382
382
 
383
383
  * Title:
384
384
  ** English; French
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
 
13
13
  spec.summary = %(IsoBibItem: Ruby ISOXMLDOC impementation.)
14
14
  spec.description = %(IsoBibItem: Ruby ISOXMLDOC impementation.)
15
- spec.homepage = 'https://github.com/riboseinc/iso-bib-item'
15
+ spec.homepage = 'https://github.com/metanorma/iso-bib-item'
16
16
  spec.license = 'BSD-2-Clause'
17
17
 
18
18
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ['lib']
24
24
 
25
- spec.add_development_dependency 'bundler', '~> 1.16'
25
+ spec.add_development_dependency 'bundler', '~> 2.0.1'
26
26
  spec.add_development_dependency 'pry-byebug'
27
27
  spec.add_development_dependency 'rake', '~> 10.0'
28
28
  spec.add_development_dependency 'rspec', '~> 3.0'
@@ -28,21 +28,29 @@ module IsoBibItem
28
28
  @to = parse_date to
29
29
  end
30
30
 
31
- # rubocop:disable Metric/AbcSize
31
+ # rubocop:disable Metrics/AbcSize
32
32
 
33
33
  # @param builder [Nokogiri::XML::Builder]
34
34
  # @return [Nokogiri::XML::Builder]
35
35
  def to_xml(builder, **opts)
36
36
  builder.date(type: type) do
37
37
  if on
38
- builder.on(opts[:no_year] ? '--' : on.year)
39
- else
40
- builder.from(opts[:no_year] ? '--' : from.year)
41
- builder.to to.year if to
38
+ date = opts[:full_date] ? on.strftime("%Y-%m") : on.year
39
+ builder.on(opts[:no_year] ? '--' : date)
40
+ elsif from
41
+ if opts[:full_date]
42
+ date_form = from.strftime("%Y-%m")
43
+ date_to = to.strftime("%Y-%m") if to
44
+ else
45
+ date_form = from.year
46
+ date_to = to.year if to
47
+ end
48
+ builder.from(opts[:no_year] ? '--' : date_form)
49
+ builder.to date_to if to
42
50
  end
43
51
  end
44
52
  end
45
- # rubocop:enable Metric/AbcSize
53
+ # rubocop:enable Metrics/AbcSize
46
54
 
47
55
  private
48
56
 
@@ -189,6 +189,11 @@ module IsoBibItem
189
189
  a.is_a?(Hash) ? FormattedString.new(a) : a
190
190
  end
191
191
  @relations = DocRelationCollection.new(args[:relations] || [])
192
+ if args[:copyright]
193
+ @copyright = if args[:copyright].is_a?(Hash)
194
+ CopyrightAssociation.new args[:copyright]
195
+ else args[:copyright] end
196
+ end
192
197
  @link = args[:link].map { |s| s.is_a?(Hash) ? TypedUri.new(s) : s }
193
198
  @series = args[:series]
194
199
  @fetched = args.fetch :fetched, Date.today
@@ -206,6 +211,28 @@ module IsoBibItem
206
211
  end
207
212
  end
208
213
 
214
+ def makeid(id, attribute, delim = '')
215
+ return nil if attribute && !@id_attribute
216
+ id = @docidentifier.reject { |i| i.type == "DOI" }[0] unless id
217
+ #contribs = publishers.map { |p| p&.entity&.abbreviation }.join '/'
218
+ #idstr = "#{contribs}#{delim}#{id.project_number}"
219
+ #idstr = id.project_number.to_s
220
+ idstr = id.id.gsub(/:/, "-")
221
+ #if id.part_number&.size&.positive? then idstr += "-#{id.part_number}"
222
+ idstr.strip
223
+ end
224
+
225
+ # @return [String]
226
+ def shortref(identifier, **opts)
227
+ pubdate = dates.select { |d| d.type == "published" }
228
+ year = if opts[:no_year] || pubdate.empty? then ""
229
+ else ":" + pubdate&.first&.on&.year.to_s
230
+ end
231
+ year += ": All Parts" if opts[:all_parts] || @all_parts
232
+
233
+ "#{makeid(identifier, false, ' ')}#{year}"
234
+ end
235
+
209
236
  # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
210
237
 
211
238
  # @return [String]
@@ -216,7 +243,7 @@ module IsoBibItem
216
243
  title.each { |t| xml.title { t.to_xml xml } }
217
244
  link.each { |s| s.to_xml xml }
218
245
  docidentifier.each { |di| di.to_xml xml }
219
- dates.each { |d| d.to_xml xml }
246
+ dates.each { |d| d.to_xml xml, full_date: true }
220
247
  contributors.each do |c|
221
248
  xml.contributor do
222
249
  c.role.each { |r| r.to_xml xml }
@@ -224,7 +251,11 @@ module IsoBibItem
224
251
  end
225
252
  end
226
253
  language.each { |l| xml.language l }
227
- status&.to_xml xml
254
+ script.each { |s| xml.script s }
255
+ abstract.each { |a| xml.abstract { a.to_xml(xml) } }
256
+ status.to_xml xml if status
257
+ copyright.to_xml xml if copyright
258
+ relations.each { |r| r.to_xml xml }
228
259
  series.each { |s| s.to_xml xml } if series
229
260
  end
230
261
  end.doc.root.to_xml
@@ -167,7 +167,7 @@ module IsoBibItem
167
167
  def initialize(**args)
168
168
  super_args = args.select do |k|
169
169
  %i[
170
- id language script dates abstract contributors relations link
170
+ id language script dates abstract contributors relations copyright link
171
171
  ].include? k
172
172
  end
173
173
  super(super_args)
@@ -189,11 +189,6 @@ module IsoBibItem
189
189
  else args[:workgroup] end
190
190
  end
191
191
  @ics = args[:ics].map { |i| i.is_a?(Hash) ? Ics.new(i) : i }
192
- if args[:copyright]
193
- @copyright = if args[:copyright].is_a?(Hash)
194
- CopyrightAssociation.new args[:copyright]
195
- else args[:copyright] end
196
- end
197
192
  @link = args[:link].map { |s| s.is_a?(Hash) ? TypedUri.new(s) : s }
198
193
  @id_attribute = true
199
194
  end
@@ -237,17 +232,6 @@ module IsoBibItem
237
232
  end
238
233
  end
239
234
 
240
- # @return [String]
241
- def shortref(identifier, **opts)
242
- pubdate = dates.select { |d| d.type == "published" }
243
- year = if opts[:no_year] || pubdate.empty? then ""
244
- else ":" + pubdate&.first&.on&.year&.to_s
245
- end
246
- year += ": All Parts" if opts[:all_parts] || @all_parts
247
-
248
- "#{makeid(identifier, false, ' ')}#{year}"
249
- end
250
-
251
235
  # @param type [Symbol] type of url, can be :src/:obp/:rss
252
236
  # @return [String]
253
237
  def url(type = :src)
@@ -311,9 +295,9 @@ module IsoBibItem
311
295
  script.each { |s| builder.script s }
312
296
  abstract.each { |a| builder.abstract { a.to_xml(builder) } }
313
297
  status.to_xml builder
314
- copyright&.to_xml builder
298
+ copyright.to_xml builder if copyright
315
299
  relations.each { |r| r.to_xml builder }
316
- workgroup&.to_xml builder
300
+ workgroup.to_xml builder if workgroup
317
301
  if opts[:note]
318
302
  builder.note("ISO DATE: #{opts[:note]}", format: 'text/plain')
319
303
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module IsoBibItem
4
- VERSION = '0.4.4'.freeze
4
+ VERSION = '0.4.5'.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.4.4
4
+ version: 0.4.5
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-11-27 00:00:00.000000000 Z
11
+ date: 2019-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: 2.0.1
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.16'
26
+ version: 2.0.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pry-byebug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -174,7 +174,7 @@ files:
174
174
  - lib/iso_bib_item/series.rb
175
175
  - lib/iso_bib_item/version.rb
176
176
  - lib/iso_bib_item/xml_parser.rb
177
- homepage: https://github.com/riboseinc/iso-bib-item
177
+ homepage: https://github.com/metanorma/iso-bib-item
178
178
  licenses:
179
179
  - BSD-2-Clause
180
180
  metadata: {}