diff options
| -rw-r--r-- | .travis.yml | 1 | ||||
| -rw-r--r-- | axlsx.gemspec | 5 | ||||
| -rw-r--r-- | lib/axlsx/stylesheet/styles.rb | 8 | ||||
| -rw-r--r-- | test/stylesheet/tc_styles.rb | 17 |
4 files changed, 25 insertions, 6 deletions
diff --git a/.travis.yml b/.travis.yml index a5e3963e..d2298044 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: ruby +before_script: "gem install rake" notifications: irc: "irc.freenode.org#axlsx" email: diff --git a/axlsx.gemspec b/axlsx.gemspec index ae3d2aaa..7a3844b3 100644 --- a/axlsx.gemspec +++ b/axlsx.gemspec @@ -23,10 +23,11 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'rmagick4j', '>= 0.3.7' if Object.const_defined? :JRUBY_VERSION s.add_runtime_dependency 'rubyzip', '>= 0.9.5' +# REQUIRED by Travis-ci please do not alter these lines s.add_runtime_dependency 'rake', '0.8.7' if RUBY_VERSION == "1.9.2" s.add_runtime_dependency 'rake', '>= 0.8.7' if ["1.9.3", "1.8.7"].include?(RUBY_VERSION) - s.add_development_dependency 'yard' - # s.add_development_dependency 'rdiscount' +# s.add_development_dependency 'yard' +# s.add_development_dependency 'rdiscount' s.required_ruby_version = '>= 1.8.7' s.require_path = 'lib' diff --git a/lib/axlsx/stylesheet/styles.rb b/lib/axlsx/stylesheet/styles.rb index 1fb2e9b3..cd8c7139 100644 --- a/lib/axlsx/stylesheet/styles.rb +++ b/lib/axlsx/stylesheet/styles.rb @@ -204,10 +204,12 @@ module Axlsx if borderId.is_a?(Hash) raise ArgumentError, "border hash definitions must include both style and color" unless borderId.keys.include?(:style) && borderId.keys.include?(:color) - s = borderId.delete :style - c = borderId.delete :color + s = borderId[:style] + c = borderId[:color] + edges = borderId[:edges] || [:left, :right, :top, :bottom] + border = Border.new - [:left, :right, :top, :bottom].each {|pr| border.prs << BorderPr.new(:name => pr, :style=>s, :color => Color.new(:rgb => c))} + edges.each {|pr| border.prs << BorderPr.new(:name => pr, :style=>s, :color => Color.new(:rgb => c))} borderId = self.borders << border end diff --git a/test/stylesheet/tc_styles.rb b/test/stylesheet/tc_styles.rb index ef14e151..31461ae3 100644 --- a/test/stylesheet/tc_styles.rb +++ b/test/stylesheet/tc_styles.rb @@ -19,11 +19,26 @@ class TestStyles < Test::Unit::TestCase end def test_add_style_border_hash border_count = @styles.borders.size - s = @styles.add_style :border => {:style=>:thin, :color => "FFFF0000"} + s = @styles.add_style :border => {:style => :thin, :color => "FFFF0000"} assert_equal(@styles.borders.size, border_count + 1) assert_equal(@styles.borders.last.prs.last.color.rgb, "FFFF0000") assert_raise(ArgumentError) { @styles.add_style :border => {:color => "FFFF0000"} } + assert_equal @styles.borders.last.prs.size, 4 + end + + def test_add_style_border_edges + s = @styles.add_style :border => { :style => :thin, :color => "0000FFFF", :edges => [:top, :bottom] } + parts = @styles.borders.last.prs + parts.each { |pr| assert_equal(pr.color.rgb, "0000FFFF", "Style is applied to #{pr.name} properly") } + assert((parts.map { |pr| pr.name.to_s }.sort && ['bottom', 'top']).size == 2, "specify two edges, and you get two border prs") + end + def test_do_not_alter_options_in_add_style + #This should test all options, but for now - just the bits that we know caused some pain + options = { :border => { :style => :thin, :color =>"FF000000" } } + @styles.add_style options + assert_equal options[:border][:style], :thin, 'thin style is stil in option' + assert_equal options[:border][:color], "FF000000", 'color is stil in option' end def test_add_style |
