pubid-core 1.12.0 → 1.12.1

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: 8752ce15b475a7cf21261ea7d1cac28e181052b6a888487a93f89c679bc3a317
4
- data.tar.gz: 85f903a2d68b26497c832a41255a571ba76b55f56c754f277ca1b6a27ccde9ca
3
+ metadata.gz: 448ee8d0c3ee2f141390d279b470709a69d479dd8203aab75202ec53f4b5d219
4
+ data.tar.gz: '0284a013694e73ddba1e96d3c560dbd27f15a69840f50cc33f19035adab3a373'
5
5
  SHA512:
6
- metadata.gz: 87c242c84385cbdceb1e711ea16ebf96b844d591e900e75923fe1812ffff1a7ab5383ca8442e22a562a2d89b0cd910364a145c0044ce71ab8380c956dab7eba2
7
- data.tar.gz: aa97a199ccaec9ddda10615c339308d64240d28f2bebf32075f50b17d34776b1f0d25d87f278498d6f4d79cb07291a5a1250c11d81446184c163d5a7637998b7
6
+ metadata.gz: d7c8e1f74a0fb9fedb9388971edf1f2920917b1ea2d9d1fedab7cd7168412a9c085434f3da4ddf796d1921909db6589af4e1b4430a795227df65cf0dd2dc136b
7
+ data.tar.gz: 8c53cb46cf3fed1bcfbf1138063fbc728ad9c80b03b903a46acd211ce79fce6a086530280fbe6a63ef0d08671d468d6e9eaba489e9e22bfc0709f10da54fd776
@@ -1,8 +1,7 @@
1
1
  module Pubid::Core
2
2
  module Identifier
3
3
  class Base
4
- attr_accessor :number, :publisher, :copublisher, :part,
5
- :type, :year, :edition, :language, :amendments,
4
+ attr_accessor :number, :publisher, :copublisher, :part, :year, :edition, :language, :amendments,
6
5
  :corrigendums, :stage
7
6
 
8
7
  TYPED_STAGES = {}.freeze
@@ -21,7 +20,7 @@ module Pubid::Core
21
20
  # @param corrigendums [Array<Corrigendum>,Array<Hash>] document's corrigendums
22
21
  # @see Amendment
23
22
  # @see Corrigendum
24
- def initialize(publisher:, number:, copublisher: nil, part: nil, type: nil,
23
+ def initialize(publisher:, number:, copublisher: nil, part: nil,
25
24
  year: nil, edition: nil, language: nil, amendments: nil,
26
25
  corrigendums: nil, stage: nil)
27
26
 
@@ -49,7 +48,6 @@ module Pubid::Core
49
48
  @number = number
50
49
  @copublisher = copublisher if copublisher
51
50
  @part = part.to_s if part
52
- @type = type.to_s if type
53
51
  @year = year.to_i if year
54
52
  @edition = edition.to_i if edition
55
53
  @language = language.to_s if language
@@ -64,7 +62,7 @@ module Pubid::Core
64
62
 
65
63
  # @return [Hash] Identifier's parameters
66
64
  def to_h(deep: true)
67
- instance_variables.map do |var|
65
+ result = instance_variables.map do |var|
68
66
  value = instance_variable_get(var)
69
67
 
70
68
  [var.to_s.gsub("@", "").to_sym,
@@ -77,6 +75,12 @@ module Pubid::Core
77
75
  end
78
76
  ]
79
77
  end.to_h
78
+
79
+ if respond_to?(:type)
80
+ result[:type] = self.type[:key]
81
+ end
82
+
83
+ result
80
84
  end
81
85
 
82
86
  def ==(other)
@@ -12,10 +12,10 @@ module Pubid::Core
12
12
  # @param typed_stage_or_stage [String] typed stage or stage
13
13
  # @return identifier's class
14
14
  def resolve_identifier(parameters = {})
15
- return @config.default_type.new(**parameters) if parameters[:type].nil? && parameters[:stage].nil?
15
+ return @config.default_type.new(**parameters.dup.tap { |h| h.delete(:type) }) if parameters[:type].nil? && parameters[:stage].nil?
16
16
 
17
17
  @config.types.each do |identifier_type|
18
- return identifier_type.new(**parameters) if identifier_type.type_match?(parameters)
18
+ return identifier_type.new(**parameters.dup.tap { |h| h.delete(:type) }) if identifier_type.type_match?(parameters)
19
19
  end
20
20
 
21
21
  # When stage is not typed stage and type is not defined
@@ -1,5 +1,5 @@
1
1
  module Pubid
2
2
  module Core
3
- VERSION = "1.12.0".freeze
3
+ VERSION = "1.12.1".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubid-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 1.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-24 00:00:00.000000000 Z
11
+ date: 2023-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake