goldendocx 0.2.3 → 0.3.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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -5
  3. data/.ruby-version +1 -0
  4. data/Gemfile.lock +1 -1
  5. data/demo/tables/create_embed_image_table.rb +3 -3
  6. data/demo/templates/xml_to_class.rb +6 -0
  7. data/lib/goldendocx/charts/properties.rb +1 -1
  8. data/lib/goldendocx/charts/series.rb +2 -2
  9. data/lib/goldendocx/charts.rb +1 -1
  10. data/lib/goldendocx/components/bar_chart.rb +2 -2
  11. data/lib/goldendocx/components/chart.rb +6 -6
  12. data/lib/goldendocx/components/column_chart.rb +2 -2
  13. data/lib/goldendocx/components/doughnut_chart.rb +2 -2
  14. data/lib/goldendocx/components/line_chart.rb +2 -2
  15. data/lib/goldendocx/components/properties.rb +1 -1
  16. data/lib/goldendocx/components/table.rb +2 -2
  17. data/lib/goldendocx/components.rb +1 -1
  18. data/lib/goldendocx/document.rb +2 -2
  19. data/lib/goldendocx/documents/body.rb +3 -3
  20. data/lib/goldendocx/documents/properties.rb +1 -1
  21. data/lib/goldendocx/documents.rb +1 -1
  22. data/lib/goldendocx/docx.rb +2 -2
  23. data/lib/goldendocx/element.rb +4 -4
  24. data/lib/goldendocx/has_associations.rb +4 -2
  25. data/lib/goldendocx/has_children.rb +2 -2
  26. data/lib/goldendocx/images/picture.rb +1 -1
  27. data/lib/goldendocx/images/properties.rb +1 -1
  28. data/lib/goldendocx/images.rb +1 -1
  29. data/lib/goldendocx/models/relationships.rb +1 -1
  30. data/lib/goldendocx/models.rb +1 -1
  31. data/lib/goldendocx/parts/content_types.rb +3 -3
  32. data/lib/goldendocx/parts/documents.rb +3 -3
  33. data/lib/goldendocx/parts/media.rb +1 -1
  34. data/lib/goldendocx/parts/properties.rb +1 -1
  35. data/lib/goldendocx/parts.rb +1 -1
  36. data/lib/goldendocx/tables/header_cell.rb +1 -1
  37. data/lib/goldendocx/tables/properties.rb +1 -1
  38. data/lib/goldendocx/tables.rb +1 -1
  39. data/lib/goldendocx/version.rb +1 -1
  40. data/lib/goldendocx/xml_serializers/nokogiri.rb +4 -4
  41. data/lib/goldendocx/xml_serializers/ox.rb +5 -5
  42. metadata +5 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec01d96d925886ed23aa79de96bfcc71fd8c0cb0c151239c7696536095b7c8c4
4
- data.tar.gz: e72d2a380906b12216d2e29ef2cb4ec94e9036860d9d5000a60313f8a95a8350
3
+ metadata.gz: dc5f8d130528f4e1f5e5738146ab61e9cc771968d549ec251d1996aa7704c1e8
4
+ data.tar.gz: 37981979a35e94d81c5515783f28752ebcf0425a635d2d610afdab1b05b4c897
5
5
  SHA512:
6
- metadata.gz: c53baede5b94336cbf2b3461183d3301114842d3bea12957655f86118d9fa9050f7f78ab2ed072720bcd0f43c126b61a8ea59cdf78b28cb7fd3282f676937860
7
- data.tar.gz: 576eca3f0caedb097062afb1952ee05ac39786848498cc9de1ac55359a25131320fd2d93a0df3e75ab992419b98bef1a4831e7d4bbb2e34a0fcbe540d69fa29b
6
+ metadata.gz: a1e8b756aa8960aa6796a23539498bb9632c68cc8f2c7e18bd02cc5546926afc61347302e8251eeb5e676075dfc97f2bc7c5126d626aec7b6b7f48400aa7f4b1
7
+ data.tar.gz: 7e4b16e552fbac46c52880c39267472d07481a5a895a9e98d892b508d51a040de7e0bd32bac05ad26c29cb722cd7829df0321b02f47ad14c53e977a758802bac
data/.rubocop.yml CHANGED
@@ -4,12 +4,8 @@ require:
4
4
 
