ofx 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f010daf75c910a87b19c737c27a0970a4a410f5e5b6ba5916f4546e2bb5f9abb
4
- data.tar.gz: abf6b0090855e5c063ce2d627e8f2b4907be64a71289cb520d4ae4bf7687371e
3
+ metadata.gz: a1f7e1315a8e1fe59c9e97b5bb1bd470f5ba977463f3311e3eb76ecdc707afd7
4
+ data.tar.gz: f8463316d6ef710908701765feabbd884e7f5ee87b0ceb2188cef1284705ed23
5
5
  SHA512:
6
- metadata.gz: f3ccb6719848c32e3047243715a3ec2aabbc80b2f241bfd2ff7dcbda819bf1baeb3086ee751459a28643345d4272bf4b4481dd56ba727f9ebf94ea6a680d4cf0
7
- data.tar.gz: 48076b4428d20fa368544099691ebe1bf877b724b49cfce83265545a84b62b07e45759e00ae0febaf254090d53c157a1f9b7b6340f5c9d59237aa1847e590ca5
6
+ metadata.gz: 4883a274bcb8fcbd35b363183f9ddf896994278ade919f038d698ccd1164dd78b947ee500d3b66b27dc6c22ba719ba6144317a1fbacf66a724d35e3bc14845bd
7
+ data.tar.gz: 7f40b8abdde571151fe54015a243e8f569116178dc7ed0113639900bbfe4e976ca4f62ccb32dbdaa72e2ce5ddd5794fd85f50bf1dc455ac20a61c893c0e5dd49
data/lib/ofx/account.rb CHANGED
@@ -1,11 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OFX
2
4
  class Account < Foundation
3
- attr_accessor :balance
4
- attr_accessor :bank_id
5
- attr_accessor :currency
6
- attr_accessor :id
7
- attr_accessor :transactions
8
- attr_accessor :type
9
- attr_accessor :available_balance
5
+ attr_accessor :balance, :bank_id, :currency, :id, :transactions, :type, :available_balance
10
6
  end
11
7
  end
data/lib/ofx/balance.rb CHANGED
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OFX
2
4
  class Balance < Foundation
3
- attr_accessor :amount
4
- attr_accessor :amount_in_pennies
5
- attr_accessor :posted_at
5
+ attr_accessor :amount, :amount_in_pennies, :posted_at
6
6
  end
7
- end
7
+ end
8
+
data/lib/ofx/errors.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OFX
2
4
  class UnsupportedFileError < StandardError; end
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OFX
2
4
  class Foundation
3
5
  def initialize(attrs)
@@ -6,4 +8,5 @@ module OFX
6
8
  end
7
9
  end
8
10
  end
9
- end
11
+ end
12
+
@@ -23,7 +23,7 @@ module OFX
23
23
  'INFO' => :info,
24
24
  'WARN' => :warn,
25
25
  'ERROR' => :error
26
- }.freeza
26
+ }.freeze
27
27
 
28
28
  attr_reader :headers, :body, :html
29
29
 
@@ -134,7 +134,7 @@ module OFX
134
134
  check_number: element.search('checknum').inner_text,
135
135
  ref_number: element.search('refnum').inner_text,
136
136
  posted_at: build_date(element.search('dtposted').inner_text),
137
- occurred_at:,
137
+ occurred_at: occurred_at,
138
138
  type: build_type(element),
139
139
  sic: element.search('sic').inner_text
140
140
  })
@@ -164,7 +164,7 @@ module OFX
164
164
  offset = '+0000'
165
165
  end
166
166
 
167
- date << ' #{offset}'
167
+ date << " #{offset}"
168
168
 
169
169
  Time.parse(date)
170
170
  end
@@ -178,9 +178,9 @@ module OFX
178
178
  end
179
179
 
180
180
  OFX::Balance.new({
181
- amount:,
181
+ amount: ammount,
182
182
  amount_in_pennies: (amount * 100).to_i,
183
- posted_at:
183
+ posted_at: posted_at
184
184
  })
185
185
  end
186
186
 
@@ -189,7 +189,7 @@ module OFX
189
189
  amount = to_decimal(node.search('availbal > balamt').inner_text)
190
190
 
191
191
  OFX::Balance.new({
192
- amount:,
192
+ amount: amount,
193
193
  amount_in_pennies: (amount * 100).to_i,
194
194
  posted_at: build_date(node.search('availbal > dtasof').inner_text)
195
195
  })
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OFX
2
4
  module Parser
3
5
  class OFX211 < OFX102
4
- VERSION = "2.1.1"
6
+ VERSION = '2.1.1'
5
7
 
6
8
  def self.parse_headers(header_text)
7
9
  doc = Nokogiri::XML(header_text)
@@ -9,7 +11,7 @@ module OFX
9
11
  # Nokogiri can't search for processing instructions, so we
10
12
  # need to do this manually.
11
13
  doc.children.each do |e|
12
- if e.type == Nokogiri::XML::Node::PI_NODE && e.name == "OFX"
14
+ if e.type == Nokogiri::XML::Node::PI_NODE && e.name == 'OFX'
13
15
  # Getting the attributes from the element doesn't seem to
14
16
  # work either.
15
17
  return extract_headers(e.text)
@@ -19,13 +21,14 @@ module OFX
19
21
  nil
20
22
  end
21
23
 
22
- private
23
24
  def self.extract_headers(text)
24
25
  headers = {}
25
26
  text.split(/\s+/).each do |attr_text|
26
27
  match = /(.+)="(.+)"/.match(attr_text)
27
28
  next unless match
