X12 0.0.5
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/CHANGELOG +13 -0
- data/COPYING +502 -0
- data/README +309 -0
- data/Rakefile +157 -0
- data/TODO +6 -0
- data/doc/classes/X12.html +174 -0
- data/doc/classes/X12/Base.html +677 -0
- data/doc/classes/X12/Composite.html +156 -0
- data/doc/classes/X12/Empty.html +186 -0
- data/doc/classes/X12/Field.html +339 -0
- data/doc/classes/X12/Loop.html +202 -0
- data/doc/classes/X12/Parser.html +306 -0
- data/doc/classes/X12/Segment.html +277 -0
- data/doc/classes/X12/Table.html +198 -0
- data/doc/created.rid +1 -0
- data/doc/files/CHANGELOG.html +108 -0
- data/doc/files/README.html +474 -0
- data/doc/files/TODO.html +95 -0
- data/doc/files/lib/X12/Base_rb.html +83 -0
- data/doc/files/lib/X12/Composite_rb.html +83 -0
- data/doc/files/lib/X12/Empty_rb.html +83 -0
- data/doc/files/lib/X12/Field_rb.html +83 -0
- data/doc/files/lib/X12/Loop_rb.html +83 -0
- data/doc/files/lib/X12/Parser_rb.html +83 -0
- data/doc/files/lib/X12/Segment_rb.html +83 -0
- data/doc/files/lib/X12/Table_rb.html +83 -0
- data/doc/files/lib/X12_rb.html +100 -0
- data/doc/fr_class_index.html +35 -0
- data/doc/fr_file_index.html +38 -0
- data/doc/fr_method_index.html +62 -0
- data/doc/index.html +27 -0
- data/doc/rdoc-style.css +208 -0
- data/example/factory.rb +92 -0
- data/example/parse.rb +56 -0
- data/lib/X12.rb +50 -0
- data/lib/X12/Base.rb +192 -0
- data/lib/X12/Composite.rb +37 -0
- data/lib/X12/Empty.rb +43 -0
- data/lib/X12/Field.rb +81 -0
- data/lib/X12/Loop.rb +74 -0
- data/lib/X12/Parser.rb +98 -0
- data/lib/X12/Segment.rb +92 -0
- data/lib/X12/Table.rb +44 -0
- data/lib/X12/x12syntax.treetop +256 -0
- data/misc/997.d12 +885 -0
- data/misc/rdoc_template.rb +697 -0
- data/test/tc_factory_997.rb +130 -0
- data/test/tc_parse_997.rb +146 -0
- data/test/ts_x12.rb +27 -0
- metadata +108 -0
@@ -0,0 +1,130 @@
|
|
1
|
+
#--
|
2
|
+
# This file is part of the X12Parser library that provides tools to
|
3
|
+
# manipulate X12 messages using Ruby native syntax.
|
4
|
+
#
|
5
|
+
# http://x12parser.rubyforge.org
|
6
|
+
#
|
7
|
+
# Copyright (C) 2008 APP Design, Inc.
|
8
|
+
#
|
9
|
+
# This library is free software; you can redistribute it and/or
|
10
|
+
# modify it under the terms of the GNU Lesser General Public
|
11
|
+
# License as published by the Free Software Foundation; either
|
12
|
+
# version 2.1 of the License, or (at your option) any later version.
|
13
|
+
#
|
14
|
+
# This library is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17
|
+
# Lesser General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU Lesser General Public
|
20
|
+
# License along with this library; if not, write to the Free Software
|
21
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
22
|
+
#++
|
23
|
+
#
|
24
|
+
require 'x12'
|
25
|
+
require 'test/unit'
|
26
|
+
|
27
|
+
class TestFactory < Test::Unit::TestCase
|
28
|
+
|
29
|
+
@@p = nil
|
30
|
+
RESULT=<<-EOT
|
31
|
+
ST*997*2878~
|
32
|
+
AK1*HS*293328532~
|
33
|
+
AK2*270*~
|
34
|
+
AK3*NM1**L1000D~
|
35
|
+
AK4***55*Bad element~
|
36
|
+
AK5*~
|
37
|
+
AK3*DMG*0*L1010*22~
|
38
|
+
AK4*0**0~
|
39
|
+
AK4*0**1~
|
40
|
+
AK4*1**0~
|
41
|
+
AK4*1**1~
|
42
|
+
AK5*666****999~
|
43
|
+
AK9****~
|
44
|
+
SE**~
|
45
|
+
EOT
|
46
|
+
|
47
|
+
@@result = RESULT.gsub!(/\n/,'')
|
48
|
+
TIMES = 1000
|
49
|
+
|
50
|
+
def setup
|
51
|
+
unless @@p
|
52
|
+
@@p = X12::Parser.new('misc/997.d12')
|
53
|
+
end
|
54
|
+
end # setup
|
55
|
+
|
56
|
+
def teardown
|
57
|
+
# Nothing
|
58
|
+
end # teardown
|
59
|
+
|
60
|
+
def test_all
|
61
|
+
@r = @@p.factory('997')
|
62
|
+
|
63
|
+
@r.ST.TransactionSetIdentifierCode = 997
|
64
|
+
@r.ST.TransactionSetControlNumber = '2878'
|
65
|
+
|
66
|
+
@r.AK1 { |ak1|
|
67
|
+
ak1.FunctionalIdentifierCode = 'HS'
|
68
|
+
ak1.GroupControlNumber = 293328532
|
69
|
+
}
|
70
|
+
|
71
|
+
@r.L1000.L1010.AK4.DataElementSyntaxErrorCode=55
|
72
|
+
@r.L1000.AK2.TransactionSetIdentifierCode = 270
|
73
|
+
@r.L1000.L1010 {|l|
|
74
|
+
l.AK3 {|s|
|
75
|
+
s.SegmentIdCode = 'NM1'
|
76
|
+
#SegmentPositionInTransactionSet
|
77
|
+
s.LoopIdentifierCode = 'L1000D'
|
78
|
+
#SegmentSyntaxErrorCode
|
79
|
+
}
|
80
|
+
|
81
|
+
l.AK4 {|s|
|
82
|
+
#s.PositionInSegment =
|
83
|
+
#s.DataElementReferenceNumber =
|
84
|
+
#s.DataElementSyntaxErrorCode =
|
85
|
+
s.CopyOfBadDataElement = 'Bad element'
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
# Should be two repeats in total
|
90
|
+
@r.L1000.repeat {|l1000|
|
91
|
+
(0..1).each {|loop_repeat| # Two repeats of the loop L1010
|
92
|
+
l1000.L1010.repeat {|l1010|
|
93
|
+
|
94
|
+
l1010.AK3 {|s|
|
95
|
+
s.SegmentIdCode = 'DMG'
|
96
|
+
s.SegmentPositionInTransactionSet = 0
|
97
|
+
s.LoopIdentifierCode = 'L1010'
|
98
|
+
s.SegmentSyntaxErrorCode = 22
|
99
|
+
} if loop_repeat == 0 # AK3 only in the first repeat of L1010
|
100
|
+
|
101
|
+
(0..1).each {|ak4_repeat| # Two repeats of the segment AK4
|
102
|
+
l1010.AK4.repeat {|s|
|
103
|
+
s.PositionInSegment = loop_repeat
|
104
|
+
#s.DataElementReferenceNumber =
|
105
|
+
s.DataElementSyntaxErrorCode = ak4_repeat
|
106
|
+
#s.CopyOfBadDataElement =
|
107
|
+
} # s
|
108
|
+
} # ak4_repeat
|
109
|
+
} # l1010
|
110
|
+
} # loop_repeat
|
111
|
+
|
112
|
+
l1000.AK5{|a|
|
113
|
+
a.TransactionSetAcknowledgmentCode = 666
|
114
|
+
a.TransactionSetSyntaxErrorCode4 = 999
|
115
|
+
} # a
|
116
|
+
} # l1000
|
117
|
+
|
118
|
+
assert_equal(@@result, @r.render)
|
119
|
+
end # test_all
|
120
|
+
|
121
|
+
def test_timing
|
122
|
+
start = Time::now
|
123
|
+
TIMES.times do
|
124
|
+
test_all
|
125
|
+
end
|
126
|
+
finish = Time::now
|
127
|
+
puts "Factories per second: #{TIMES.to_f/(finish-start)}, elapsed: #{finish-start}"
|
128
|
+
end # test_timing
|
129
|
+
|
130
|
+
end # TestList
|
@@ -0,0 +1,146 @@
|
|
1
|
+
#--
|
2
|
+
# This file is part of the X12Parser library that provides tools to
|
3
|
+
# manipulate X12 messages using Ruby native syntax.
|
4
|
+
#
|
5
|
+
# http://x12parser.rubyforge.org
|
6
|
+
#
|
7
|
+
# Copyright (C) 2008 APP Design, Inc.
|
8
|
+
#
|
9
|
+
# This library is free software; you can redistribute it and/or
|
10
|
+
# modify it under the terms of the GNU Lesser General Public
|
11
|
+
# License as published by the Free Software Foundation; either
|
12
|
+
# version 2.1 of the License, or (at your option) any later version.
|
13
|
+
#
|
14
|
+
# This library is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17
|
+
# Lesser General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU Lesser General Public
|
20
|
+
# License along with this library; if not, write to the Free Software
|
21
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
22
|
+
#++
|
23
|
+
#
|
24
|
+
require 'x12'
|
25
|
+
require 'test/unit'
|
26
|
+
|
27
|
+
class TestParse < Test::Unit::TestCase
|
28
|
+
|
29
|
+
@@p = nil
|
30
|
+
@@parser = X12::Parser.new('misc/997.d12')
|
31
|
+
TIMES = 1000
|
32
|
+
|
33
|
+
def setup
|
34
|
+
unless @@p
|
35
|
+
@@m997=<<-EOT
|
36
|
+
ST*997*2878~
|
37
|
+
AK1*HS*293328532~
|
38
|
+
AK2*270*307272179~
|
39
|
+
AK3*NM1*8*L1010_0*8~
|
40
|
+
AK4*0:0*66*1~
|
41
|
+
AK4*0:1*66*1~
|
42
|
+
AK4*0:2*66*1~
|
43
|
+
AK3*NM1*8*L1010_1*8~
|
44
|
+
AK4*1:0*66*1~
|
45
|
+
AK4*1:1*66*1~
|
46
|
+
AK3*NM1*8*L1010_2*8~
|
47
|
+
AK4*2:0*66*1~
|
48
|
+
AK5*R*5~
|
49
|
+
AK9*R*1*1*0~
|
50
|
+
SE*8*2878~
|
51
|
+
EOT
|
52
|
+
|
53
|
+
# This should parse into
|
54
|
+
# 997 [0]: ST*997*2878~AK1*HS*293328532~A...AK5*R*5~AK9*R*1*1*0~SE*8*2878~
|
55
|
+
# ST [0]: ST*997*2878~
|
56
|
+
# AK1 [0]: AK1*HS*293328532~
|
57
|
+
# L1000 [0]: AK2*270*307272179~AK3*NM1*8*L1...1010_2*8~AK4*2:0*66*1~AK5*R*5~
|
58
|
+
# AK2 [0]: AK2*270*307272179~
|
59
|
+
# L1010 [0]: AK3*NM1*8*L1010_0*8~AK4*0:0*66*1~AK4*0:1*66*1~AK4*0:2*66*1~
|
60
|
+
# AK3 [0]: AK3*NM1*8*L1010_0*8~
|
61
|
+
# AK4 [0]: AK4*0:0*66*1~
|
62
|
+
# AK4 [1]: AK4*0:1*66*1~
|
63
|
+
# AK4 [2]: AK4*0:2*66*1~
|
64
|
+
# L1010 [1]: AK3*NM1*8*L1010_1*8~AK4*1:0*66*1~AK4*1:1*66*1~
|
65
|
+
# AK3 [0]: AK3*NM1*8*L1010_1*8~
|
66
|
+
# AK4 [0]: AK4*1:0*66*1~
|
67
|
+
# AK4 [1]: AK4*1:1*66*1~
|
68
|
+
# L1010 [2]: AK3*NM1*8*L1010_2*8~AK4*2:0*66*1~
|
69
|
+
# AK3 [0]: AK3*NM1*8*L1010_2*8~
|
70
|
+
# AK4 [0]: AK4*2:0*66*1~
|
71
|
+
# AK5 [0]: AK5*R*5~
|
72
|
+
# AK9 [0]: AK9*R*1*1*0~
|
73
|
+
# SE [0]: SE*8*2878~
|
74
|
+
|
75
|
+
@@m997.gsub!(/\n/,'')
|
76
|
+
|
77
|
+
@@p = @@parser.parse('997', @@m997)
|
78
|
+
end
|
79
|
+
@r = @@p
|
80
|
+
end # setup
|
81
|
+
|
82
|
+
def teardown
|
83
|
+
# Nothing
|
84
|
+
end # teardown
|
85
|
+
|
86
|
+
def test_ST
|
87
|
+
assert_equal('ST*997*2878~', @r.ST.to_s)
|
88
|
+
assert_equal('997', @r.ST.TransactionSetIdentifierCode)
|
89
|
+
end # test_ST
|
90
|
+
|
91
|
+
def test_AK1
|
92
|
+
assert_equal('293328532', @r.AK1.GroupControlNumber)
|
93
|
+
end # test_AK1
|
94
|
+
|
95
|
+
def test_AK2
|
96
|
+
assert_equal('270', @r.L1000.AK2.TransactionSetIdentifierCode)
|
97
|
+
end # test_AK2
|
98
|
+
|
99
|
+
def test_L1010
|
100
|
+
assert_match(/L1010_0/, @r.L1000.L1010.to_s)
|
101
|
+
assert_equal(3, @r.L1000.L1010.to_a.size)
|
102
|
+
assert_equal(3, @r.L1000.L1010.size)
|
103
|
+
assert_match(/L1010_2/, @r.L1000.L1010.to_a[2].to_s)
|
104
|
+
assert_match(/L1010_2/, @r.L1000.L1010[2].to_s)
|
105
|
+
end # test_L1010
|
106
|
+
|
107
|
+
def test_AK4
|
108
|
+
assert_equal('AK4*1:0*66*1~', @r.L1000.L1010.to_a[1].AK4.to_s)
|
109
|
+
assert_equal('AK4*1:0*66*1~', @r.L1000.L1010[1].AK4.to_s)
|
110
|
+
assert_equal(3, @r.L1000.L1010.AK4.to_a.size)
|
111
|
+
assert_equal(3, @r.L1000.L1010.AK4.size)
|
112
|
+
assert_equal(2, @r.L1000.L1010.to_a[1].AK4.to_a.size)
|
113
|
+
assert_equal(2, @r.L1000.L1010[1].AK4.size)
|
114
|
+
assert_equal('AK4*1:1*66*1~', @r.L1000.L1010.to_a[1].AK4.to_a[1].to_s)
|
115
|
+
assert_equal('AK4*1:1*66*1~', @r.L1000.L1010[1].AK4[1].to_s)
|
116
|
+
assert_equal('66', @r.L1000.L1010.AK4.DataElementReferenceNumber)
|
117
|
+
end # test_AK4
|
118
|
+
|
119
|
+
def test_absent
|
120
|
+
assert_equal(X12::EMPTY, @r.L1000.AK8.TransactionSetIdentifierCode)
|
121
|
+
assert_equal(X12::EMPTY, @r.L1000.L1111)
|
122
|
+
assert_equal(X12::EMPTY, @r.L1000.L1111.L2222)
|
123
|
+
assert_equal(X12::EMPTY, @r.L1000.L1111.L2222.AFAFA)
|
124
|
+
assert_equal(X12::EMPTY, @r.L1000.L1010[-99])
|
125
|
+
assert_equal(X12::EMPTY, @r.L1000.L1010[99])
|
126
|
+
assert_equal(X12::EMPTY, @r.L1000.L1010[99].AK4)
|
127
|
+
|
128
|
+
assert_equal('', @r.L1000.AK8.TransactionSetIdentifierCode.to_s)
|
129
|
+
end # test_absent
|
130
|
+
|
131
|
+
def test_timing
|
132
|
+
start = Time::now
|
133
|
+
TIMES.times do
|
134
|
+
@r = @@parser.parse('997', @@m997)
|
135
|
+
test_ST
|
136
|
+
test_AK1
|
137
|
+
test_AK2
|
138
|
+
test_AK4
|
139
|
+
test_L1010
|
140
|
+
test_absent
|
141
|
+
end
|
142
|
+
finish = Time::now
|
143
|
+
puts "Parses per second: #{TIMES.to_f/(finish-start)}, elapsed: #{finish-start}"
|
144
|
+
end # test_timing
|
145
|
+
|
146
|
+
end # TestList
|
data/test/ts_x12.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#--
|
2
|
+
# This file is part of the X12Parser library that provides tools to
|
3
|
+
# manipulate X12 messages using Ruby native syntax.
|
4
|
+
#
|
5
|
+
# http://x12parser.rubyforge.org
|
6
|
+
#
|
7
|
+
# Copyright (C) 2008 APP Design, Inc.
|
8
|
+
#
|
9
|
+
# This library is free software; you can redistribute it and/or
|
10
|
+
# modify it under the terms of the GNU Lesser General Public
|
11
|
+
# License as published by the Free Software Foundation; either
|
12
|
+
# version 2.1 of the License, or (at your option) any later version.
|
13
|
+
#
|
14
|
+
# This library is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17
|
+
# Lesser General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU Lesser General Public
|
20
|
+
# License along with this library; if not, write to the Free Software
|
21
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
22
|
+
#++
|
23
|
+
#
|
24
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
25
|
+
|
26
|
+
require 'tc_parse_997'
|
27
|
+
require 'tc_factory_997'
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.4
|
3
|
+
specification_version: 1
|
4
|
+
name: X12
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.5
|
7
|
+
date: 2008-11-13 00:00:00 -06:00
|
8
|
+
summary: X12 parsing and generation library
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: info@appdesign.com
|
12
|
+
homepage: http://www.appdesign.com
|
13
|
+
rubyforge_project: X12
|
14
|
+
description: Library to parse X12 messages and manipulate their loops, segments, fields, composites, and validation tables.
|
15
|
+
autorequire: x12
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- APP Design, Inc.
|
31
|
+
files:
|
32
|
+
- Rakefile
|
33
|
+
- README
|
34
|
+
- TODO
|
35
|
+
- CHANGELOG
|
36
|
+
- COPYING
|
37
|
+
- doc/classes
|
38
|
+
- doc/classes/X12
|
39
|
+
- doc/classes/X12/Base.html
|
40
|
+
- doc/classes/X12/Composite.html
|
41
|
+
- doc/classes/X12/Empty.html
|
42
|
+
- doc/classes/X12/Field.html
|
43
|
+
- doc/classes/X12/Loop.html
|
44
|
+
- doc/classes/X12/Parser.html
|
45
|
+
- doc/classes/X12/Segment.html
|
46
|
+
- doc/classes/X12/Table.html
|
47
|
+
- doc/classes/X12.html
|
48
|
+
- doc/created.rid
|
49
|
+
- doc/files
|
50
|
+
- doc/files/CHANGELOG.html
|
51
|
+
- doc/files/lib
|
52
|
+
- doc/files/lib/X12
|
53
|
+
- doc/files/lib/X12/Base_rb.html
|
54
|
+
- doc/files/lib/X12/Composite_rb.html
|
55
|
+
- doc/files/lib/X12/Empty_rb.html
|
56
|
+
- doc/files/lib/X12/Field_rb.html
|
57
|
+
- doc/files/lib/X12/Loop_rb.html
|
58
|
+
- doc/files/lib/X12/Parser_rb.html
|
59
|
+
- doc/files/lib/X12/Segment_rb.html
|
60
|
+
- doc/files/lib/X12/Table_rb.html
|
61
|
+
- doc/files/lib/X12_rb.html
|
62
|
+
- doc/files/README.html
|
63
|
+
- doc/files/TODO.html
|
64
|
+
- doc/fr_class_index.html
|
65
|
+
- doc/fr_file_index.html
|
66
|
+
- doc/fr_method_index.html
|
67
|
+
- doc/index.html
|
68
|
+
- doc/rdoc-style.css
|
69
|
+
- lib/X12
|
70
|
+
- lib/X12/Base.rb
|
71
|
+
- lib/X12/Composite.rb
|
72
|
+
- lib/X12/Empty.rb
|
73
|
+
- lib/X12/Field.rb
|
74
|
+
- lib/X12/Loop.rb
|
75
|
+
- lib/X12/Parser.rb
|
76
|
+
- lib/X12/Segment.rb
|
77
|
+
- lib/X12/Table.rb
|
78
|
+
- lib/X12/x12syntax.treetop
|
79
|
+
- lib/X12.rb
|
80
|
+
- test/tc_factory_997.rb
|
81
|
+
- test/tc_parse_997.rb
|
82
|
+
- test/ts_x12.rb
|
83
|
+
- example/factory.rb
|
84
|
+
- example/parse.rb
|
85
|
+
- misc/997.d12
|
86
|
+
- misc/rdoc_template.rb
|
87
|
+
test_files:
|
88
|
+
- test/ts_x12.rb
|
89
|
+
rdoc_options: []
|
90
|
+
|
91
|
+
extra_rdoc_files: []
|
92
|
+
|
93
|
+
executables: []
|
94
|
+
|
95
|
+
extensions: []
|
96
|
+
|
97
|
+
requirements:
|
98
|
+
- none
|
99
|
+
dependencies:
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: treetop
|
102
|
+
version_requirement:
|
103
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">"
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: 0.0.0
|
108
|
+
version:
|