diff options
| -rw-r--r-- | .rubocop_todo.yml | 6 | ||||
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | lib/axlsx.rb | 8 | ||||
| -rw-r--r-- | lib/axlsx/package.rb | 6 | ||||
| -rw-r--r-- | lib/axlsx/util/constants.rb | 4 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/page_margins.rb | 9 |
6 files changed, 14 insertions, 20 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 99cea3ce..bb6a38f9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -84,12 +84,6 @@ Lint/UnusedMethodArgument: - 'lib/axlsx/package.rb' - 'lib/axlsx/util/validators.rb' -# Configuration parameters: MinSize. -Performance/CollectionLiteralInLoop: - Exclude: - - 'lib/axlsx/package.rb' - - 'lib/axlsx/workbook/worksheet/page_margins.rb' - # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: separated, grouped diff --git a/CHANGELOG.md b/CHANGELOG.md index cf7a02ba..c7e0fc8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ CHANGELOG - Fix `SimpleTypedList#to_a` and `SimpleTypedList#to_ary` returning the internal list instance - Remove ability to set `u=` to true in favor of using :single or one of the other underline options - Fix `Workbook#sheet_by_name` not returning sheets with encoded characters in the name + - Raise exception if `axlsx_styler` gem is present as its code was merged directly into `caxlsx` in v3.3.0 - **April.23.23**: 3.4.1 - [PR #209](https://github.com/caxlsx/caxlsx/pull/209) - Revert characters other than `=` being considered as formulas. diff --git a/lib/axlsx.rb b/lib/axlsx.rb index 58096e7c..20af45e0 100644 --- a/lib/axlsx.rb +++ b/lib/axlsx.rb @@ -33,12 +33,8 @@ require 'bigdecimal' require 'set' require 'time' -begin - if Gem.loaded_specs.has_key?("axlsx_styler") - raise StandardError, "Please remove `axlsx_styler` from your Gemfile, the associated functionality is now built-in to `caxlsx` directly." - end -rescue StandardError - # Do nothing +if Gem.loaded_specs.has_key?("axlsx_styler") + raise StandardError, "Please remove `axlsx_styler` from your Gemfile, the associated functionality is now built-in to `caxlsx` directly." end # xlsx generation with charts, images, automated column width, customizable styles diff --git a/lib/axlsx/package.rb b/lib/axlsx/package.rb index 2983ed72..20195ddc 100644 --- a/lib/axlsx/package.rb +++ b/lib/axlsx/package.rb @@ -330,11 +330,11 @@ module Axlsx end exts = workbook.images.map { |image| image.extname.downcase } exts.uniq.each do |ext| - ct = if ['jpeg', 'jpg'].include?(ext) + ct = if JPEG_EXS.include?(ext) JPEG_CT - elsif ext == 'gif' + elsif ext == GIF_EX GIF_CT - elsif ext == 'png' + elsif ext == PNG_EX PNG_CT end c_types << Axlsx::Default.new(:ContentType => ct, :Extension => ext) diff --git a/lib/axlsx/util/constants.rb b/lib/axlsx/util/constants.rb index 138c8bf0..459e0099 100644 --- a/lib/axlsx/util/constants.rb +++ b/lib/axlsx/util/constants.rb @@ -166,8 +166,8 @@ module Axlsx # xml content type extensions XML_EX = "xml" - # jpeg extension - JPEG_EX = "jpeg" + # jpeg extensions + JPEG_EXS = ["jpeg", "jpg"].freeze # gif extension GIF_EX = "gif" diff --git a/lib/axlsx/workbook/worksheet/page_margins.rb b/lib/axlsx/workbook/worksheet/page_margins.rb index 4d133c5a..9c2ddd8e 100644 --- a/lib/axlsx/workbook/worksheet/page_margins.rb +++ b/lib/axlsx/workbook/worksheet/page_margins.rb @@ -29,7 +29,10 @@ module Axlsx parse_options options end - serializable_attributes :left, :right, :bottom, :top, :header, :footer + # Possible margins to set + MARGIN_KEYS = [:left, :right, :top, :bottom, :header, :footer].freeze + + serializable_attributes(*MARGIN_KEYS) # Default left and right margin (in inches) DEFAULT_LEFT_RIGHT = 0.75 @@ -65,10 +68,10 @@ module Axlsx attr_reader :footer # Set some or all margins at once. - # @param [Hash] margins the margins to set (possible keys are :left, :right, :top, :bottom, :header and :footer). + # @param [Hash] margins the margins to set. See {MARGIN_KEYS} for a list of possible keys. def set(margins) margins.select do |k, v| - next unless [:left, :right, :top, :bottom, :header, :footer].include? k + next unless MARGIN_KEYS.include? k send("#{k}=", v) end |