5
5
  AllCops:
6
6
  NewCops: enable
7
- TargetRubyVersion: 2.7
7
+ TargetRubyVersion: 3.2
8
8
  SuggestExtensions: false
9
- Exclude:
10
- - 'tmp/**/*'
11
- - 'demo/templates/xml_to_class.rb'
12
-
13
9
 
14
10
  Metrics/AbcSize:
15
11
  CountRepeatedAttributes: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- goldendocx (0.2.3)
4
+ goldendocx (0.3.0)
5
5
  activesupport (~> 7.0)
6
6
  nokogiri (~> 1.14)
7
7
  ox (~> 2.14)
@@ -27,9 +27,9 @@ image_base64 = File.read("#{Dir.pwd}/demo/templates/image_base64")
27
27
  image = docx.create_embed_image(image_base64, width: 720000, height: 720000, align: :left)
28
28
 
29
29
  rows = [
30
- [Goldendocx::Tables::ImageCell.new(image: image, content: '选项A'), 3, '¥3.00', '¥9.00'],
31
- [Goldendocx::Tables::ImageCell.new(image: image, content: '选项B'), 4, '¥6.50', '¥18.00'],
32
- [Goldendocx::Tables::ImageCell.new(image: image, content: '选项C'), 10, '¥6.00', '¥60.00']
30
+ [Goldendocx::Tables::ImageCell.new(image:, content: '选项A'), 3, '¥3.00', '¥9.00'],
31
+ [Goldendocx::Tables::ImageCell.new(image:, content: '选项B'), 4, '¥6.50', '¥18.00'],
32
+ [Goldendocx::Tables::ImageCell.new(image:, content: '选项C'), 10, '¥6.00', '¥60.00']
33
33
  ]
34
34
  rows.each do |r|
35
35
  row = table.add_row(r)
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Metrics/AbcSize
4
+ # rubocop:disable Metrics/MethodLength
5
+ # rubocop:disable Metrics/CyclomaticComplexity
3
6
  require 'ox'
4
7
  require 'fileutils'
5
8
  require 'active_support/core_ext/string/inflections'
@@ -89,3 +92,6 @@ class XmlToClass
89
92
  end
90
93
  end
91
94
  end
95
+ # rubocop:enable Metrics/AbcSize
96
+ # rubocop:enable Metrics/MethodLength
97
+ # rubocop:enable Metrics/CyclomaticComplexity
@@ -7,6 +7,6 @@ module Goldendocx
7
7
  end
8
8
  end
9
9
 
10
- Dir.glob(File.join(File.dirname(__FILE__), 'properties', '*.rb').to_s).sort.each do |file|
10
+ Dir.glob(File.join(File.dirname(__FILE__), 'properties', '*.rb').to_s).each do |file|
11
11
  require file
12
12
  end
@@ -27,7 +27,7 @@ module Goldendocx
27
27
  def categories=(categories)
28
28
  category_axis.values.build_count(count: categories.size)
29
29
  categories.each_with_index do |cat, index|
30
- point = category_axis.values.build_point(index: index)
30
+ point = category_axis.values.build_point(index:)
31
31
  point.build_value(value: cat)
32
32
  end
33
33
  end
@@ -35,7 +35,7 @@ module Goldendocx
35
35
  def values=(values)
36
36
  value_axis.values.build_count(count: values.size)
37
37
  values.each_with_index do |val, index|
38
- point = value_axis.values.build_point(index: index)
38
+ point = value_axis.values.build_point(index:)
39
39
  point.build_value(value: val)
40
40
  end
41
41
  end
@@ -21,6 +21,6 @@ end
21
21
 
22
22
  require 'goldendocx/charts/properties'
23
23
 
24
- Dir.glob(File.join(File.dirname(__FILE__), 'charts', '*.rb').to_s).sort.each do |file|
24
+ Dir.glob(File.join(File.dirname(__FILE__), 'charts', '*.rb').to_s).each do |file|
25
25
  require file
26
26
  end
@@ -3,8 +3,8 @@
3
3
  module Goldendocx
4
4
  module Components
5
5
  class BarChart < Chart
