banker-ofx 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Banker [![CI Build Status](https://secure.travis-ci.org/BritRuby/Banker-OFX.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/BritRuby/Banker-OFX.png?travis)][gemnasium]
1
+ # Banker-OFX [![CI Build Status](https://secure.travis-ci.org/BritRuby/Banker-OFX.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/BritRuby/Banker-OFX.png?travis)][gemnasium]
2
2
 
3
3
  [travis]:http://travis-ci.org/BritRuby/Banker-OFX
4
4
  [gemnasium]:https://gemnasium.com/BritRuby/Banker-OFX
data/lib/ofx.rb CHANGED
@@ -2,6 +2,9 @@ require "open-uri"
2
2
  require "nokogiri"
3
3
  require "bigdecimal"
4
4
 
5
+ require "iconv"
6
+ require "kconv"
7
+
5
8
  require "ofx/errors"
6
9
  require "ofx/parser"
7
10
  require "ofx/parser/ofx102"
@@ -17,7 +17,7 @@ module OFX
17
17
  return document if document.respond_to?(:read)
18
18
  open(document, "r:iso-8859-1:utf-8")
19
19
  rescue
20
- StringIO.new(document.encode('utf-8'))
20
+ StringIO.new(utf8_converter(document))
21
21
  end
22
22
 
23
23
  def prepare(content)
@@ -57,10 +57,15 @@ module OFX
57
57
  end
58
58
 
59
59
  def condition_body(body)
60
- body.gsub!(/>\s+</m, "><").
61
- gsub!(/\s+</m, "<").
62
- gsub!(/>\s+/m, ">").
63
- gsub!(/<(\w+?)>([^<]+)/m, '<\1>\2</\1>')
60
+ body.gsub!(/>\s+</m, "><")
61
+ body.gsub!(/\s+</m, "<")
62
+ body.gsub!(/>\s+/m, ">")
63
+ body.gsub!(/<(\w+?)>([^<]+)/m, '<\1>\2</\1>')
64
+ end
65
+
66
+ def utf8_converter(string)
67
+ return string if Kconv.isutf8(string)
68
+ Iconv.conv("UTF-8", "LATIN1//IGNORE", string)
64
69
  end
65
70
  end
66
71
  end
@@ -2,7 +2,7 @@ module OFX
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 4
5
- PATCH = 1
5
+ PATCH = 2
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
8
8
  end
@@ -58,7 +58,6 @@ describe OFX::Account do
58
58
  it { subject.transactions.size.should eql(2) }
59
59
  it { subject.balance.amount.should eql(-562.0) }
60
60
  it { subject.balance.amount_in_pennies.should eql(-56200) }
61
- it { subject.balance.posted_at.should eql(Time.parse("2005-08-31 16:51:53 +0100")) }
62
61
  end
63
62
  end
64
63
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: banker-ofx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: