xlsxrb 0.1.5 → 0.1.6

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 (97) hide show
  1. checksums.yaml +4 -4
  2. data/.gem_rbs_collection/nokogiri/1.11/.rbs_meta.yaml +9 -0
  3. data/.gem_rbs_collection/nokogiri/1.11/nokogiri.rbs +2332 -0
  4. data/.gem_rbs_collection/nokogiri/1.11/patch.rbs +4 -0
  5. data/.gem_rbs_collection/rubyzip/3.2/.rbs_meta.yaml +9 -0
  6. data/.gem_rbs_collection/rubyzip/3.2/manifest.yaml +8 -0
  7. data/.gem_rbs_collection/rubyzip/3.2/zip/central_directory.rbs +42 -0
  8. data/.gem_rbs_collection/rubyzip/3.2/zip/compressor.rbs +5 -0
  9. data/.gem_rbs_collection/rubyzip/3.2/zip/constants.rbs +47 -0
  10. data/.gem_rbs_collection/rubyzip/3.2/zip/crypto/aes_encryption.rbs +30 -0
  11. data/.gem_rbs_collection/rubyzip/3.2/zip/crypto/decrypted_io.rbs +9 -0
  12. data/.gem_rbs_collection/rubyzip/3.2/zip/crypto/encryption.rbs +7 -0
  13. data/.gem_rbs_collection/rubyzip/3.2/zip/crypto/null_encryption.rbs +19 -0
  14. data/.gem_rbs_collection/rubyzip/3.2/zip/crypto/traditional_encryption.rbs +31 -0
  15. data/.gem_rbs_collection/rubyzip/3.2/zip/decompressor.rbs +18 -0
  16. data/.gem_rbs_collection/rubyzip/3.2/zip/deflater.rbs +12 -0
  17. data/.gem_rbs_collection/rubyzip/3.2/zip/dirtyable.rbs +11 -0
  18. data/.gem_rbs_collection/rubyzip/3.2/zip/dos_time.rbs +13 -0
  19. data/.gem_rbs_collection/rubyzip/3.2/zip/entry.rbs +95 -0
  20. data/.gem_rbs_collection/rubyzip/3.2/zip/entry_set.rbs +31 -0
  21. data/.gem_rbs_collection/rubyzip/3.2/zip/errors.rbs +58 -0
  22. data/.gem_rbs_collection/rubyzip/3.2/zip/extra_field/aes.rbs +24 -0
  23. data/.gem_rbs_collection/rubyzip/3.2/zip/extra_field/generic.rbs +17 -0
  24. data/.gem_rbs_collection/rubyzip/3.2/zip/extra_field/ntfs.rbs +23 -0
  25. data/.gem_rbs_collection/rubyzip/3.2/zip/extra_field/old_unix.rbs +22 -0
  26. data/.gem_rbs_collection/rubyzip/3.2/zip/extra_field/universal_time.rbs +30 -0
  27. data/.gem_rbs_collection/rubyzip/3.2/zip/extra_field/unix.rbs +20 -0
  28. data/.gem_rbs_collection/rubyzip/3.2/zip/extra_field/unknown.rbs +15 -0
  29. data/.gem_rbs_collection/rubyzip/3.2/zip/extra_field/zip64.rbs +26 -0
  30. data/.gem_rbs_collection/rubyzip/3.2/zip/extra_field.rbs +21 -0
  31. data/.gem_rbs_collection/rubyzip/3.2/zip/file.rbs +131 -0
  32. data/.gem_rbs_collection/rubyzip/3.2/zip/file_split.rbs +14 -0
  33. data/.gem_rbs_collection/rubyzip/3.2/zip/filesystem/dir.rbs +33 -0
  34. data/.gem_rbs_collection/rubyzip/3.2/zip/filesystem/directory_iterator.rbs +21 -0
  35. data/.gem_rbs_collection/rubyzip/3.2/zip/filesystem/file.rbs +63 -0
  36. data/.gem_rbs_collection/rubyzip/3.2/zip/filesystem/file_stat.rbs +55 -0
  37. data/.gem_rbs_collection/rubyzip/3.2/zip/filesystem/zip_file_name_mapper.rbs +35 -0
  38. data/.gem_rbs_collection/rubyzip/3.2/zip/filesystem.rbs +7 -0
  39. data/.gem_rbs_collection/rubyzip/3.2/zip/inflater.rbs +10 -0
  40. data/.gem_rbs_collection/rubyzip/3.2/zip/input_stream.rbs +22 -0
  41. data/.gem_rbs_collection/rubyzip/3.2/zip/ioextras/abstract_input_stream.rbs +29 -0
  42. data/.gem_rbs_collection/rubyzip/3.2/zip/ioextras/abstract_output_stream.rbs +17 -0
  43. data/.gem_rbs_collection/rubyzip/3.2/zip/ioextras.rbs +13 -0
  44. data/.gem_rbs_collection/rubyzip/3.2/zip/null_compressor.rbs +10 -0
  45. data/.gem_rbs_collection/rubyzip/3.2/zip/null_decompressor.rbs +8 -0
  46. data/.gem_rbs_collection/rubyzip/3.2/zip/null_input_stream.rbs +6 -0
  47. data/.gem_rbs_collection/rubyzip/3.2/zip/output_stream.rbs +30 -0
  48. data/.gem_rbs_collection/rubyzip/3.2/zip/pass_thru_compressor.rbs +10 -0
  49. data/.gem_rbs_collection/rubyzip/3.2/zip/pass_thru_decompressor.rbs +10 -0
  50. data/.gem_rbs_collection/rubyzip/3.2/zip/streamable_directory.rbs +5 -0
  51. data/.gem_rbs_collection/rubyzip/3.2/zip/streamable_stream.rbs +15 -0
  52. data/.gem_rbs_collection/rubyzip/3.2/zip/version.rbs +3 -0
  53. data/.gem_rbs_collection/rubyzip/3.2/zip.rbs +40 -0
  54. data/CHANGELOG.md +18 -0
  55. data/README.md +39 -32
  56. data/Rakefile +2 -1
  57. data/Steepfile +0 -2
  58. data/benchmark.rb +376 -0
  59. data/docs/ARCHITECTURE.md +12 -5
  60. data/docs/wasm/ruby.wasm +0 -0
  61. data/lib/xlsxrb/elements/cell.rb +39 -7
  62. data/lib/xlsxrb/elements/row.rb +17 -4
  63. data/lib/xlsxrb/elements/types.rb +4 -0
  64. data/lib/xlsxrb/ooxml/shared_strings_parser.rb +104 -40
  65. data/lib/xlsxrb/ooxml/worksheet_parser.rb +144 -23
  66. data/lib/xlsxrb/ooxml/worksheet_writer.rb +160 -145
  67. data/lib/xlsxrb/ooxml/xml_builder.rb +16 -10
  68. data/lib/xlsxrb/ooxml/zip_reader.rb +104 -18
  69. data/lib/xlsxrb/ooxml/zip_writer.rb +63 -25
  70. data/lib/xlsxrb/style_builder.rb +158 -30
  71. data/lib/xlsxrb/version.rb +1 -1
  72. data/lib/xlsxrb.rb +443 -236
  73. data/rbs_collection.lock.yaml +28 -0
  74. data/sig/generated/xlsxrb/elements/cell.rbs +30 -0
  75. data/sig/generated/xlsxrb/elements/column.rbs +30 -0
  76. data/sig/generated/xlsxrb/elements/row.rbs +32 -0
  77. data/sig/generated/xlsxrb/elements/types.rbs +74 -0
  78. data/sig/generated/xlsxrb/elements/workbook.rbs +25 -0
  79. data/sig/generated/xlsxrb/elements/worksheet.rbs +27 -0
  80. data/sig/generated/xlsxrb/ooxml/reader.rbs +1412 -0
  81. data/sig/generated/xlsxrb/ooxml/shared_strings_parser.rbs +21 -0
  82. data/sig/generated/xlsxrb/ooxml/styles_parser.rbs +44 -0
  83. data/sig/generated/xlsxrb/ooxml/utils.rbs +40 -0
  84. data/sig/generated/xlsxrb/ooxml/workbook_parser.rbs +46 -0
  85. data/sig/generated/xlsxrb/ooxml/workbook_writer.rbs +66 -0
  86. data/sig/generated/xlsxrb/ooxml/worksheet_parser.rbs +67 -0
  87. data/sig/generated/xlsxrb/ooxml/worksheet_writer.rbs +92 -0
  88. data/sig/generated/xlsxrb/ooxml/writer.rbs +880 -0
  89. data/sig/generated/xlsxrb/ooxml/xml_builder.rbs +45 -0
  90. data/sig/generated/xlsxrb/ooxml/xml_parser.rbs +30 -0
  91. data/sig/generated/xlsxrb/ooxml/zip_generator.rbs +38 -0
  92. data/sig/generated/xlsxrb/ooxml/zip_reader.rbs +45 -0
  93. data/sig/generated/xlsxrb/ooxml/zip_writer.rbs +45 -0
  94. data/sig/generated/xlsxrb/style_builder.rbs +212 -50
  95. data/sig/generated/xlsxrb.rbs +1276 -0
  96. data/sig/rexml.rbs +4 -0
  97. metadata +76 -1