6
- def initialize(chart_id, relationship_id, **attributes)
7
- super(chart_id, relationship_id, **attributes)
6
+ def initialize(chart_id, relationship_id, attributes = {})
7
+ super(chart_id, relationship_id, attributes)
8
8
 
9
9
  build_chart.plot_area.build_bar_chart
10
10
  end
@@ -18,21 +18,21 @@ module Goldendocx
18
18
  attr_accessor :name
19
19
  attr_reader :id, :series
20
20
 
21
- def initialize(chart_id, relationship_id, **attributes)
21
+ def initialize(chart_id, relationship_id, attributes = {})
22
22
  @id = chart_id
23
23
  @series = []
24
24
 
25
25
  @paragraph = Goldendocx::Components::Paragraph.new
26
26
  inline_drawing = @paragraph.build_run.build_drawing.build_inline
27
- inline_drawing.build_non_visual_property(relationship_id: relationship_id)
27
+ inline_drawing.build_non_visual_property(relationship_id:)
28
28
  inline_drawing.build_extents(width: attributes[:width], height: attributes[:height])
29
- inline_drawing.build_graphic.build_data.build_chart(relationship_id: relationship_id)
29
+ inline_drawing.build_graphic.build_data.build_chart(relationship_id:)
30
30
  end
31
31
 
32
32
  def add_series(name, categories, values)
33
33
  ser_id = series.size + 1
34
- the_chart.build_series(categories: categories, values: values, id: ser_id, name: name)
35
- ser = Goldendocx::Charts::Series.new(categories: categories, values: values, id: ser_id, name: name)
34
+ the_chart.build_series(categories:, values:, id: ser_id, name:)
35
+ ser = Goldendocx::Charts::Series.new(categories:, values:, id: ser_id, name:)
36
36
  series << ser
37
37
  ser
38
38
  end
@@ -46,7 +46,7 @@ module Goldendocx
46
46
  end
47
47
 
48
48
  def write_to(zos)
49
- entry_name = format(Goldendocx::Charts::RELATIONSHIP_NAME_PATTERN, id: id)
49
+ entry_name = format(Goldendocx::Charts::RELATIONSHIP_NAME_PATTERN, id:)
50
50
  zos.put_next_entry "word/#{entry_name}"
51
51
  zos.write to_document_xml
52
52
  end
@@ -3,8 +3,8 @@
3
3
  module Goldendocx
4
4
  module Components
5
5
  class ColumnChart < Chart
6
- def initialize(chart_id, relationship_id, **attributes)
7
- super(chart_id, relationship_id, **attributes)
6
+ def initialize(chart_id, relationship_id, attributes = {})
7
+ super(chart_id, relationship_id, attributes)
8
8
 
9
9
  build_chart.plot_area.build_column_chart
10
10
  end
@@ -3,8 +3,8 @@
3
3
  module Goldendocx
4
4
  module Components
5
5
  class DoughnutChart < Chart
6
- def initialize(chart_id, relationship_id, **attributes)
7
- super(chart_id, relationship_id, **attributes)
6
+ def initialize(chart_id, relationship_id, attributes = {})
7
+ super(chart_id, relationship_id, attributes)
8
8
 
9
9
  build_chart.plot_area.build_doughnut_chart
10
10
  end
@@ -3,8 +3,8 @@
3
3
  module Goldendocx
4
4
  module Components
5
5
  class LineChart < Chart
6
- def initialize(chart_id, relationship_id, **attributes)
7
- super(chart_id, relationship_id, **attributes)
6
+ def initialize(chart_id, relationship_id, attributes = {})
7
+ super(chart_id, relationship_id, attributes)
8
8
 
9
9
  build_chart.plot_area.build_line_chart
10
10
  end
@@ -7,6 +7,6 @@ module Goldendocx
7
7
  end
8
8
  end
9
9
 
10
- Dir.glob(File.join(File.dirname(__FILE__), 'properties', '*.rb').to_s).sort.each do |file|
10
+ Dir.glob(File.join(File.dirname(__FILE__), 'properties', '*.rb').to_s).each do |file|
11
11
  require file
12
12
  end
@@ -29,8 +29,8 @@ module Goldendocx
29
29
  end
30
30
 
