entable 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Entable
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -44,7 +44,11 @@ module Entable::XlsExport
44
44
  end
45
45
 
46
46
  def quote_for_xls text
47
- (text.is_a?(String) && needs_quoting?(text)) ? "=\"#{text}\"" : text
47
+ (text.is_a?(String) && needs_quoting?(text)) ? "=\"#{double_quote text}\"" : text
48
+ end
49
+
50
+ def double_quote text
51
+ text.gsub /"/, '""'
48
52
  end
49
53
 
50
54
  def needs_quoting? text
@@ -120,5 +120,9 @@ describe Entable do
120
120
  </table></body></html>}
121
121
  end
122
122
 
123
+ it "should escape double-quotes when necessary" do
124
+ self.class.send :include, Entable::XlsExport
125
+ quote_for_xls('2, "The Hammonds"').should == '="2, ""The Hammonds"""'
126
+ end
123
127
 
124
128
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: entable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-05 00:00:00.000000000 Z
12
+ date: 2013-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec