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: diff --git a/lib/fast_excel.rb b/lib/fast_excel.rb index 75a74de..b750691 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 @@ -295,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) @@ -334,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 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/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 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