31
31
  def add_header(title, width: nil)
32
- header.build_cell(content: title, width: width)
33
- grid_property.build_grid_column(width: width) if width
32
+ header.build_cell(content: title, width:)
33
+ grid_property.build_grid_column(width:) if width
34
34
  header
35
35
  end
36
36
 
@@ -11,6 +11,6 @@ end
11
11
  require 'goldendocx/components/properties'
12
12
  require 'goldendocx/components/chart'
13
13
 
14
- Dir.glob(File.join(File.dirname(__FILE__), 'components', '*.rb').to_s).sort.each do |file|
14
+ Dir.glob(File.join(File.dirname(__FILE__), 'components', '*.rb').to_s).each do |file|
15
15
  require file
16
16
  end
@@ -25,8 +25,8 @@ module Goldendocx
25
25
  end
26
26
  end
27
27
 
28
- def to_document_xml(&block)
29
- Goldendocx.xml_serializer.build_document_xml(tag_name, concerned_namespaces, ignorable_namespaces) { |xml| build_element(xml, &block) }
28
+ def to_document_xml(&)
29
+ Goldendocx.xml_serializer.build_document_xml(tag_name, concerned_namespaces, ignorable_namespaces) { |xml| build_element(xml, &) }
30
30
  end
31
31
  end
32
32
  end
@@ -49,7 +49,7 @@ module Goldendocx
49
49
  end
50
50
 
51
51
  def create_text(text, options = {})
52
- text = build_text(text: text, **options.slice(:align, :color, :bold))
52
+ text = build_text(text:, **options.slice(:align, :color, :bold))
53
53
 
54
54
  components << text
55
55
 
@@ -66,7 +66,7 @@ module Goldendocx
66
66
  end
67
67
 
68
68
  def create_image(relationship_id, options)
69
- image = build_image(relationship_id: relationship_id, width: options[:width], height: options[:height])
69
+ image = build_image(relationship_id:, width: options[:width], height: options[:height])
70
70
 
71
71
  components << image
72
72
 
@@ -74,7 +74,7 @@ module Goldendocx
74
74
  end
75
75
 
76
76
  def create_embed_image(relationship_id, options)
77
- Goldendocx::Components::Image.new(relationship_id: relationship_id, width: options[:width], height: options[:height])
77
+ Goldendocx::Components::Image.new(relationship_id:, width: options[:width], height: options[:height])
78
78
  end
79
79
 
80
80
  def ensure_chart_type(chart_type)
@@ -7,6 +7,6 @@ module Goldendocx
7
7
  end
8
8
  end
9
9
 
10
- Dir.glob(File.join(File.dirname(__FILE__), 'properties', '*.rb').to_s).sort.each do |file|
10
+ Dir.glob(File.join(File.dirname(__FILE__), 'properties', '*.rb').to_s).each do |file|
11
11
  require file
12
12
  end
@@ -5,6 +5,6 @@ module Goldendocx
5
5
  end
6
6
  end
7
7
 
8
- Dir.glob(File.join(File.dirname(__FILE__), 'documents', '*.rb').to_s).sort.each do |file|
8
+ Dir.glob(File.join(File.dirname(__FILE__), 'documents', '*.rb').to_s).each do |file|
9
9
  require file
10
10
  end
@@ -89,9 +89,9 @@ module Goldendocx
89
89
 
90
90
  def build_default
91
91
  associations.each do |association, options|
92
- association_class = options[:class_name].constantize
92
+ association_class = options.class_name.constantize
93
93
  instance_variable_set("@#{association}", association_class.new)
94
- add_relationship association_class::TYPE, association_class::XML_PATH unless options[:isolate]
94
+ add_relationship association_class::TYPE, association_class::XML_PATH unless options.isolate
95
95
  end
96
96
 
97
97
  content_types.add_override "/#{Goldendocx::Parts::App::XML_PATH}", Goldendocx::Parts::App::CONTENT_TYPE
@@ -64,12 +64,12 @@ module Goldendocx
64
64
  @tag_name ||= [namespace, tag].compact.join(':')
65
65
  end
66
66
 
