extras_de_cont 1.0.0 → 1.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45c645d6d5fc89fb998902c22056fb81e1a47fadfd1337492119ca9146f809d3
4
- data.tar.gz: 3717d8ac49c1779fc31db92f8405c79e9bdb44fa5cd07d38173c35d14c4ef49f
3
+ metadata.gz: 69bb4ccabcbeca26046ace09db26a3b6e207e5ccb269f0572373472ae6ce8cd4
4
+ data.tar.gz: c249a2485737903eb4cc42c26ddcd41f17d4aa653d23546e0ede16e93c6ed8ee
5
5
  SHA512:
6
- metadata.gz: c37d86a1c6e8a7e885226c0d0a9710129e119d4bc5b93fcd2b1b6863de7d455f557ef6ee827b53689cf01ff134ba37f1a7c15537681ca0010cca73767611754d
7
- data.tar.gz: 32b6256f9e0c00689a781ff168afb74c16688672ae0bc7f307c94c0559a19bb5198e143530926ba7eff458457ddddc4c2da065edfd4436084e0d02e1822c042f
6
+ metadata.gz: b347db52d2b09495de4f60edd64897440b548f8a010b3c6d732e17cfa2de684e2dbdd33c882766dbc1d6ce60419dbd7b99bc7e0213e8e913b7dec922c3b2cbfd
7
+ data.tar.gz: 7945a8150853d19eab987edbbe1e5d99b6682ec35068faabb6083bc43fcfd62643c0b21a5bb970641cdc21011be3a2aace847acf4e022765aca899dd63ff4908
@@ -2,17 +2,57 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "extras_de_cont"
5
- s.version = "1.0.0"
5
+ s.version = "1.0.1"
6
6
  s.licenses = ["GPLv3"]
7
7
  s.summary = "A simple library which helps you extract transactions from a PDF bank statement."
8
8
  s.description = <<~TEXT
9
- "A simple library which helps you extract transactions from a PDF bank statement.
10
- Fine tuned for Romanian bank statements."
9
+ A simple library which helps you extract transactions from a PDF bank statement.
10
+ Fine tuned for Romanian bank statements.
11
+
12
+ # ExtrasDeCont
13
+
14
+ A ruby gem for extracting bank statements from PDFs.
15
+
16
+ ## Simple usage
17
+
18
+ Create a PDF parser and print the extracted text:
19
+
20
+ ```ruby
21
+ require "bundler/setup"
22
+ require "extras_de_cont"
23
+
24
+ parser = ExtrasDeCont::Parser.new("/home/dnutiu/Documents/tranzactii_revolut.pdf")
25
+ puts parser.text
26
+ ```
27
+
28
+ Or, extract all the transactions from a Revolut Bank statement PDF:
29
+
30
+ ```ruby
31
+ transactions = ExtrasDeCont.parse(file, bank: :revolut)
32
+
33
+ transactions.each do |t|
34
+ puts "\#{t.date}, \#{t.description}, \#{t.amount}, \#{t.currency}"
35
+ end
36
+ ```
37
+
38
+ Or use the included entrypoint:
39
+
40
+ ```bash
41
+ bundle exec ruby -Ilib bin/main /home/dnutiu/Documents/tranzactii_revolut.pdf
42
+ ```
43
+
44
+ Run the Revolut parser test with:
45
+
46
+ ```bash
47
+ ruby -Ilib:test test/revolut_rule_test.rb
48
+ ```
49
+
11
50
  TEXT
12
51
  s.authors = ["Denis Nutiu"]
13
52
  s.email = "dnutiu@nuculabs.dev"
14
53
  s.homepage = "https://nuculabs.dev"
15
- s.metadata = {"source_code_uri" => "https://gitlab.nuculabs.dev/dnutiu/extras-de-cont"}
54
+ s.metadata = { "source_code_uri" => "https://gitlab.nuculabs.dev/dnutiu/extras-de-cont",
55
+ "rubygems_mfa_required" => "true" }
16
56
  s.required_ruby_version = ">= 3.0.0"