@@ -5,6 +5,7 @@
5
5
  module Xlsxrb
6
6
  # Helper class for building cell styles with a fluent DSL.
7
7
  # Encapsulates font, fill, border, alignment, and number format properties.
8
+ # @api public
8
9
  class StyleBuilder
9
10
  COLORS = {
10
11
  black: "FF000000",
@@ -29,7 +30,7 @@ module Xlsxrb
29
30
  color.to_s
30
31
  end
31
32
 
32
- # : (?String? name) -> void
33
+ #: (?String? name) -> void
33
34
  def initialize(name = nil)
34
35
  @name = name
35
36
  @font_props = {}
@@ -43,7 +44,12 @@ module Xlsxrb
43
44
 
44
45
  # Applies option-style definitions so callers can use add_style(name, **opts)
45
46
  # as an alternative to block-based fluent chaining.
46
- # : (**untyped opts) -> self
47
+ # Applies option-style definitions so callers can use add_style(name, **opts)
48
+ # as an alternative to block-based fluent chaining.
49
+ # @param opts [Hash] The styling options.
50
+ # @return [self]
51
+ # @api public
52
+ #: (**untyped) -> self
47
53
  def apply_options!(**opts)
48
54
  if opts.key?(:font)
49
55
  font_opts = opts[:font] || {}
@@ -129,7 +135,11 @@ module Xlsxrb
129
135
 
130
136
  # --- Font Properties ---
131
137
 
132
- # : (**untyped opts) -> self
138
+ # Configures multiple font properties at once.
139
+ # @param opts [Hash] The font properties.
140
+ # @return [self]
141
+ # @api public
142
+ #: (**untyped) -> self
133
143
  def font(**opts)
134
144
  bold(opts[:bold]) if opts.key?(:bold)
135
145
  italic(opts[:italic]) if opts.key?(:italic)
@@ -143,49 +153,81 @@ module Xlsxrb
143
153
  end
144
154
 
145
155
  # rubocop:disable Style/OptionalBooleanParameter
146
- # : (?bool value) -> self
156
+ # Sets the font to bold.
157
+ # @param value [Boolean] Whether to apply bold.
158
+ # @return [self]
159
+ # @api public
160
+ #: (?bool) -> self
147
161
  def bold(value = true)
148
162
  @font_props[:bold] = value
149
163
  self
150
164
  end
151
165
 
152
- # : (?bool value) -> self
166
+ # Sets the font to italic.
167
+ # @param value [Boolean] Whether to apply italic.
168
+ # @return [self]
169
+ # @api public
170
+ #: (?bool) -> self
153
171
  def italic(value = true)
154
172
  @font_props[:italic] = value
155
173
  self
156
174
  end
157
175
 
158
- # : (Numeric size_value) -> self
176
+ # Sets the font size.
177
+ # @param size_value [Numeric] The size.
178
+ # @return [self]
179
+ # @api public
180
+ #: (Numeric) -> self
159
181
  def size(size_value)
160
182
  @font_props[:sz] = size_value.to_i
161
183
  self
162
184
  end
163
185
 
164
- # : (String name) -> self
186
+ # Sets the font name.
187
+ # @param name [String] The font name.
188
+ # @return [self]
189
+ # @api public
190
+ #: (String) -> self
165
191
  def font_name(name)
166
192
  @font_props[:name] = name
167
193
  self
168
194
  end
169
195
 
170
- # : (String | Symbol color) -> self
196
+ # Sets the font color.
197
+ # @param color [String, Symbol] The color.
198
+ # @return [self]
199
+ # @api public
200
+ #: (String | Symbol) -> self
171
201
  def font_color(color)
172
202
  @font_props[:color] = resolve_color(color)
173
203
  self
174
204
  end
175
205
 
176
- # : (?String val) -> self
206
+ # Sets the font underline style.
207
+ # @param val [String] The underline style (e.g., 'single').
208
+ # @return [self]
209
+ # @api public
210
+ #: (?String) -> self
177
211
  def underline(val = "single")
178
212
  @font_props[:underline] = val
179
213
  self
180
214
  end
181
215
 
182
- # : (?bool value) -> self
216
+ # Sets the font strikethrough.
217
+ # @param value [Boolean] Whether to apply strike.
218
+ # @return [self]
219
+ # @api public
220
+ #: (?bool) -> self
183
221
  def strike(value = true)
184
222
  @font_props[:strike] = value
185
223
  self
186
224
  end
187
225
 
188
- # : (String value) -> self
226
+ # Sets the vertical alignment of the font.
227
+ # @param value [String] The alignment value.
228
+ # @return [self]
229
+ # @api public
230
+ #: (String) -> self
189
231
  def vert_align(value)
190
232
  @font_props[:vert_align] = value
191
233
  self
@@ -194,7 +236,19 @@ module Xlsxrb
194
236
 
195
237
  # --- Fill Properties ---
196
238
 
197
- # : (String | Symbol pattern, ?fg_color: String | Symbol | nil, ?bg_color: String | Symbol | nil) -> self
239
+ # Sets the fill pattern.
240
+ # @param pattern [String, Symbol] The pattern type.
241
+ # @param fg_color [String, Symbol, nil] The foreground color.
242
+ # @param bg_color [String, Symbol, nil] The background color.
243
+ # @return [self]
244
+ # @api public
245
+ # Configures fill properties.
246
+ # @param pattern [String, Symbol] The pattern type.
247
+ # @param fg_color [String, Symbol, nil] The foreground color.
248
+ # @param bg_color [String, Symbol, nil] The background color.
249
+ # @return [self]
250
+ # @api public
251
+ #: (String | Symbol pattern, ?fg_color: String | Symbol | nil, ?bg_color: String | Symbol | nil) -> self
198
252
  def fill_pattern(pattern, fg_color: nil, bg_color: nil)
199
253
  @fill_props[:pattern] = pattern
200
254
  @fill_props[:fg_color] = fg_color if fg_color
@@ -202,19 +256,29 @@ module Xlsxrb
202
256
  self
203
257
  end
204
258
 
205
- # : (String | Symbol color) -> self
259
+ # Sets a solid fill color.
260
+ # @param color [String, Symbol] The color.
261
+ # @return [self]
262
+ # @api public
263
+ #: (String | Symbol) -> self
206
264
  def fill_color(color)
207
265
  @fill_props[:pattern] = "solid"
208
266
  @fill_props[:fg_color] = resolve_color(color)
209
267
  self
210
268
  end
211
269
 
212
- # : (?pattern: String | Symbol, ?fg_color: String | Symbol | nil, ?bg_color: String | Symbol | nil) -> self
270
+ #: (?pattern: String | Symbol, ?fg_color: String | Symbol | nil, ?bg_color: String | Symbol | nil) -> self
213
271
  def fill(pattern: "solid", fg_color: nil, bg_color: nil)
214
272
  fill_pattern(pattern, fg_color: resolve_color(fg_color), bg_color: resolve_color(bg_color))
215
273
  end
216
274
 
217
- # : (type: String, ?degree: Numeric | nil, ?stops: Array[untyped]) -> self
275
+ # Sets a gradient fill.
276
+ # @param type [String] The gradient type.
277
+ # @param degree [Numeric, nil] The degree.
278
+ # @param stops [Array] The gradient stops.
279
+ # @return [self]
280
+ # @api public
281
+ #: (type: String, ?degree: Numeric | nil, ?stops: Array[untyped]) -> self
218
282
  def fill_gradient(type:, degree: nil, stops: [])
219
283
  @fill_props[:gradient] = {
220
284
  type: type,
@@ -226,7 +290,11 @@ module Xlsxrb
226
290
 
227
291
  # --- Border Properties ---
228
292
 
229
- # : (**untyped opts) -> self
293
+ # Configures multiple border properties.
294
+ # @param opts [Hash] Border options.
295
+ # @return [self]
296
+ # @api public
297
+ #: (**untyped) -> self
230
298
  def border(**opts)
231
299
  border_all(**opts[:all]) if opts.key?(:all) && opts[:all]
232
300
  border_left(**opts[:left]) if opts.key?(:left) && opts[:left]
@@ -236,7 +304,12 @@ module Xlsxrb
236
304
  self
237
305
  end
238
306
 
239
- # : (?style: String | Symbol, ?color: String | Symbol | nil) -> self
307
+ # Sets all borders.
308
+ # @param style [String, Symbol] The border style.
309
+ # @param color [String, Symbol, nil] The color.
310
+ # @return [self]
311
+ # @api public
312
+ #: (?style: String | Symbol, ?color: String | Symbol | nil) -> self
240
313
  def border_all(style: "thin", color: nil)
241
314
  color_opt = color ? { color: resolve_color(color) } : {}
242
315
  @border_props[:left] = { style: style, **color_opt }
@@ -246,32 +319,59 @@ module Xlsxrb
246
319
  self
247
320
  end
248
321
 
249
- # : (?style: String | Symbol, ?color: String | Symbol | nil) -> self
322
+ # Sets the left border.
323
+ # @param style [String, Symbol] The border style.
324
+ # @param color [String, Symbol, nil] The color.
325
+ # @return [self]
326
+ # @api public
327
+ #: (?style: String | Symbol, ?color: String | Symbol | nil) -> self
250
328
  def border_left(style: "thin", color: nil)
251
329
  @border_props[:left] = { style: style, color: resolve_color(color) }.compact
252
330
  self
253
331
  end
254
332
 
255
- # : (?style: String | Symbol, ?color: String | Symbol | nil) -> self
333
+ # Sets the right border.
334
+ # @param style [String, Symbol] The border style.
335
+ # @param color [String, Symbol, nil] The color.
336
+ # @return [self]
337
+ # @api public
338
+ #: (?style: String | Symbol, ?color: String | Symbol | nil) -> self
256
339
  def border_right(style: "thin", color: nil)
257
340
  @border_props[:right] = { style: style, color: resolve_color(color) }.compact
258
341
  self
259
342
  end
260
343
 
261
- # : (?style: String | Symbol, ?color: String | Symbol | nil) -> self
344
+ # Sets the top border.
345
+ # @param style [String, Symbol] The border style.
346
+ # @param color [String, Symbol, nil] The color.
347
+ # @return [self]
348
+ # @api public
349
+ #: (?style: String | Symbol, ?color: String | Symbol | nil) -> self
262
350
  def border_top(style: "thin", color: nil)
263
351
  @border_props[:top] = { style: style, color: resolve_color(color) }.compact
264
352
  self
265
353
  end
266
354
 
267
- # : (?style: String | Symbol, ?color: String | Symbol | nil) -> self
355
+ # Sets the bottom border.
356
+ # @param style [String, Symbol] The border style.
357
+ # @param color [String, Symbol, nil] The color.
358
+ # @return [self]
359
+ # @api public
360
+ #: (?style: String | Symbol, ?color: String | Symbol | nil) -> self
268
361
  def border_bottom(style: "thin", color: nil)
269
362
  @border_props[:bottom] = { style: style, color: resolve_color(color) }.compact
270
363
  self
271
364
  end
272
365
 
273
366
  # rubocop:disable Naming/MethodParameterName
274
- # : (?style: String | Symbol, ?color: String | Symbol | nil, ?up: bool, ?down: bool) -> self
367
+ # Sets diagonal borders.
368
+ # @param style [String, Symbol] The border style.
369
+ # @param color [String, Symbol, nil] The color.
370
+ # @param up [Boolean] Diagonal up.
371
+ # @param down [Boolean] Diagonal down.
372
+ # @return [self]
373
+ # @api public
374
+ #: (?style: String | Symbol, ?color: String | Symbol | nil, ?up: bool, ?down: bool) -> self
275
375
  def border_diagonal(style: "thin", color: nil, up: false, down: false)
276
376
  @border_props[:diagonal] = { style: style, color: resolve_color(color) }.compact
277
377
  @border_props[:diagonal_up] = true if up
@@ -282,39 +382,63 @@ module Xlsxrb
282
382
 
283
383
  # --- Alignment Properties ---
284
384
 
285
- # : (String | Symbol value) -> self
385
+ # Sets horizontal alignment.
386
+ # @param value [String, Symbol] The alignment.
387
+ # @return [self]
388
+ # @api public
389
+ #: (String | Symbol) -> self
286
390
  def align_horizontal(value)
287
391
  @alignment[:horizontal] = value
288
392
  self
289
393
  end
290
394
 
291
- # : (String | Symbol value) -> self
395
+ # Sets vertical alignment.
396
+ # @param value [String, Symbol] The alignment.
397
+ # @return [self]
398
+ # @api public
399
+ #: (String | Symbol) -> self
292
400
  def align_vertical(value)
293
401
  @alignment[:vertical] = value
294
402
  self
295
403
  end
296
404
 
297
405
  # rubocop:disable Style/OptionalBooleanParameter
298
- # : (?bool value) -> self
406
+ # Sets text wrapping.
407
+ # @param value [Boolean] Whether to wrap text.
408
+ # @return [self]
409
+ # @api public
410
+ #: (?bool) -> self
299
411
  def wrap_text(value = true)
300
412
  @alignment[:wrap_text] = value
301
413
  self
302
414
  end
303
415
 
304
- # : (?bool value) -> self
416
+ # Sets shrink to fit.
417
+ # @param value [Boolean] Whether to shrink text.
418
+ # @return [self]
419
+ # @api public
420
+ #: (?bool) -> self
305
421
  def shrink_to_fit(value = true)
306
422
  @alignment[:shrink_to_fit] = value
307
423
  self
308
424
  end
309
425
  # rubocop:enable Style/OptionalBooleanParameter
310
426
 
311
- # : (Numeric value) -> self
427
+ # Sets text rotation.
428
+ # @param value [Numeric] The rotation angle.
429
+ # @return [self]
430
+ # @api public
431
+ #: (Numeric) -> self
312
432
  def text_rotation(value)
313
433
  @alignment[:text_rotation] = value
314
434
  self
315
435
  end
316
436
 
317
- # : (Numeric value) -> self
437
+ # Sets text indent.
438
+ # @param value [Numeric] The indent level.
439
+ # @return [self]
440
+ # @api public
441
+ #: (Numeric) -> self
318
442
  def indent(value)
319
443
  @alignment[:indent] = value.to_i
320
444
  self
@@ -322,7 +446,11 @@ module Xlsxrb
322
446
 
323
447
  # --- Number Format ---
324
448
 
325
- # : (String | Integer num_fmt_id) -> self
449
+ # Sets the number format.
450
+ # @param num_fmt_id [String, Integer] The format id or format string.
451
+ # @return [self]
452
+ # @api public
453
+ #: (String | Integer) -> self
326
454
  def number_format(num_fmt_id)
327
455
  @num_fmt_id = num_fmt_id
328
456
  self
@@ -331,7 +459,7 @@ module Xlsxrb
331
459
 
332
460
  # Register this style with the given Writer, returning the style_id.
333
461
  # writer:: Xlsxrb::Ooxml::Writer instance
334
- # : (untyped writer) -> Integer
462
+ #: (untyped writer) -> Integer
335
463
  def register_with(writer)
336
464
  font_id = 0
337
465
  fill_id = 0
@@ -3,5 +3,5 @@
3
3
  # rbs_inline: enabled
4
4
 
5
5
  module Xlsxrb
6
- VERSION = "0.1.5"
6
+ VERSION = "0.1.6"
7
7
  end