67
- def to_element(**context, &block)
68
- Goldendocx.xml_serializer.build_element(tag_name, **context) { |xml| build_element(xml, &block) }
67
+ def to_element(**context, &)
68
+ Goldendocx.xml_serializer.build_element(tag_name, **context) { |xml| build_element(xml, &) }
69
69
  end
70
70
 
71
- def to_xml(&block)
72
- Goldendocx.xml_serializer.build_xml(tag_name) { |xml| build_element(xml, &block) }
71
+ def to_xml(&)
72
+ Goldendocx.xml_serializer.build_xml(tag_name) { |xml| build_element(xml, &) }
73
73
  end
74
74
 
75
75
  def build_element(xml)
@@ -11,6 +11,8 @@ module Goldendocx
11
11
  delegate :add_relationship, to: :relationships
12
12
  end
13
13
 
14
+ Options = Data.define(:class_name, :isolate)
15
+
14
16
  class_methods do
15
17
  def relationships_at(xml_path)
16
18
  self.relationships_xml_path = xml_path
@@ -18,7 +20,7 @@ module Goldendocx
18
20
 
19
21
  def associate(name, class_name:, isolate: false)
20
22
  named = name.to_s
21
- associations[named] = { class_name: class_name, isolate: isolate }
23
+ associations[named] = Options.new(class_name:, isolate:)
22
24
 
23
25
  define_method named do
24
26
  return instance_variable_get("@#{name}") if instance_variable_defined?("@#{name}")
@@ -31,7 +33,7 @@ module Goldendocx
31
33
 
32
34
  def read_associations(docx_file)
33
35
  associations.each do |association, options|
34
- association_class = options[:class_name].constantize
36
+ association_class = options.class_name.constantize
35
37
  association_document_xml = docx_file.read(association_class::XML_PATH)
36
38
  instance_variable_set("@#{association}", association_class.parse(association_document_xml))
37
39
  end
@@ -18,7 +18,7 @@ module Goldendocx
18
18
  def embeds_one(name, class_name:, auto_build: false)
19
19
  warning_naming_suggestion(__method__, name, name.to_s.singularize)
20
20
 
21
- options = { class_name: class_name, multiple: false, auto_build: auto_build }
21
+ options = { class_name:, multiple: false, auto_build: }
22
22
  self.children = children.merge(name => options)
23
23
 
24
24
  create_children_getter(name)
@@ -29,7 +29,7 @@ module Goldendocx
29
29
  def embeds_many(name, class_name:, uniqueness: false)
30
30
  warning_naming_suggestion(__method__, name, name.to_s.pluralize)
31
31
 
32
- options = { class_name: class_name, multiple: true, uniqueness: uniqueness }
32
+ options = { class_name:, multiple: true, uniqueness: }
33
33
  self.children = children.merge(name => options)
34
34
 
35
35
  create_children_getter(name)
@@ -31,7 +31,7 @@ module Goldendocx
31
31
  return unless relationship_id
32
32
 
33
33
  non_visual_picture.non_visual_drawing.assign_attributes(
34
- relationship_id: relationship_id,
34
+ relationship_id:,
35
35
  name: "#{relationship_id}.png"
36
36
  )
37
37
  picture_fill.blip.relationship_id = relationship_id
@@ -7,6 +7,6 @@ module Goldendocx
7
7
  end
8
8
  end
9
9
 
10
- Dir.glob(File.join(File.dirname(__FILE__), 'properties', '*.rb').to_s).sort.each do |file|
10
+ Dir.glob(File.join(File.dirname(__FILE__), 'properties', '*.rb').to_s).each do |file|
11
11
  require file
12
12
  end
@@ -7,6 +7,6 @@ end
7
7
 
8
8
  require 'goldendocx/images/properties'
9
9
 
10
- Dir.glob(File.join(File.dirname(__FILE__), 'images', '*.rb').to_s).sort.each do |file|
10
+ Dir.glob(File.join(File.dirname(__FILE__), 'images', '*.rb').to_s).each do |file|
11
11
  require file
12
12
  end
@@ -23,7 +23,7 @@ module Goldendocx
23
23
 
24
24
  def add_relationship(type, target)
25
25
  relationship_id = "rId#{relationships.size + 1}"
26
- build_relationship(id: relationship_id, type: type, target: target)
26
+ build_relationship(id: relationship_id, type:, target:)
27
27
  relationship_id