17
57
 
18
58
  # Files to include in the gem
@@ -2,6 +2,7 @@
2
2
 
3
3
  module ExtrasDeCont
4
4
  module Rules
5
+ # The base class for implementing bank specific transaction parsing rules.
5
6
  class Base
6
7
  def parse(_text)
7
8
  raise NotImplementedError, "#{self.class} must implement #parse"
@@ -5,6 +5,7 @@ require "extras_de_cont/transaction"
5
5
 
6
6
  module ExtrasDeCont
7
7
  module Rules
8
+ # Rules for parsing Revolut bank statements.
8
9
  class Revolut < Rules::Base
9
10
  SECTION_HEADERS = [
10
11
  "Pending from ",
@@ -147,12 +148,10 @@ module ExtrasDeCont
147
148
  return if amount_matches.empty?
148
149
 
149
150
  transaction_match = if table.fetch(:has_balance)
150
- if amount_matches.length > 1
151
- amount_matches[-2]
152
- end
153
- else
154
- amount_matches[-1]
155
- end
151
+ amount_matches[-2] if amount_matches.length > 1
152
+ else
153
+ amount_matches[-1]
154
+ end
156
155
  return if transaction_match.nil?
157
156
 
158
157
  description = row[date_match.end(0)...transaction_match.begin(0)].to_s.strip
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extras_de_cont
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Nutiu
@@ -23,9 +23,48 @@ dependencies:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
25
  version: '2.15'
26
- description: |
27
- "A simple library which helps you extract transactions from a PDF bank statement.
28
- Fine tuned for Romanian bank statements."
26
+ description: |+
27
+ A simple library which helps you extract transactions from a PDF bank statement.
28
+ Fine tuned for Romanian bank statements.
29
+
30
+ # ExtrasDeCont
31
+
32
+ A ruby gem for extracting bank statements from PDFs.
33
+
34
+ ## Simple usage
35
+
36
+ Create a PDF parser and print the extracted text:
37
+
38
+ ```ruby
39
+ require "bundler/setup"
40
+ require "extras_de_cont"
41
+
42
+ parser = ExtrasDeCont::Parser.new("/home/dnutiu/Documents/tranzactii_revolut.pdf")
43
+ puts parser.text
44
+ ```
45
+
46
+ Or, extract all the transactions from a Revolut Bank statement PDF:
47
+
48
+ ```ruby
49
+ transactions = ExtrasDeCont.parse(file, bank: :revolut)
50
+
51
+ transactions.each do |t|
52
+ puts "#{t.date}, #{t.description}, #{t.amount}, #{t.currency}"
53
+ end
54
+ ```
55
+
56
+ Or use the included entrypoint:
57
+
58
+ ```bash
59
+ bundle exec ruby -Ilib bin/main /home/dnutiu/Documents/tranzactii_revolut.pdf
60
+ ```
61
+
62
+ Run the Revolut parser test with:
63
+
64
+ ```bash
65
+ ruby -Ilib:test test/revolut_rule_test.rb
66
+ ```
67
+
29
68
  email: dnutiu@nuculabs.dev
30
69
  executables: []
31
70
  extensions: []
@@ -45,6 +84,7 @@ licenses:
45
84
  - GPLv3
46
85
  metadata:
47
86
  source_code_uri: https://gitlab.nuculabs.dev/dnutiu/extras-de-cont
87
+ rubygems_mfa_required: 'true'
48
88
  rdoc_options: []
49
89
  require_paths:
50
90
  - lib
@@ -63,3 +103,4 @@ rubygems_version: 4.0.10
63
103
  specification_version: 4
64
104
  summary: A simple library which helps you extract transactions from a PDF bank statement.
65
105
  test_files: []
106
+ ...