28
- k, v = match[1], match[2]
29
+
30
+ k = match[1]
31
+ v = match[2]
29
32
  headers[k] = v
30
33
  end
31
34
  headers
@@ -33,6 +36,7 @@ module OFX
33
36
 
34
37
  def self.strip_quotes(s)
35
38
  return unless s
39
+
36
40
  s.sub(/^"(.*)"$/, '\1')
37
41
  end
38
42
  end
data/lib/ofx/parser.rb CHANGED
@@ -1,10 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OFX
2
4
  module Parser
3
5
  class Base
4
- attr_reader :headers
5
- attr_reader :body
6
- attr_reader :content
7
- attr_reader :parser
6
+ attr_reader :headers, :body, :conten, :parser
8
7
 
9
8
  def initialize(resource)
10
9
  resource = open_resource(resource)
@@ -12,17 +11,17 @@ module OFX
12
11
  begin
13
12
  @content = convert_to_utf8(resource.read)
14
13
  @headers, @body = prepare(content)
15
- rescue
14
+ rescue StandardError
16
15
  raise OFX::UnsupportedFileError
17
16
  end
18
17
 
19
- case headers["VERSION"]
20
- when /102/ then
21
- @parser = OFX102.new(:headers => headers, :body => body)
22
- when /103/ then
23
- @parser = OFX103.new(:headers => headers, :body => body)
24
- when /200|202|211|220/ then
25
- @parser = OFX211.new(:headers => headers, :body => body)
18
+ case headers['VERSION']
19
+ when /102/
20
+ @parser = OFX102.new(headers: headers, body: body)
21
+ when /103/
22
+ @parser = OFX103.new(headersu: headers, body: body)
23
+ when /200|202|211|220/
24
+ @parser = OFX211.new(headers: headers, body: body)
26
25
  else
27
26
  raise OFX::UnsupportedFileError
28
27
  end
@@ -34,11 +33,12 @@ module OFX
34
33
  else
35
34
  open(resource)
36
35
  end
37
- rescue
36
+ rescue StandardError
38
37
  StringIO.new(resource)
39
38
  end
40
39
 
41
40
  private
41
+
42
42
  def prepare(content)
43
43
  # split headers & body
44
44
  header_text, body = content.dup.split(/<OFX>/, 2)
@@ -55,9 +55,9 @@ module OFX
55
55
  end
56
56
 
57
57
  # Replace body tags to parse it with Nokogiri
58
- body.gsub!(/>\s+</m, "><")
59
- body.gsub!(/\s+</m, "<")
60
- body.gsub!(/>\s+/m, ">")
58
+ body.gsub!(/>\s+</m, '><')
59
+ body.gsub!(/\s+</m, '<')
60
+ body.gsub!(/>\s+/m, '>')
61
61
  body.gsub!(/<(\w+?)>([^<]+)/m, '<\1>\2</\1>')
62
62
 
63
63
  [headers, body]
@@ -65,7 +65,8 @@ module OFX
65
65
 
66
66
  def convert_to_utf8(string)
67
67
  return string if Kconv.isutf8(string)
68
- string.encode("UTF-8", "ISO-8859-1")
68
+
69
+ string.encode('UTF-8', 'ISO-8859-1')
69
70
  end
70
71
  end
71
72
  end
data/lib/ofx/sign_on.rb CHANGED
@@ -1,8 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OFX
2
4
  class SignOn < Foundation
3
- attr_accessor :language
4
- attr_accessor :fi_id
5
- attr_accessor :fi_name
6
- attr_accessor :status
5
+ attr_accessor :language, :fi_id, :fi_name, :status
7
6
  end
8
7
  end
data/lib/ofx/statement.rb CHANGED
@@ -1,11 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OFX
2
4
  class Statement < Foundation
3
- attr_accessor :account
4
- attr_accessor :available_balance
5
- attr_accessor :balance
6
- attr_accessor :currency
7
- attr_accessor :start_date
8
- attr_accessor :end_date
9
- attr_accessor :transactions
5
+ attr_accessor :account, :available_balance, :balance, :currency, :start_date, :end_date, :transactions
10
6
  end
11
7
  end
data/lib/ofx/status.rb CHANGED
@@ -1,12 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OFX
2
4
  # Error Reporting Aggregate
3
5
  class Status < Foundation
4
- attr_accessor :code # Error code
5
- attr_accessor :severity # Severity of the error
6
- attr_accessor :message # Textual explanation
6
+ attr_accessor :code, :severity, :message
7
7
 
8
8
  def success?
9
- code == 0
9
+ code.zero?
10
10
  end
11
11
  end
12
12
  end
@@ -1,16 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OFX
2
4
  class Transaction < Foundation
3
- attr_accessor :amount
4
- attr_accessor :amount_in_pennies
5
- attr_accessor :check_number
6
- attr_accessor :fit_id
7
- attr_accessor :memo
8
- attr_accessor :name
9
- attr_accessor :payee
10
- attr_accessor :posted_at
11
- attr_accessor :occurred_at
12
- attr_accessor :ref_number
13
- attr_accessor :type
14
- attr_accessor :sic
5
+ attr_accessor :amount, :amount_in_pennies, :check_number, :fit_id, :memo, :name, :payee, :posted_at, :occurred_at,
6
+ :ref_number, :type, :sic
15
7
  end
16
8
  end
data/lib/ofx/version.rb CHANGED
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OFX
2
4
  module Version
3
5
  MAJOR = 0
4
6
  MINOR = 3
5
- PATCH = 4
7
+ PATCH = 5
6
8
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
9
  end
8
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ofx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-02-22 00:00:00.000000000 Z
12
+ date: 2022-02-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri