From c939f10d399b36b826bdb959d92db2d1ce22e0d5 Mon Sep 17 00:00:00 2001 From: RYOTA-KOBA Date: Sun, 22 Feb 2026 18:51:05 +0900 Subject: [PATCH 1/2] Add RBS for rubyXL 3.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rubyXL is a gem for reading and writing Excel (.xlsx) files. This commit adds type definitions for the most commonly used APIs described in the README. Defined classes: - RubyXL::SheetData — sparse array of rows with index access - RubyXL::Row — sparse array of cells with index access - RubyXL::Cell — cell value accessor and style-change methods - RubyXL::Worksheet — sheet name, cell creation, row/column styling - RubyXL::Workbook — workbook construction, worksheet access, I/O - RubyXL::Parser — parsing .xlsx files from path or buffer Notable design decisions: - Cell#value returns String | Integer | Float | DateTime | nil. The implementation (num_to_date) returns DateTime, not Date. - manifest.yaml declares `date` stdlib dependency because rubyXL's gemspec does not list it, yet DateTime is used in the RBS. - Workbook#write is included as it is a documented public API (alias of save), even though it is defined via alias_method. --- gems/rubyXL/.rubocop.yml | 19 ++++++++++++ gems/rubyXL/3.4/_test/metadata.yaml | 4 +++ gems/rubyXL/3.4/_test/test.rb | 46 ++++++++++++++++++++++++++++ gems/rubyXL/3.4/manifest.yaml | 7 +++++ gems/rubyXL/3.4/rubyXL.rbs | 47 +++++++++++++++++++++++++++++ 5 files changed, 123 insertions(+) create mode 100644 gems/rubyXL/.rubocop.yml create mode 100644 gems/rubyXL/3.4/_test/metadata.yaml create mode 100644 gems/rubyXL/3.4/_test/test.rb create mode 100644 gems/rubyXL/3.4/manifest.yaml create mode 100644 gems/rubyXL/3.4/rubyXL.rbs diff --git a/gems/rubyXL/.rubocop.yml b/gems/rubyXL/.rubocop.yml new file mode 100644 index 000000000..7d0be8ff2 --- /dev/null +++ b/gems/rubyXL/.rubocop.yml @@ -0,0 +1,19 @@ +# This configuration inherits from /.rubocop.yml. +# You can configure RBS style of this gem. +# This file is used on CI. It is configured to automatically +# make rubocop suggestions on pull requests for this gem. +# If you do not like the style enforcement, you should remove this file. +inherit_from: ../../.rubocop.yml + +## +# If you want to customize the style, please consult with the gem reviewers. +# You can see the list of cops at https://github.com/ksss/rubocop-on-rbs/blob/main/docs/modules/ROOT/pages/cops.adoc + +RBS/Layout: + Enabled: true + +RBS/Lint: + Enabled: true + +RBS/Style: + Enabled: true diff --git a/gems/rubyXL/3.4/_test/metadata.yaml b/gems/rubyXL/3.4/_test/metadata.yaml new file mode 100644 index 000000000..29015bc02 --- /dev/null +++ b/gems/rubyXL/3.4/_test/metadata.yaml @@ -0,0 +1,4 @@ +# If the test needs gem's RBS files, declare them here. +# +# additional_gems: +# - GEM_NAME diff --git a/gems/rubyXL/3.4/_test/test.rb b/gems/rubyXL/3.4/_test/test.rb new file mode 100644 index 000000000..a9ca3d549 --- /dev/null +++ b/gems/rubyXL/3.4/_test/test.rb @@ -0,0 +1,46 @@ +require "rubyXL" +require "rubyXL/convenience_methods" + +workbook = RubyXL::Workbook.new + +worksheets = workbook.worksheets +worksheet = worksheets[0] + +new_sheet = workbook.add_worksheet("Sheet2") +new_sheet.sheet_name = "Renamed Sheet" +name = new_sheet.sheet_name + +sheet_by_index = workbook[0] +sheet_by_name = workbook["Sheet1"] + +cell = new_sheet.add_cell(0, 0, "Hello, RubyXL!") +cell2 = new_sheet.add_cell(0, 1, 42) +cell3 = new_sheet.add_cell(1, 0, 3.14) + +val = cell.value + +cell.change_fill("FF0000") +cell.change_font_bold(true) +cell.change_text_wrap(true) +cell.change_vertical_alignment("center") + +new_sheet.change_row_height(0, 20) +new_sheet.change_row_font_size(0, 12) +new_sheet.change_column_width(0, 15) + +sheet_data = new_sheet.sheet_data +rows = sheet_data.rows +row_count = sheet_data.size + +row = new_sheet[0] +if row + cells = row.cells + cell_count = row.size + + first_cell = row[0] + if first_cell + first_val = first_cell.value + end +end + +io = workbook.stream diff --git a/gems/rubyXL/3.4/manifest.yaml b/gems/rubyXL/3.4/manifest.yaml new file mode 100644 index 000000000..2d36ae952 --- /dev/null +++ b/gems/rubyXL/3.4/manifest.yaml @@ -0,0 +1,7 @@ +# manifest.yaml describes dependencies which do not appear in the gemspec. +# If this gem includes such dependencies, comment-out the following lines and +# declare the dependencies. +# If all dependencies appear in the gemspec, you should remove this file. +# +dependencies: + - name: date diff --git a/gems/rubyXL/3.4/rubyXL.rbs b/gems/rubyXL/3.4/rubyXL.rbs new file mode 100644 index 000000000..57b6fb7b9 --- /dev/null +++ b/gems/rubyXL/3.4/rubyXL.rbs @@ -0,0 +1,47 @@ +module RubyXL + class SheetData + def rows: () -> Array[Row?] + def []: (Integer ind) -> Row? + def size: () -> Integer + end + + class Row + def cells: () -> Array[Cell?] + def []: (Integer ind) -> Cell? + def size: () -> Integer + end + + class Cell + def value: () -> (::String | ::Integer | ::Float | ::DateTime | nil) + def change_fill: (::String rgb) -> void + def change_font_bold: (bool bold) -> void + def change_text_wrap: (bool wrap) -> void + def change_vertical_alignment: (::String alignment) -> void + end + + class Worksheet + def sheet_name: () -> ::String + def sheet_name=: (::String name) -> ::String + def sheet_data: () -> SheetData + def []: (Integer row) -> Row? + def add_cell: (Integer row_index, Integer column_index, ?untyped data, ?::String? formula, ?bool overwrite) -> Cell + def change_row_height: (?Integer row, ?::Numeric height) -> void + def change_row_font_size: (?Integer row, ?::Numeric font_size) -> void + def change_column_width: (Integer column_index, ?::Numeric width_in_chars) -> void + end + + class Workbook + def initialize: () -> void + def worksheets: () -> Array[Worksheet] + def []: (Integer index) -> Worksheet? + | (::String name) -> Worksheet? + def add_worksheet: (?::String? name) -> Worksheet + def stream: () -> ::StringIO + def write: (::String dst_file_path) -> ::String + end + + class Parser + def self.parse: (::String src_file_path) -> Workbook + def self.parse_buffer: (::IO | ::String buffer) -> Workbook + end +end From ac2572051aa71d8204618b45a68695da954c3b9f Mon Sep 17 00:00:00 2001 From: RYOTA-KOBA Date: Sun, 22 Feb 2026 18:54:00 +0900 Subject: [PATCH 2/2] remove metadata.yaml --- gems/rubyXL/3.4/_test/metadata.yaml | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 gems/rubyXL/3.4/_test/metadata.yaml diff --git a/gems/rubyXL/3.4/_test/metadata.yaml b/gems/rubyXL/3.4/_test/metadata.yaml deleted file mode 100644 index 29015bc02..000000000 --- a/gems/rubyXL/3.4/_test/metadata.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# If the test needs gem's RBS files, declare them here. -# -# additional_gems: -# - GEM_NAME