ach 0.4.2 → 0.4.3
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.
- data/examples/ach/batch_example.rb +6 -0
- data/lib/ach.rb +2 -1
- data/lib/ach/ach_file.rb +1 -1
- data/lib/ach/field_identifiers.rb +20 -3
- data/lib/ach/version.rb +1 -1
- metadata +4 -4
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require 'example_helper'
|
2
3
|
|
3
4
|
describe ACH::Batch do
|
@@ -119,5 +120,10 @@ describe ACH::Batch do
|
|
119
120
|
@credit.individual_name = "Employee Name That Is Much Too Long"
|
120
121
|
@credit.individual_name_to_ach.should == "Employee Name That Is "
|
121
122
|
end
|
123
|
+
|
124
|
+
it 'should strip non ascii characters' do
|
125
|
+
@credit.individual_name = "Jacob Møller"
|
126
|
+
@credit.individual_name_to_ach.should == "Jacob Mller "
|
127
|
+
end
|
122
128
|
end
|
123
129
|
end
|
data/lib/ach.rb
CHANGED
@@ -23,9 +23,11 @@ module ACH
|
|
23
23
|
end
|
24
24
|
|
25
25
|
require 'time'
|
26
|
+
require 'iconv' if RUBY_VERSION < '1.9'
|
26
27
|
require 'ach/field_identifiers'
|
27
28
|
require 'ach/ach_file'
|
28
29
|
require 'ach/batch'
|
30
|
+
require 'ach/version'
|
29
31
|
|
30
32
|
# Require records files
|
31
33
|
require 'ach/records/record'
|
@@ -36,6 +38,5 @@ end
|
|
36
38
|
|
37
39
|
# Include Records module to simplify accessing Records classes.
|
38
40
|
module ACH
|
39
|
-
VERSION = '0.4.2'
|
40
41
|
include Records
|
41
42
|
end
|
data/lib/ach/ach_file.rb
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
module ACH
|
2
2
|
module FieldIdentifiers
|
3
|
+
|
4
|
+
# these are used to convert non ascii characters to UTF-8
|
5
|
+
|
6
|
+
ENCODING_OPTIONS = {
|
7
|
+
:invalid => :replace, # Replace invalid byte sequences
|
8
|
+
:undef => :replace, # Replace anything not defined in ASCII
|
9
|
+
:replace => '', # Use a blank for those replacements
|
10
|
+
}
|
11
|
+
|
3
12
|
# NOTE: the msg parameter is unused and should be removed when the API can change
|
4
13
|
def field(name, klass, stringify = nil, default = nil, validate = nil, msg ='')
|
5
14
|
fields << name
|
@@ -38,10 +47,18 @@ module ACH
|
|
38
47
|
end
|
39
48
|
end
|
40
49
|
|
41
|
-
if
|
42
|
-
|
43
|
-
|
50
|
+
if val.kind_of?(String)
|
51
|
+
if RUBY_VERSION < '1.9'
|
52
|
+
val = Iconv.conv('ASCII//IGNORE', 'UTF8', val)
|
53
|
+
else
|
54
|
+
val = val.encode Encoding.find('ASCII'), ENCODING_OPTIONS
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
if stringify
|
44
59
|
stringify.call(val)
|
60
|
+
else
|
61
|
+
val
|
45
62
|
end
|
46
63
|
end
|
47
64
|
end
|
data/lib/ach/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ach
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-01-
|
13
|
+
date: 2013-01-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: micronaut
|
17
|
-
requirement: &
|
17
|
+
requirement: &72084880 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *72084880
|
26
26
|
description: ach is a Ruby helper for building and parsing ACH files. In particular,
|
27
27
|
it helps with field order and alignment, and adds padding lines to end of file.
|
28
28
|
email: jmorgan@morgancreative.net
|