28
28
  end
29
29
  end
@@ -5,6 +5,6 @@ module Goldendocx
5
5
  end
6
6
  end
7
7
 
8
- Dir.glob(File.join(File.dirname(__FILE__), 'models', '*.rb').to_s).sort.each do |file|
8
+ Dir.glob(File.join(File.dirname(__FILE__), 'models', '*.rb').to_s).each do |file|
9
9
  require file
10
10
  end
@@ -24,7 +24,7 @@ module Goldendocx
24
24
 
25
25
  def initialize
26
26
  REQUIRED_DEFAULTS.map do |extension, content_type|
27
- build_defaults(extension: extension, content_type: content_type)
27
+ build_defaults(extension:, content_type:)
28
28
  end
29
29
  end
30
30
 
@@ -36,13 +36,13 @@ module Goldendocx
36
36
  def add_default(extension, content_type)
37
37
  return if defaults.any? { |default| extension == default.extension && content_type == default.content_type }
38
38
 
39
- build_defaults(extension: extension, content_type: content_type)
39
+ build_defaults(extension:, content_type:)
40
40
  end
41
41
 
42
42
  def add_override(part_name, content_type)
43
43
  return if overrides.any? { |override| part_name == override.part_name && content_type == override.content_type }
44
44
 
45
- build_override(part_name: part_name, content_type: content_type)
45
+ build_override(part_name:, content_type:)
46
46
  end
47
47
  end
48
48
  end
@@ -32,9 +32,9 @@ module Goldendocx
32
32
 
33
33
  def initialize
34
34
  associations.each do |association, options|
35
- association_class = options[:class_name].constantize
35
+ association_class = options.class_name.constantize
36
36
  instance_variable_set("@#{association}", association_class.new)
37
- add_relationship association_class::TYPE, association_class::XML_PATH.gsub(XML_PATH, '') unless options[:isolate]
37
+ add_relationship association_class::TYPE, association_class::XML_PATH.gsub(XML_PATH, '') unless options.isolate
38
38
  end
39
39
 
40
40
  @medias = []
@@ -105,7 +105,7 @@ module Goldendocx
105
105
  format(Goldendocx::Charts::RELATIONSHIP_NAME_PATTERN, id: chart_id)
106
106
  )
107
107
 
108
- document.body.create_chart(chart_type, chart_id, relationship_id, width: width, height: height)
108
+ document.body.create_chart(chart_type, chart_id, relationship_id, width:, height:)
109
109
  end
110
110
 
111
111
  def add_style(fragment)
@@ -7,7 +7,7 @@ module Goldendocx
7
7
  BASE64_PNG_PATTERN = %r{
8
8
  ^data:image/png;base64,
9
9
  (?<data>(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?)$
10
- }x.freeze
10
+ }x
11
11
 
12
12
  def initialize(name, data)
13
13
  @name = name
@@ -7,6 +7,6 @@ module Goldendocx
7
7
  end
8
8
  end
9
9
 
10
- Dir.glob(File.join(File.dirname(__FILE__), 'properties', '*.rb').to_s).sort.each do |file|
10
+ Dir.glob(File.join(File.dirname(__FILE__), 'properties', '*.rb').to_s).each do |file|
11
11
  require file
12
12
  end
@@ -5,6 +5,6 @@ module Goldendocx
5
5
  end
6
6
  end
7
7
 
8
- Dir.glob(File.join(File.dirname(__FILE__), 'parts', '*.rb').to_s).sort.each do |file|
8
+ Dir.glob(File.join(File.dirname(__FILE__), 'parts', '*.rb').to_s).each do |file|
9
9
  require file
10
10
  end
@@ -9,7 +9,7 @@ module Goldendocx
9
9
  end
10
10
 
11
11
  def width=(width, type: :dxa)
12
- property.width.assign_attributes(width: width, type: type)
12
+ property.width.assign_attributes(width:, type:)
13
13
  end
14
14
  end
15
15
  end
@@ -7,6 +7,6 @@ module Goldendocx
7
7
  end
8
8
  end
9
9
 
