Skip to content

Commit

Permalink
Merge pull request #3 from payrollhero/update_roo
Browse files Browse the repository at this point in the history
Update roo
  • Loading branch information
bramski committed Apr 14, 2015
2 parents 2c92e5f + 38c2fcc commit 3188df0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
3 changes: 2 additions & 1 deletion excel_templating.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Gem::Specification.new do |gem|
gem.require_paths = ['lib']

gem.add_dependency "mustache"
gem.add_dependency "roo"
gem.add_dependency "roo", ">= 2.0.0beta1", "< 3"
gem.add_dependency "roo-xls"
gem.add_dependency "write_xlsx"
gem.add_dependency "writeexcel"

Expand Down
24 changes: 14 additions & 10 deletions lib/excel_templating/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,21 @@ def looks_like_a_separator?(value)
end

def format_for(font)
@font_formats ||= {}
unless @font_formats.has_key?(font)
format = workbook.add_format(
{
bold: font.bold? ? 1 : 0,
italic: font.italic? ? 1 : 0,
underline: font.underline? ? 1 : 0
}.merge(default_format_styling))
@font_formats[font] = format
font_formats[font]
end

def font_formats
@font_formats ||= Hash.new do |cache, font|
template_font = font || Roo::Font.new

format_details = {
bold: template_font.bold? ? 1 : 0,
italic: template_font.italic? ? 1 : 0,
underline: template_font.underline? ? 1 : 0
}.merge(default_format_styling)

cache[font] = workbook.add_format format_details
end
@font_formats[font]
end

def mustachify(inline_template, locals: {})
Expand Down
1 change: 1 addition & 0 deletions lib/excel_templating/rspec_excel_matcher.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'roo'
require "roo-xls"

# Matcher for rspec 'match_excel_content'
# @example
Expand Down

0 comments on commit 3188df0

Please sign in to comment.