From d41dd3d5064bef21d4fc1d56bd94fdb414710c83 Mon Sep 17 00:00:00 2001 From: Pavel Evstigneev Date: Wed, 19 Mar 2025 14:01:35 +0300 Subject: [PATCH 1/6] Add tests for FastExcel.lxw_time --- lib/fast_excel.rb | 3 --- test/date_test.rb | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/fast_excel.rb b/lib/fast_excel.rb index 75a74de..de3ea63 100644 --- a/lib/fast_excel.rb +++ b/lib/fast_excel.rb @@ -1,9 +1,6 @@ require_relative './fast_excel/binding' require 'set' -# not used for now -#require_relative '../ext/fast_excel/text_width_ext' - module FastExcel class Formula diff --git a/test/date_test.rb b/test/date_test.rb index bcd46b0..8f1dc28 100644 --- a/test/date_test.rb +++ b/test/date_test.rb @@ -54,3 +54,17 @@ end end + +describe "FastExcel.lxw_time" do + it "should make Libxlsxwriter::Datetime" do + time = Time.at(610421163).utc + lxw_time = FastExcel.lxw_time(time) + + assert_equal(lxw_time[:year], 1989) + assert_equal(lxw_time[:month], 5) + assert_equal(lxw_time[:day], 6) + assert_equal(lxw_time[:hour], 1) + assert_equal(lxw_time[:min], 26) + assert_equal(lxw_time[:sec], 3.0) + end +end From 7165fa35eae6642f816f6efe9f232691f112b2f2 Mon Sep 17 00:00:00 2001 From: Pavel Evstigneev Date: Sun, 20 Apr 2025 09:50:04 +0300 Subject: [PATCH 2/6] Add test for FastExcel.color_to_hex --- lib/fast_excel.rb | 4 ++-- test/color_to_hex_test.rb | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 test/color_to_hex_test.rb diff --git a/lib/fast_excel.rb b/lib/fast_excel.rb index de3ea63..f6773ad 100644 --- a/lib/fast_excel.rb +++ b/lib/fast_excel.rb @@ -292,8 +292,8 @@ def self.color_to_hex(value) return EXTRA_COLORS[value.to_sym] elsif COLOR_ENUM.find(value.to_sym) return COLOR_ENUM.find(value.to_sym) - elsif COLOR_ENUM.find("color_#{value.to_sym}") - return COLOR_ENUM.find("color_#{value.to_sym}") + elsif COLOR_ENUM.find("color_#{value}".to_sym) + return COLOR_ENUM.find("color_#{value}".to_sym) elsif value =~ /^#?(0x)?([\da-f]){6}$/i value = value.sub('#', '') if value.start_with?('#') return value.start_with?('0x') ? value.to_i(16) : "0x#{value}".to_i(16) diff --git a/test/color_to_hex_test.rb b/test/color_to_hex_test.rb new file mode 100644 index 0000000..50bafdf --- /dev/null +++ b/test/color_to_hex_test.rb @@ -0,0 +1,15 @@ +require_relative 'test_helper' + +describe "FastExcel.color_to_hex" do + it "should convert hex number color to hex" do + assert_equal(FastExcel.color_to_hex(0xFF0000), 0xFF0000) + end + + it "should convert color name to hex" do + assert_equal(FastExcel.color_to_hex("color_lime"), 0x00FF00) + end + + it "should convert color name (extra colors) to hex" do + assert_equal(FastExcel.color_to_hex("steel_blue"), 0x4682B4) + end +end From e1aae74584b7d7581fbdba9735d2369d84b8587b Mon Sep 17 00:00:00 2001 From: Pavel Evstigneev Date: Sun, 20 Apr 2025 09:57:14 +0300 Subject: [PATCH 3/6] Try with octocov's body --- .octocov.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.octocov.yml b/.octocov.yml index 0583db2..93f3a13 100644 --- a/.octocov.yml +++ b/.octocov.yml @@ -13,8 +13,12 @@ diff: datastores: - artifact://${GITHUB_REPOSITORY} comment: - if: is_pull_request - deletePrevious: true + if: false +body: + if: true +#comment: +# if: is_pull_request +# deletePrevious: true report: if: is_default_branch datastores: From 05f73d348d35a517b8608094704ff4b083564dae Mon Sep 17 00:00:00 2001 From: Pavel Evstigneev Date: Sun, 20 Apr 2025 09:59:43 +0300 Subject: [PATCH 4/6] try with sonar --- sonar.properties | 1 + 1 file changed, 1 insertion(+) create mode 100644 sonar.properties diff --git a/sonar.properties b/sonar.properties new file mode 100644 index 0000000..95f76a1 --- /dev/null +++ b/sonar.properties @@ -0,0 +1 @@ +sonar.ruby.coverage.reportPaths=coverage/.resultset.json From 8436afe98822835eac9fb50e94c13b5562a21327 Mon Sep 17 00:00:00 2001 From: Pavel Evstigneev Date: Sun, 20 Apr 2025 10:13:42 +0300 Subject: [PATCH 5/6] Update pretty_print(pp) --- lib/fast_excel.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fast_excel.rb b/lib/fast_excel.rb index f6773ad..b750691 100644 --- a/lib/fast_excel.rb +++ b/lib/fast_excel.rb @@ -331,8 +331,8 @@ def fields_hash res end - def pretty_print(pp) - pp fields_hash + def pretty_print(pp_obj) + fields_hash.pretty_print(pp_obj) end end From c10fe4e59c45dc19965a6b4aa3cc3339fa12ca91 Mon Sep 17 00:00:00 2001 From: Pavel Evstigneev Date: Sun, 20 Apr 2025 10:14:47 +0300 Subject: [PATCH 6/6] Uodate sonar config --- sonar-project.properties | 4 ++++ sonar.properties | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 sonar-project.properties delete mode 100644 sonar.properties diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..6dc3bbe --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,4 @@ +sonar.sources=. +sonar.language=ruby +sonar.ruby.coverage.reportPaths=coverage/.resultset.json +sonar.exclusions=**/*_test.rb,**/coverage/** diff --git a/sonar.properties b/sonar.properties deleted file mode 100644 index 95f76a1..0000000 --- a/sonar.properties +++ /dev/null @@ -1 +0,0 @@ -sonar.ruby.coverage.reportPaths=coverage/.resultset.json