diff options
Diffstat (limited to 'lib')
| -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 |
4 files changed, 13 insertions, 14 deletions
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 |
