Skip to content

Updates for Ruby 3.4, StandardRB #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
matrix:
os: [ ubuntu]
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-ruby
ruby: [2.1, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, jruby, head]
ruby: [2.6, 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, jruby, head]
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || endsWith(matrix.ruby, 'jruby') }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
Expand Down
17 changes: 17 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
### 1.3.4 29.03.2025
Author: Niklaus Giger <[email protected]>
* Formatted using standardrb
* Fixes for Ruby 3.4
* Bumped minimal Ruby version to 2.6

### 1.3.3 20.11.2024

commit 6464ab51195eb3593fbc2feed7436d0b6b057f73
Author: Edouard Brière <[email protected]>
* Remove trailing slash from spec.homepage

### 1.3.2 15.1.2024
commit a2f54fec58339818c54e4193eed21fbb72aceff9
Author: Andrew Nesbitt <[email protected]>
* Add funding_uri to gemspec

### 1.3.1 15.1.2024
commit dd69d23f00427066cda8d2b30355e044b8c07eff
Author: Mark Young <[email protected]>
Expand Down
11 changes: 8 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# -*- ruby -*-
require 'bundler'
require_relative './lib/spreadsheet.rb'
Bundler::GemHelper.install_tasks
require "bundler/gem_tasks"
require "standard/rake"

desc "test using minittest via test/suite.rb"
task :test do |t|
$LOAD_PATH << File.dirname(__FILE__)
require "test/suite"
end
# vim: syntax=Ruby
96 changes: 18 additions & 78 deletions devenv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1705399223,
"narHash": "sha256-2nhAJ/9LMlwaEZDnoDIhnhQ0pEC/YIIt09WD7FmTp6g=",
"lastModified": 1736273305,
"owner": "cachix",
"repo": "devenv",
"rev": "ff37923d4ba9e220b9826594e83fc29e1a4f4338",
"rev": "cc48e044747cef4e4f69897e20a100adf5b716a3",
"type": "github"
},
"original": {
Expand All @@ -20,11 +19,10 @@
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"lastModified": 1733328505,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
"type": "github"
},
"original": {
Expand All @@ -36,11 +34,10 @@
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"lastModified": 1733328505,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
"type": "github"
},
"original": {
Expand All @@ -54,29 +51,10 @@
"systems": "systems"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"lastModified": 1731533236,
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
Expand All @@ -93,11 +71,10 @@
]
},
"locked": {
"lastModified": 1703887061,
"narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=",
"lastModified": 1709087332,
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
Expand All @@ -108,16 +85,15 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1705331948,
"narHash": "sha256-qjQXfvrAT1/RKDFAMdl8Hw3m4tLVvMCc8fMqzJv0pP4=",
"lastModified": 1736200483,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b8dd8be3c790215716e7c12b247f45ca525867e2",
"rev": "3f0a8ac25fb674611b98089ca3a5dd6480175751",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.11",
"ref": "nixos-24.11",
"repo": "nixpkgs",
"type": "github"
}
Expand All @@ -131,11 +107,10 @@
]
},
"locked": {
"lastModified": 1705118282,
"narHash": "sha256-9FUnVSPjF+xV2a7tfai8fxi9Ek538mdkEjaFJnWRk9Y=",
"lastModified": 1735192621,
"owner": "bobvanderlinden",
"repo": "nixpkgs-ruby",
"rev": "1a4b0055af39b2d0756d5a117589b8ccddbce4f8",
"rev": "602c528c8228f231f912c6d117703a1700464202",
"type": "github"
},
"original": {
Expand All @@ -144,38 +119,19 @@
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1704874635,
"narHash": "sha256-YWuCrtsty5vVZvu+7BchAxmcYzTMfolSPP5io8+WYCg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3dc440faeee9e889fe2d1b4d25ad0f430d449356",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils_2",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
]
},
"locked": {
"lastModified": 1705229514,
"narHash": "sha256-itILy0zimR/iyUGq5Dgg0fiW8plRDyxF153LWGsg3Cw=",
"lastModified": 1735882644,
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "ffa9a5b90b0acfaa03b1533b83eaf5dead819a05",
"rev": "a5a961387e75ae44cc20f0a57ae463da5e959656",
"type": "github"
},
"original": {
Expand All @@ -195,22 +151,6 @@
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
Expand Down
3 changes: 2 additions & 1 deletion devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
# languages.nix.enable = true;

languages.ruby.enable = true;
languages.ruby.versionFile = ./.ruby-version;
languages.ruby.version = "3.4";

# https://devenv.sh/pre-commit-hooks/
# pre-commit.hooks.shellcheck.enable = true;

Expand Down
2 changes: 1 addition & 1 deletion devenv.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
inputs:
nixpkgs:
url: github:NixOS/nixpkgs/nixos-23.11
url: github:NixOS/nixpkgs/nixos-24.11
nixpkgs-ruby:
url: github:bobvanderlinden/nixpkgs-ruby
inputs:
Expand Down
2 changes: 1 addition & 1 deletion lib/parseexcel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# 8006 Zürich
### Switzerland

require 'parseexcel/parseexcel'
require "parseexcel/parseexcel"
124 changes: 66 additions & 58 deletions lib/parseexcel/parseexcel.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require 'spreadsheet'
require "spreadsheet"

warn <<-EOS
[DEPRECATED] By requiring 'parseexcel', 'parseexcel/parseexcel' and/or
'parseexcel/parser' you are loading a Compatibility layer which
provides a drop-in replacement for the ParseExcel library. This
code makes the reading of Spreadsheet documents less efficient and
will be removed in Spreadsheet version 1.0.0
warn <<~EOS
[DEPRECATED] By requiring 'parseexcel', 'parseexcel/parseexcel' and/or
'parseexcel/parser' you are loading a Compatibility layer which
provides a drop-in replacement for the ParseExcel library. This
code makes the reading of Spreadsheet documents less efficient and
will be removed in Spreadsheet version 1.0.0
EOS

module Spreadsheet
Expand All @@ -14,62 +14,70 @@ module Spreadsheet
# ParseExcel library. This code is deprecated and will be removed in
# Spreadsheet version 1.0.0
module ParseExcel
def ParseExcel.parse path
Spreadsheet.open path
end
class Worksheet
class Cell
attr_accessor :value, :kind, :numeric, :code, :book,
:format, :rich, :encoding, :annotation
def initialize value, format, row, idx
@format = format
@idx = idx
@row = row
@value = value
@encoding = Spreadsheet.client_encoding
end
def date
@row.date @idx
end
def datetime
@row.datetime @idx
end
def to_i
@value.to_i
def self.parse path
Spreadsheet.open path
end
def to_f
@value.to_f
end
def to_s(target_encoding=nil)
if(target_encoding)
begin
Iconv.new(target_encoding, @encoding).iconv(@value)
rescue
Iconv.new(target_encoding, 'ascii').iconv(@value.to_s)

class Worksheet
class Cell
attr_accessor :value, :kind, :numeric, :code, :book,
:format, :rich, :encoding, :annotation
def initialize value, format, row, idx
@format = format
@idx = idx
@row = row
@value = value
@encoding = Spreadsheet.client_encoding
end

def date
@row.date @idx
end

def datetime
@row.datetime @idx
end

def to_i
@value.to_i
end

def to_f
@value.to_f
end

def to_s(target_encoding = nil)
if target_encoding
begin
Iconv.new(target_encoding, @encoding).iconv(@value)
rescue
Iconv.new(target_encoding, "ascii").iconv(@value.to_s)
end
else
@value.to_s
end
end

def type
if @format && (@format.date? || @format.time?)
:date
elsif @value.is_a?(Numeric)
:numeric
else
:text
end
end
else
@value.to_s
end
end
def type
if @format && (@format.date? || @format.time?)
:date
elsif @value.is_a?(Numeric)
:numeric
else
:text
end
end
end
end
end

module Excel
class Reader # :nodoc: all
def set_cell worksheet, row, column, xf, value=nil
cells = @current_row_block[row] ||= Row.new(nil, row)
cells.formats[column] = xf = @workbook.format(xf)
cells[column] = ParseExcel::Worksheet::Cell.new(value, xf, cells, column)
end
end
class Reader # :nodoc: all
def set_cell worksheet, row, column, xf, value = nil
cells = @current_row_block[row] ||= Row.new(nil, row)
cells.formats[column] = xf = @workbook.format(xf)
cells[column] = ParseExcel::Worksheet::Cell.new(value, xf, cells, column)
end
end
end
end
Loading
Loading