nacha 0.1.6 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 782ae8de3e488c9404aab641bf27e71da0b9bc6d391d235dbec10fc8d750c27a
4
- data.tar.gz: 76e485087bcdd967c437912b1318bd79f21e50c1e9ed6eb3dbd73ea3233b86ec
3
+ metadata.gz: 8375798ff41c91e7a14ae4ebbf1442f7ceaf83ae7f61c81b1b88c87fd2ca4760
4
+ data.tar.gz: b35fa722059c4eab240896141868eb27cd2b17c5c17539b5281a5d2a71ccfb07
5
5
  SHA512:
6
- metadata.gz: 799751bb17453a1f28e7e0b362e7a06eb017445d5928c06e7130c15c6d7b6a6a427e2b96ecb05567fafc60107400c82e39e0c81799158f2d942af6839ba470b7
7
- data.tar.gz: adf86d5aa5302590c53c0333e3ea7a32c5e0e3ed255da5bf8812d0d2e853173e31b8cf12a7ba1602b9c0420f1aa52eedd9c54f7698f90ba11f0a399bd787bb42
6
+ metadata.gz: f5bd9637030e63e90ca54b3203a09341badba050d4b9351063e2ea6c2da743ecbf33539280e1b7fc03b44a93bfa90fb644ace1cd895a98ee473e7925ca0b0454
7
+ data.tar.gz: 49b0621426a2609b6f65b4385f159cd053cfd9e7dc6e294850b1bcf7b1c7c723f771d2487e494a9dee0c704c4d572e35f5441c8391ddf2b78460d4c7f2a55b77
data/CHANGELOG.md CHANGED
@@ -7,6 +7,13 @@ 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
+
10
17
  ## [0.1.6] - 2025-06-20
11
18
 
12
19
  - Better code coverage
data/lib/nacha/parser.rb CHANGED
@@ -4,7 +4,8 @@ require 'nacha'
4
4
  require 'nacha/parser_context'
5
5
 
6
6
  class Nacha::Parser
7
- DEFAULT_RECORD_TYPES = ['Nacha::Record::FileHeader'].freeze
7
+ DEFAULT_RECORD_TYPES = ['Nacha::Record::FileHeader',
8
+ 'Nacha::Record::Filler'].freeze
8
9
 
9
10
  attr_reader :context
10
11
 
@@ -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
- output_started = true
85
- Regexp.last_match(1)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nacha
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.7'
5
5
  end
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
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nacha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - David H. Wilkins