pubid-core 1.12.2 → 1.12.4

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: 9d2be43aad6f69c9b201bf69b722d6e305aef555bf32926004d8652d25dc3988
4
- data.tar.gz: 7f101b011e471f1c386ecfdf5fab54e830c76884e52d314bd94809d3d2a38748
3
+ metadata.gz: 2905a611f0bd23030009f14b8f3c9cbe7e24efbf3fdb9c2536fb895526a60706
4
+ data.tar.gz: 12380f2b1a7a2875909ac7c82e78eea20901fbe6c602819dc3054d85d31e754e
5
5
  SHA512:
6
- metadata.gz: 4c0263f2f4bab74aa39177da1187bf7138997ff7545ec2ade31edc0e29e50c066fe290dde176bbad9acb694b5e0dcf172e61fba4bf6dd7c15f9dd98af14e914f
7
- data.tar.gz: d91a015f964644d7ca16d67d1dc50fa80d29300ffb45abdda64a49601db216b63139fb6c08087b21b81b744fef28cc0e71fb85e422f29afae098f4aab4d6d795
6
+ metadata.gz: f5d25ff122a185577e2066ac58146f3b0e00059a41137100aafc6c57e412b5706dcf3b0fc1c4d86e53b413edc3933d2e0e50051b91a3d4ec7864e73116cd9316
7
+ data.tar.gz: 909377bfbd364f597ac87b7bb2e95111c453942e51d533ddb147d040298d59035d7c4fd227e5bc402d1b214e6384358ae1a1760104a96d7d9a0844bba30d24ec
@@ -45,7 +45,7 @@ module Pubid::Core
45
45
  end
46
46
 
47
47
  @publisher = publisher.to_s
48
- @number = number
48
+ @number = number&.to_s
49
49
  @copublisher = copublisher if copublisher
50
50
  @part = part.to_s if part
51
51
  @year = year.to_i if year
@@ -61,7 +61,7 @@ module Pubid::Core
61
61
  end
62
62
 
63
63
  # @return [Hash] Identifier's parameters
64
- def to_h(deep: true)
64
+ def to_h(deep: true, add_type: true)
65
65
  result = instance_variables.map do |var|
66
66
  value = instance_variable_get(var)
67
67
 
@@ -76,8 +76,8 @@ module Pubid::Core
76
76
  ]
77
77
  end.to_h
78
78
 
79
- if respond_to?(:type)
80
- result[:type] = self.type[:short]
79
+ if add_type && respond_to?(:type) && type[:short]
80
+ result[:type] = type[:short]
81
81
  end
82
82
 
83
83
  result
@@ -92,8 +92,22 @@ module Pubid::Core
92
92
  self.class.get_renderer_class.new(to_h(deep: false)).render
93
93
  end
94
94
 
95
- def exclude(*attrs)
96
- self.class.new(**to_h.reject { |k| attrs.include?(k) })
95
+ def exclude(*args)
96
+ nested_exclusions, top_level_exclusions = args.partition { |arg| arg.is_a?(Hash) }
97
+
98
+ nested_exclusions = nested_exclusions.reduce({}, :merge)
99
+
100
+ excluded_hash = to_h(add_type: false)
101
+ .reject { |k, v| top_level_exclusions.include?(k) }
102
+ .each_with_object({}) do |(k, v), memo|
103
+ memo[k] = if v.is_a?(Hash) && nested_exclusions.key?(k)
104
+ v.reject { |key, _| nested_exclusions[k].include?(key) }
105
+ else
106
+ v
107
+ end
108
+ end
109
+
110
+ self.class.new(**excluded_hash)
97
111
  end
98
112
 
99
113
  def typed_stage_abbrev
@@ -1,5 +1,5 @@
1
1
  module Pubid
2
2
  module Core
3
- VERSION = "1.12.2".freeze
3
+ VERSION = "1.12.4".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.2
4
+ version: 1.12.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-09 00:00:00.000000000 Z
11
+ date: 2024-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake