Skip to content

Commit

Permalink
Add RubyZip 2.4 and 3.0 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
tagliala committed Jul 18, 2024
1 parent 66bc9f7 commit 8376937
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ jobs:
allow_failures: 'allow failures'
- ruby: jruby-head
allow_failures: 'allow failures'
- ruby: 3.3
gemfile: 'gemfiles/rubyzip_3.gemfile'
allow_failures: 'allow failures'

steps:
- uses: actions/checkout@v4
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ examples/sprk2012
.~lock*
*.qcachegrind
*.iml
.idea
.idea
gemfiles/*.lock
30 changes: 30 additions & 0 deletions gemfiles/rubyzip_3.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

source 'https://rubygems.org'
gemspec path: "../"

gem 'rubyzip', '3.0.0.alpha'

group :development, :test do
gem 'kramdown'
gem 'yard'

if RUBY_VERSION >= '2.7'
gem 'rubocop', '1.65.0'
gem 'rubocop-minitest', '0.35.1'
gem 'rubocop-performance', '1.21.1'
end
end

group :test do
gem 'rake'
gem 'simplecov'
gem 'minitest'
gem 'timecop'
gem 'webmock'
end

group :profile do
gem 'memory_profiler'
gem 'ruby-prof', platforms: :ruby
end
1 change: 1 addition & 0 deletions lib/axlsx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# required gems
require 'nokogiri'
require 'zip'
require 'zip/version'

# core dependencies
require 'bigdecimal'
Expand Down
7 changes: 6 additions & 1 deletion lib/axlsx/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,12 @@ def write_parts(zip)
# @return [Zip::Entry]
def zip_entry_for_part(part)
timestamp = Zip::DOSTime.at(@core.created.to_i)
Zip::Entry.new("", part[:entry], "", "", 0, 0, Zip::Entry::DEFLATED, 0, timestamp)

if Zip::VERSION >= '2.4'
Zip::Entry.new("", part[:entry], time: timestamp)
else
Zip::Entry.new("", part[:entry], "", "", 0, 0, Zip::Entry::DEFLATED, 0, timestamp)
end
end

# The parts of a package
Expand Down

0 comments on commit 8376937

Please sign in to comment.