ooxml_parser 0.38.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4bc1ff538795412ae50d0eaef25915e142f6b8834d316c42ee9900dcf215ed0c
4
- data.tar.gz: 8e807903a12ec8dfdc9b8a490de8fdd4b4df01135b5f9d0388de86613ae30457
3
+ metadata.gz: 064ea9325ec10b0d22eeaf5774ffc480746f739ab78d5580eda00f05499e7111
4
+ data.tar.gz: 71aace963676dec9978977537985b8e9d834cca7ad8e6f7a4a5b24736694d287
5
5
  SHA512:
6
- metadata.gz: e652d471af15d19de026c9c17a462829bc0f6393207d81a982e2584ea03f4392915ac36726e3a6a1b147296b40c89f42641ae903ccc71ddbbe6c72407bb7096f
7
- data.tar.gz: 05a985c15a174a8a301c5b67f75025db076e9bf7a2e7f7c991a7724422b7abea37a359a4260a978e22421a0299e33fd17dbca619c34cfc6d49a0461938d4c602
6
+ metadata.gz: e0205f6ce29895ba3597afab6184ce8959515c4997dce7ffcbca329c98c6fc394eec73a5b0f05e66e0c5b240b41eefa4dba7fdc4b06c2dd6f0218cb273792840
7
+ data.tar.gz: de025b3b50f9dd8cf5151861d6767f799bb993e7de46afe003c60957f79d1a03223488d0e78a13605a29adcde415511c1d780d137924cdf43c4f08c2e12b8a03
@@ -133,7 +133,7 @@ module OoxmlParser
133
133
 
134
134
  # @return [String] result of convert of object to string
135
135
  def to_s
136
- "#{@column}#{@row} #{@list ? "list: #{@list}" : ''}"
136
+ "#{@column}#{@row} #{"list: #{@list}" if @list}"
137
137
  end
138
138
 
139
139
  def nil?
@@ -3,33 +3,7 @@
3
3
  module OoxmlParser
4
4
  # Module for helper methods for OOXMLDocumentObject
5
5
  module OoxmlDocumentObjectHelper
6
- # Convert object to hash
7
- # @return [Hash]
8
- def to_hash
9
- result_hash = {}
10
- instance_variables.each do |current_attribute|
11
- next if current_attribute == :@parent
12
-
13
- attribute_value = instance_variable_get(current_attribute)
14
- next unless attribute_value
15
-
16
- if attribute_value.is_a?(Array)
17
- attribute_value.each_with_index do |object_element, index|
18
- result_hash[:"#{current_attribute}_#{index}"] = object_element.to_hash
19
- end
20
- else
21
- result_hash[current_attribute.to_sym] = if attribute_value.respond_to?(:to_hash)
22
- attribute_value.to_hash
23
- else
24
- attribute_value.to_s
25
- end
26
- end
27
- end
28
- result_hash
29
- end
30
-
31
- private
32
-
6
+ # @return [Hash] Hash to Convert value to human readable symbol
33
7
  VALUE_TO_SYMBOL_HASH = { l: :left,
34
8
  ctr: :center,
35
9
  r: :right,
@@ -98,6 +72,33 @@ module OoxmlParser
98
72
  rnd: :round,
99
73
  sq: :square }.freeze
100
74
 
75
+ # Convert object to hash
76
+ # @return [Hash]
77
+ def to_hash
78
+ result_hash = {}
79
+ instance_variables.each do |current_attribute|
80
+ next if current_attribute == :@parent
81
+
82
+ attribute_value = instance_variable_get(current_attribute)
83
+ next unless attribute_value
84
+
85
+ if attribute_value.is_a?(Array)
86
+ attribute_value.each_with_index do |object_element, index|
87
+ result_hash[:"#{current_attribute}_#{index}"] = object_element.to_hash
88
+ end
89
+ else
90
+ result_hash[current_attribute.to_sym] = if attribute_value.respond_to?(:to_hash)
91
+ attribute_value.to_hash
92
+ else
93
+ attribute_value.to_s
94
+ end
95
+ end
96
+ end
97
+ result_hash
98
+ end
99
+
100
+ private
101
+
101
102
  # Convert value to human readable symbol
102
103
  # @param [String] value to convert
103
104
  # @return [Symbol]
@@ -19,11 +19,11 @@ module OoxmlParser
19
19
  # @return [Symbol] type of border in visual editor
20
20
  def border_visual_type
21
21
  result = []
22
- result << :left if @left.val == :single
23
- result << :right if @right.val == :single
24
- result << :top if @top.val == :single
25
- result << :bottom if @bottom.val == :single
26
- result << :inner if @between.val == :single
22
+ result << :left if @left && @left.val == :single
23
+ result << :right if @right && @right.val == :single
24
+ result << :top if @top && @top.val == :single
25
+ result << :bottom if @bottom && @bottom.val == :single
26
+ result << :inner if @between && @between.val == :single
27
27
  return :none if result == []
28
28
  return :all if result == %i[left right top bottom inner]
29
29
  return :outer if result == %i[left right top bottom]
@@ -44,7 +44,7 @@ module OoxmlParser
44
44
  # @return [Hash] hash with sorted values
45
45
  # TODO: Totally redone parsing of spacing to remove this workaround
46
46
  def sorted_attributes(node)
47
- node.attributes.sort.reverse.to_h
47
+ node.attributes.sort.reverse!.to_h
48
48
  end
49
49
  end
50
50
  end
@@ -37,7 +37,7 @@ module OoxmlParser
37
37
  transform = transform_of_object(object)
38
38
  return :left if transform.offset.x.zero?
39
39
  return :center if OoxmlSize.new((slide_size.width.value / 2) - (transform.extents.x.value / 2)) == OoxmlSize.new(transform.offset.x.value)
40
- return :right if OoxmlSize.new((slide_size.width.value - transform.extents.x.value)) == OoxmlSize.new(transform.offset.x.value)
40
+ return :right if OoxmlSize.new(slide_size.width.value - transform.extents.x.value) == OoxmlSize.new(transform.offset.x.value)
41
41
 
42
42
  :unknown
43
43
  end
@@ -4,6 +4,6 @@ module OoxmlParser
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
6
  # [String] Version of Gem
7
- STRING = '0.38.0'
7
+ STRING = '0.39.0'
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ooxml_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.38.0
4
+ version: 0.39.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ONLYOFFICE
@@ -9,7 +9,7 @@ authors:
9
9
  - Roman Zagudaev
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2025-02-17 00:00:00.000000000 Z
12
+ date: 1980-01-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -494,7 +494,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
494
494
  - !ruby/object:Gem::Version
495
495
  version: '0'
496
496
  requirements: []
497
- rubygems_version: 3.6.3
497
+ rubygems_version: 3.6.9
498
498
  specification_version: 4
499
499
  summary: OoxmlParser Gem
500
500
  test_files: []