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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c263ac1b849fc88d62de1fa8e01fc3e7afbe5277c9ec96bb8317f00a587ce46
4
- data.tar.gz: b194ada2fd9a5075279e6dd316f34dfec6ba263554920f2d72460174cd9e938c
3
+ metadata.gz: 8375798ff41c91e7a14ae4ebbf1442f7ceaf83ae7f61c81b1b88c87fd2ca4760
4
+ data.tar.gz: b35fa722059c4eab240896141868eb27cd2b17c5c17539b5281a5d2a71ccfb07
5
5
  SHA512:
6
- metadata.gz: 48818fd3a324f8def81109f5306331c864564d32502a1cf0e98cf2656cf966eab29a7ce6442c176b7c493570fa54c1119e181b7d2a917170a71fd9df1d17299f
7
- data.tar.gz: ea4ad06ae76ff311a856c3c24fb448c9f190d51806d039269984b7bf66fed21965b0e071b2c9864a19dc63da6a36ecd5bc8d9204db40a6d1ec470ac9a582f669
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
@@ -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
- if @value.is_a?(String) && @value.match(/\A *\z/)
10
- @value # blank strings should return as blank
11
- else
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
- self
13
+ @value.to_i
16
14
  end
17
15
  end
18
16
 
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
 
@@ -11,7 +11,7 @@ class Nacha::ParserContext
11
11
  attr_accessor :previous_record
12
12
  attr_reader :validated
13
13
 
14
- def initialize (opts = {})
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
@@ -3,7 +3,7 @@
3
3
  require 'json'
4
4
  require 'nacha/field'
5
5
  require 'nacha/record/validations/field_validations'
6
- require 'byebug'
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
- 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.5'
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.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - David H. Wilkins