iif-parser 1.1.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +14 -1
- data/README.md +13 -0
- data/Rakefile +5 -0
- data/iif-parser.gemspec +3 -3
- data/lib/iif/parser/version.rb +1 -1
- data/lib/iif/parser.rb +12 -1
- metadata +14 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ebf93f08ba013e95d2a6bf5d79cdf479d1182e2952a08aaaf8c740cd425a03f4
|
4
|
+
data.tar.gz: 76e734f908ea3e659800a3fb883d77c7c50beb7d0094a763afc014c2159545cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f201c8b90403b0d3b0ceb19f1b90fd16d5350efd54968a89750e642a27db17d1c29b8e8acfce3c3b3423c3eb45acd085a284c5deab007d003a79e03208fd24d
|
7
|
+
data.tar.gz: 945a5a3d2a88a751d00b71549c7b6bda8bbc479925e1f5fe8e038e407fcec655752206b1aad5d9c1353f06f04a55f124c195aff173451981bf291817798edaf0
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -44,6 +44,8 @@ puts i.transactions.first.entries
|
|
44
44
|
```
|
45
45
|
#### See the [specs](https://github.com/minimul/iif-parser/blob/master/spec/iif/parser_spec.rb) for more examples
|
46
46
|
|
47
|
+
#### Ruby support is >= 2.7
|
48
|
+
|
47
49
|
## Installation
|
48
50
|
Add this line to your application's Gemfile:
|
49
51
|
|
@@ -58,7 +60,18 @@ Non tab-delimited IIF files are parsed with `CSV.parse_line`. You can set option
|
|
58
60
|
iif_file = File.read(File.dirname(__FILE__) + "/../fixtures/liberal-parsing.iif")
|
59
61
|
iif_parser = Iif::Parser.new(iif_file, { csv_parse_line_options: { liberal_parsing: true } })
|
60
62
|
```
|
63
|
+
**OR**
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
options = { csv_parse_line_options: { converters: -> (f) { f ? f.strip : nil } } }
|
67
|
+
i = Iif::Parser.new(iif, options)
|
68
|
+
```
|
69
|
+
**OR COMBINE OPTIONS**
|
61
70
|
|
71
|
+
```ruby
|
72
|
+
options = { csv_parse_line_options: { liberal_parsing: true, converters: -> (f) { f ? f.strip : nil } } }
|
73
|
+
i = Iif::Parser.new(iif, options)
|
74
|
+
```
|
62
75
|
|
63
76
|
And then execute:
|
64
77
|
|
data/Rakefile
CHANGED
data/iif-parser.gemspec
CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.add_runtime_dependency "rchardet"
|
21
21
|
|
22
|
-
spec.add_development_dependency "rspec"
|
22
|
+
spec.add_development_dependency "rspec", ">= 3.4.4"
|
23
23
|
spec.add_development_dependency "awesome_print"
|
24
|
-
spec.add_development_dependency "bundler", "
|
25
|
-
spec.add_development_dependency "rake", "
|
24
|
+
spec.add_development_dependency "bundler", ">= 1.9"
|
25
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
26
26
|
end
|
data/lib/iif/parser/version.rb
CHANGED
data/lib/iif/parser.rb
CHANGED
@@ -70,7 +70,7 @@ module Iif
|
|
70
70
|
next unless definition and definition[idx]
|
71
71
|
entry.send(definition[idx] + "=", field)
|
72
72
|
end
|
73
|
-
entry.amount =
|
73
|
+
entry.amount = convert_amount(entry.amount) unless entry.amount.to_s == ""
|
74
74
|
entry.date = convert_date(entry.date) if entry.date and not entry.date == ""
|
75
75
|
@entries.push(entry)
|
76
76
|
end
|
@@ -88,6 +88,17 @@ module Iif
|
|
88
88
|
Date.new(year.to_i, ar[0], ar[1])
|
89
89
|
end
|
90
90
|
|
91
|
+
def convert_amount(amount)
|
92
|
+
amount.gsub!(/(,)/,'')
|
93
|
+
if amount =~ /^--/
|
94
|
+
amount.slice!(0)
|
95
|
+
elsif amount =~ /^\(.*\)$/
|
96
|
+
amount.gsub!(/[()]/,'')
|
97
|
+
amount.prepend("-")
|
98
|
+
end
|
99
|
+
BigDecimal(amount)
|
100
|
+
end
|
101
|
+
|
91
102
|
def create_transactions
|
92
103
|
transaction = nil
|
93
104
|
in_transaction = false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iif-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Pelczarski
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rchardet
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 3.4.4
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 3.4.4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: awesome_print
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,30 +56,30 @@ dependencies:
|
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.9'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.9'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 12.3.3
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 12.3.3
|
83
83
|
description: ''
|
84
84
|
email:
|
85
85
|
- christian@minimul.com
|
@@ -105,7 +105,7 @@ homepage: https://github.com/minimul/iif-parser
|
|
105
105
|
licenses:
|
106
106
|
- MIT
|
107
107
|
metadata: {}
|
108
|
-
post_install_message:
|
108
|
+
post_install_message:
|
109
109
|
rdoc_options: []
|
110
110
|
require_paths:
|
111
111
|
- lib
|
@@ -120,9 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
- !ruby/object:Gem::Version
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
|
-
|
124
|
-
|
125
|
-
signing_key:
|
123
|
+
rubygems_version: 3.1.6
|
124
|
+
signing_key:
|
126
125
|
specification_version: 4
|
127
126
|
summary: Basic IIF parser written in Ruby
|
128
127
|
test_files: []
|