xml-mixup 0.1.15 → 0.2.0

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: 83154ccf54f91484833c4f3b6990bce856635bc95864eeae11edb5b791d1118c
4
- data.tar.gz: 6cc3737aedbaf7b5c9c04dc621b003c3047b6f86c16f9ab954da4a5bb4c774d0
3
+ metadata.gz: 460b4560533df750db75bcee4c5a6eedfaaece84faea406fc3f2711845ab17c0
4
+ data.tar.gz: 1f6311bcaa48547ce09f3ee718afa0077589addd2466982aaee2dd743035d6fa
5
5
  SHA512:
6
- metadata.gz: f4591665e4d05cbe1b5d3d638f37f54d5e39a8ff79f4037814783c954cdeebb7809f4f3890f481148f4ff24c7a42d981df97b0d361965f078ba5b1f5f49876de
7
- data.tar.gz: 7fe10c1db99f7fdf143f7fb49b20cdf68b4c157758c72cfb31cd8ba71cbbbad4647b574e3353c61ea9bd4169b2f9d8b2000c27d3b1f28a667929f8fd62f7ac56
6
+ metadata.gz: 2de6209eba128209f7433fcb50df44f9f4de64e3607e82d81e24b4b64c76a3c4e7d88d5625d4e3db2f9c2022058ca2fba6dd99764ccabd1bc7cecaf20c15696a
7
+ data.tar.gz: 163e037051e2f295254d3aa11972f213faf904e458aa8276e2451cfe4653defe69f617d6e322d3b7a1eeff952b1ccd2b4d4434360040b0c1d7949b4a92807463
@@ -1,5 +1,5 @@
1
1
  module XML
2
2
  module Mixup
3
- VERSION = "0.1.15"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
data/lib/xml/mixup.rb CHANGED
@@ -63,21 +63,22 @@ module XML::Mixup
63
63
  #
64
64
  # @return [String] the attribute in question.
65
65
  #
66
- def flatten_attr obj, args
66
+ def flatten_attr obj, args = []
67
67
  return if obj.nil?
68
+ args ||= []
68
69
  # early bailout for most likely condition
69
70
  if ATOMS.any? { |x| obj.is_a? x }
70
71
  obj.to_s
71
72
  elsif obj.is_a? Hash
72
73
  tmp = obj.sort.map do |kv|
73
- v = flatten_attr kv[1], args
74
- v.nil? ? nil : "#{kv[0].to_s}: #{v}"
74
+ v = flatten_attr kv.last, args
75
+ v.nil? ? nil : "#{kv.first.to_s}: #{v}"
75
76
  end.compact
76
77
  tmp.empty? ? nil : tmp.join(' ')
77
78
  elsif obj.respond_to? :call
78
79
  flatten_attr obj.call(*args), args
79
- elsif obj.respond_to? :map
80
- tmp = obj.map { |x| flatten_attr x, args }.reject do |x|
80
+ elsif [Array, Set].any? { |c| obj.is_a? c }
81
+ tmp = obj.to_a.map { |x| flatten_attr x, args }.reject do |x|
81
82
  x.nil? || x == ''
82
83
  end
83
84
  tmp.empty? ? nil : tmp.join(' ')
@@ -491,6 +492,9 @@ module XML::Mixup
491
492
  extra: [], head: {}, body: {}, attr: {}, content: [],
492
493
  transform: nil, dtd: true, xmlns: true, args: []
493
494
 
495
+ vocab ||= prefix[nil]
496
+ prefix = prefix.except nil if prefix
497
+
494
498
  spec = []
495
499
 
496
500
  # add xslt stylesheet
@@ -572,7 +576,7 @@ module XML::Mixup
572
576
  root[:prefix] = prefix
573
577
 
574
578
  if xmlns
575
- x = prefix.transform_keys { |k| "xmlns:#{k}" }
579
+ x = prefix.except(nil).transform_keys { |k| "xmlns:#{k}" }
576
580
  root = x.merge(root)
577
581
  end
578
582
  end
data/xml-mixup.gemspec CHANGED
@@ -21,9 +21,9 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_development_dependency "bundler", "~> 2.1"
25
- spec.add_development_dependency "rake", "~> 13.0"
26
- spec.add_development_dependency "rspec", "~> 3.9"
24
+ spec.add_development_dependency "bundler", ">= 2.1"
25
+ spec.add_development_dependency "rake", ">= 13.0"
26
+ spec.add_development_dependency "rspec", ">= 3.9"
27
27
 
28
28
  spec.add_dependency "nokogiri", ">= 1.13.6"
29
29
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xml-mixup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Taylor
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-01 00:00:00.000000000 Z
11
+ date: 2023-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.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
26
  version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.9'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.9'
55
55
  - !ruby/object:Gem::Dependency
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []
107
- rubygems_version: 3.3.11
107
+ rubygems_version: 3.3.15
108
108
  signing_key:
109
109
  specification_version: 4
110
110
  summary: A mixin for (XML) markup