nacha 0.1.5 → 0.1.7
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 +4 -4
- data/CHANGELOG.md +16 -0
- data/lib/nacha/ach_date.rb +1 -1
- data/lib/nacha/numeric.rb +5 -7
- data/lib/nacha/parser.rb +2 -1
- data/lib/nacha/parser_context.rb +1 -1
- data/lib/nacha/record/base.rb +11 -5
- data/lib/nacha/version.rb +1 -1
- data/lib/nacha.rb +21 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8375798ff41c91e7a14ae4ebbf1442f7ceaf83ae7f61c81b1b88c87fd2ca4760
|
4
|
+
data.tar.gz: b35fa722059c4eab240896141868eb27cd2b17c5c17539b5281a5d2a71ccfb07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5bd9637030e63e90ca54b3203a09341badba050d4b9351063e2ea6c2da743ecbf33539280e1b7fc03b44a93bfa90fb644ace1cd895a98ee473e7925ca0b0454
|
7
|
+
data.tar.gz: 49b0621426a2609b6f65b4385f159cd053cfd9e7dc6e294850b1bcf7b1c7c723f771d2487e494a9dee0c704c4d572e35f5441c8391ddf2b78460d4c7f2a55b77
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [0.1.7] - 2025-06-23
|
11
|
+
|
12
|
+
- Better parsing. Nacha::Record::FileControl had issues parsing if the reserved
|
13
|
+
part of the record was stripped off. Since the reserved part of the record is
|
14
|
+
all spaces, it can safely be missing.
|
15
|
+
|
16
|
+
|
17
|
+
## [0.1.6] - 2025-06-20
|
18
|
+
|
19
|
+
- Better code coverage
|
20
|
+
|
21
|
+
- fixed an issue with jruby running tests
|
22
|
+
|
23
|
+
- Bump version to 0.1.6
|
24
|
+
|
25
|
+
|
10
26
|
## [0.1.5] - 2025-06-18
|
11
27
|
|
12
28
|
### Fixed
|
data/lib/nacha/ach_date.rb
CHANGED
@@ -36,7 +36,7 @@ class Nacha::AchDate < Date
|
|
36
36
|
# This works because `Date.new` is designed to be effectively `allocate.initialize`.
|
37
37
|
super(year, month, day)
|
38
38
|
|
39
|
-
rescue ArgumentError => e
|
39
|
+
rescue TypeError, ArgumentError => e
|
40
40
|
# Catch errors that might arise from strptime or invalid date components
|
41
41
|
raise ArgumentError, "Invalid date format for Nacha::AchDate: #{args.inspect}. Original error: #{e.message}"
|
42
42
|
end
|
data/lib/nacha/numeric.rb
CHANGED
@@ -5,14 +5,12 @@ class Nacha::Numeric
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def to_i
|
8
|
-
if @value
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
@value.to_i
|
13
|
-
end
|
8
|
+
return 0 if @value.nil?
|
9
|
+
|
10
|
+
if @value.is_a?(String) && @value.match(/\A *\z/)
|
11
|
+
@value # blank strings should return as blank
|
14
12
|
else
|
15
|
-
|
13
|
+
@value.to_i
|
16
14
|
end
|
17
15
|
end
|
18
16
|
|
data/lib/nacha/parser.rb
CHANGED
data/lib/nacha/parser_context.rb
CHANGED
@@ -11,7 +11,7 @@ class Nacha::ParserContext
|
|
11
11
|
attr_accessor :previous_record
|
12
12
|
attr_reader :validated
|
13
13
|
|
14
|
-
def initialize
|
14
|
+
def initialize(opts = {})
|
15
15
|
@file_name = opts[:file_name] || ''
|
16
16
|
@line_number = opts[:line_number] || 0
|
17
17
|
@line_length = opts[:line_length] || 0
|
data/lib/nacha/record/base.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'json'
|
4
4
|
require 'nacha/field'
|
5
5
|
require 'nacha/record/validations/field_validations'
|
6
|
-
|
6
|
+
|
7
7
|
module Nacha
|
8
8
|
module Record
|
9
9
|
class Base
|
@@ -29,8 +29,6 @@ module Nacha
|
|
29
29
|
end
|
30
30
|
|
31
31
|
class << self
|
32
|
-
attr_reader :nacha_record_name
|
33
|
-
|
34
32
|
def nacha_field(name, inclusion:, contents:, position:)
|
35
33
|
definition[name] = { inclusion: inclusion,
|
36
34
|
contents: contents,
|
@@ -41,7 +39,9 @@ module Nacha
|
|
41
39
|
|
42
40
|
validations[name] ||= []
|
43
41
|
validations[name] << validation_method
|
42
|
+
Nacha.add_ach_record_type(self)
|
44
43
|
end
|
44
|
+
|
45
45
|
def definition
|
46
46
|
@definition ||= {}
|
47
47
|
end
|
@@ -81,8 +81,14 @@ module Nacha
|
|
81
81
|
@matcher ||=
|
82
82
|
Regexp.new('\A' + definition.values.reverse.collect do |d|
|
83
83
|
if d[:contents] =~ /\AC(.+)\z/
|
84
|
-
|
85
|
-
|
84
|
+
last_match = Regexp.last_match(1)
|
85
|
+
if last_match =~ /\A *\z/
|
86
|
+
skipped_output = true
|
87
|
+
''
|
88
|
+
else
|
89
|
+
output_started = true
|
90
|
+
last_match
|
91
|
+
end
|
86
92
|
elsif d[:contents] =~ /\ANumeric\z/
|
87
93
|
if output_started
|
88
94
|
'[0-9 ]' + "{#{(d[:position] || d['position']).size}}"
|
data/lib/nacha/version.rb
CHANGED
data/lib/nacha.rb
CHANGED
@@ -7,16 +7,6 @@ require 'nacha/ach_date'
|
|
7
7
|
require 'nacha/field'
|
8
8
|
require 'nacha/numeric'
|
9
9
|
|
10
|
-
Gem.find_files('nacha/record/*.rb').reject{|f| f =~ /\/spec\//}.each do |file|
|
11
|
-
require File.expand_path(file)
|
12
|
-
end
|
13
|
-
|
14
|
-
Gem.find_files('nacha/record/**/*.rb').reject{|f| f =~ /\/spec\//}.each do |file|
|
15
|
-
require File.expand_path(file)
|
16
|
-
end
|
17
|
-
|
18
|
-
require 'nacha/parser'
|
19
|
-
|
20
10
|
module Nacha
|
21
11
|
STANDARD_ENTRY_CLASS_CODES = %w[ACK ADV ARC ATX BOC CCD PPD CIE
|
22
12
|
COR CTX DNE ENR IAT POP POS SHR
|
@@ -30,6 +20,16 @@ module Nacha
|
|
30
20
|
48 49 55 56 82 84 86 88].freeze
|
31
21
|
|
32
22
|
TRANSACTION_CODES = (CREDIT_TRANSACTION_CODES + DEBIT_TRANSACTION_CODES).freeze
|
23
|
+
@@ach_record_types = []
|
24
|
+
|
25
|
+
def self.add_ach_record_type(klass)
|
26
|
+
@@ach_record_types << klass unless @@ach_record_types.include?(klass)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.ach_record_types
|
30
|
+
@@ach_record_types
|
31
|
+
end
|
32
|
+
|
33
33
|
class << self
|
34
34
|
def parse(object)
|
35
35
|
parser = Nacha::Parser.new
|
@@ -53,3 +53,14 @@ module Nacha
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
57
|
+
Gem.find_files('nacha/record/*.rb').reject{|f| f =~ /\/spec\//}.each do |file|
|
58
|
+
require File.expand_path(file)
|
59
|
+
end
|
60
|
+
|
61
|
+
Gem.find_files('nacha/record/**/*.rb').reject{|f| f =~ /\/spec\//}.each do |file|
|
62
|
+
require File.expand_path(file)
|
63
|
+
end
|
64
|
+
|
65
|
+
require 'nacha/parser'
|
66
|
+
|