Repository navigation
fix: Base#each, deprecate to_xls (returns XLSX), refresh TESTING.md (1.3.0) - #3
Merged
Merged
Conversation
…bump 1.3.0 - Base#each called an undefined rows! and always raised NoMethodError; it now returns all rows, or yields them with a block. - Base#to_xls keeps returning XLSX data for compatibility, with a one-time deprecation warning. - TESTING.md and bin/test_all now follow the CI matrix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
問題
Base#each一呼叫就NoMethodError (undefined method 'rows!'):內部呼叫不存在的rows!(應為each!)。to_xls名叫 xls,實際回傳 XLSX(內部就是Exporter::Xlsx,zip 開頭PK\x03\x04,不是 OLE2 的D0 CF 11 E0)。真正的.xls只有ExportTo::Exporter::Xls。TESTING.md、bin/test_all過期:只列 Ruby 2.7–3.1,與 CI matrix(2.7–3.4 × Rails 6.1–8.1)不符。決策:選「最不破壞」的做法
to_xls改回傳真 .xlsto_xlsto_xls行為不變(仍回傳 XLSX),文件誠實標註 + 一次性 deprecation 警告理由:既然從 1.0.0 起就一直回傳 XLSX,下游很可能已經依賴(例如存成
.xlsx或直接給 Excel 開)。靜默換格式風險比現狀更大。所以只「說實話 + 警告」,把真正換格式留給未來的 major 版本。to_xls:回傳值不變;每個 process 第一次呼叫印一次[DEPRECATION]到$stderr(含呼叫位置)。要真 .xls 請用ExportTo::Exporter::Xls.new(export).to_xls。Base#each:修好。無 block 回傳所有列的 Array(表頭在第一列,內容與to_csv一致);給 block 則逐列 yield 並回傳 self,因此map/to_a等 Enumerable 方法可用。each!不變。TESTING.md重寫成指向ci.yml/gemfiles/,不再抄版本清單;bin/test_all的TEST_MATRIX與 CI 對齊,並用「該 minor 最新已安裝 patch」解析 rbenv 版本。破壞性判斷
無 breaking change:沒有移除/改名任何公開方法,
to_xls回傳值不變。唯一行為差異:each以前一定 raise,現在能用;to_xls多一行 stderr 警告。版本
1.2.1→1.3.0(minor:新增each的 block / Enumerable 支援與 deprecation)。Gemfile.lock與 5 個gemfiles/*.lock的export_to (x.y.z)一併更新。CHANGELOG.md新增 1.3.0(含 compare 連結)、README.md更新。測試(先紅後綠)
新增
to_xlsx/to_xls(magic bytes 為 XLSX)/ warn-once /Exporter::Xls(真 xls magic)/each(無 block、block、Enumerable、each!不變)。lib/時,each相關 4 errors + deprecation 測試 1 failure;相容性測試前後皆綠(證明沒改行為)。請 Eddy 決定
to_xls的 deprecation 警告要不要?(若不想吵,可只留文件。)to_xls的終局:下個 major 改成真 .xls,還是直接移除?publish.yml(發版到 RubyGems),請確認後再 merge。