10
- Dir.glob(File.join(File.dirname(__FILE__), 'properties', '*.rb').to_s).sort.each do |file|
10
+ Dir.glob(File.join(File.dirname(__FILE__), 'properties', '*.rb').to_s).each do |file|
11
11
  require file
12
12
  end
@@ -14,6 +14,6 @@ require 'goldendocx/tables/properties'
14
14
  require 'goldendocx/tables/row'
15
15
  require 'goldendocx/tables/cell'
16
16
 
17
- Dir.glob(File.join(File.dirname(__FILE__), 'tables', '*.rb').to_s).sort.each do |file|
17
+ Dir.glob(File.join(File.dirname(__FILE__), 'tables', '*.rb').to_s).each do |file|
18
18
  require file
19
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Goldendocx
4
- VERSION = '0.2.3'
4
+ VERSION = '0.3.0'
5
5
  end
@@ -32,12 +32,12 @@ module Goldendocx
32
32
  node.xpath(search_paths.join('/'), namespaces)
33
33
  end
34
34
 
35
- def build_xml(tag, &block)
36
- CGI.unescapeHTML build_element(tag, &block).to_xml(indent: 0, save_with: DEFAULT_BUILD_OPTIONS).delete("\n")
35
+ def build_xml(tag, &)
36
+ CGI.unescapeHTML build_element(tag, &).to_xml(indent: 0, save_with: DEFAULT_BUILD_OPTIONS).delete("\n")
37
37
  end
38
38
 
39
- def build_document_xml(tag, namespaces = [], ignore_namespaces = [], &block)
40
- CGI.unescapeHTML build_document(tag, namespaces, ignore_namespaces, &block).to_xml(indent: 0).delete("\n")
39
+ def build_document_xml(tag, namespaces = [], ignore_namespaces = [], &)
40
+ CGI.unescapeHTML build_document(tag, namespaces, ignore_namespaces, &).to_xml(indent: 0).delete("\n")
41
41
  end
42
42
 
43
43
  def build_document(tag, namespaces = [], ignore_namespaces = [])
@@ -4,7 +4,7 @@ require 'extensions/ox_extensions'
4
4
 
5
5
  module Goldendocx
6
6
  module XmlSerializers
7
- class Ox
7
+ module Ox
8
8
  class << self
9
9
  def parse(xml, paths = [])
10
10
  xml = ::Ox.parse(xml)
@@ -18,13 +18,13 @@ module Goldendocx
18
18
  node.locate(paths.join('/'))
19
19
  end
20
20
 
21
- def build_xml(tag, &block)
22
- xml = build_element(tag, &block)
21
+ def build_xml(tag, &)
22
+ xml = build_element(tag, &)
23
23
  ::Ox.dump(xml, indent: -1, with_xml: true, encoding: 'UTF-8')
24
24
  end
25
25
 
26
- def build_document_xml(tag, namespaces = [], ignore_namespaces = [], &block)
27
- xml = build_document(tag, namespaces, ignore_namespaces, &block)
26
+ def build_document_xml(tag, namespaces = [], ignore_namespaces = [], &)
27
+ xml = build_document(tag, namespaces, ignore_namespaces, &)
28
28
  ::Ox.dump(xml, indent: -1, with_xml: true)
29
29
  end
30
30
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goldendocx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - WangYuechen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-07 00:00:00.000000000 Z
11
+ date: 2023-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -187,6 +187,7 @@ extra_rdoc_files: []
187
187
  files:
188
188
  - ".rspec"
189
189
  - ".rubocop.yml"
190
+ - ".ruby-version"
190
191
  - CHANGELOG.md
191
192
  - Gemfile
192
193
  - Gemfile.lock
@@ -377,14 +378,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
377
378
  requirements:
378
379
  - - ">="
379
380
  - !ruby/object:Gem::Version
380
- version: 2.7.0
381
+ version: '3.2'
381
382
  required_rubygems_version: !ruby/object:Gem::Requirement
382
383
  requirements:
383
384
  - - ">="
384
385
  - !ruby/object:Gem::Version
385
386
  version: '0'
386
387
  requirements: []
387
- rubygems_version: 3.3.23
388
+ rubygems_version: 3.4.1
388
389
  signing_key:
389
390
  specification_version: 4
390
391
  summary: The Ruby API for Microsoft Word