paxmex 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb3b2c57e588061f78854c40bde2df60edb87920
4
- data.tar.gz: f9db52e77a355287c46c88f10a0d20908739cd29
3
+ metadata.gz: 873f859a60a234be55dfd8e57e8d8ce52806465e
4
+ data.tar.gz: 14ad88336ee18973abbba8abc6b07a89b06ab349
5
5
  SHA512:
6
- metadata.gz: c367931ad09b533e2da9ef65cfab76251ddcb8c33584bbda29aca5af4d44eba49dd826e6d8896e0b061db62f459d028d617f46fcdfb1b9ad2e91e98f9c697bf3
7
- data.tar.gz: 63614d95ec55c31ab7d81fd9f60206e2cdffc52d572c225cc91823983b3c2b112eaf89c9959a910347f9b012a932c15498be66d8fb39b99fb6c5be35a3e2b32e
6
+ metadata.gz: cc895ad6ce66301ce496350b4f495cc9b20bb2c5c8d02f9dc2c990f4246f3a7412bda3e9ff4ed7bf8ff01300c6717e484c12caf1b1380d358e61ceafec6384c0
7
+ data.tar.gz: 670b609085c611796b57de80e953426487c52e74746348f1c573e801ba88467aadafc9ae7239e7a9962492b17d603a58db2ae19964a384f1957f6f1e136af81e
data/config/cbnot.yml ADDED
@@ -0,0 +1,278 @@
1
+ DATA_FILE_HEADER_RECORD:
2
+ FIELDS:
3
+ - NAME: REC_TYPE
4
+ RANGE: [0, 0]
5
+ - NAME: AMEX_APPL_AREA
6
+ RANGE: [1, 100]
7
+ - NAME: SAID
8
+ RANGE: [101, 106]
9
+ - NAME: DATATYPE
10
+ RANGE: [107, 111]
11
+ - NAME: CCYYDDD
12
+ RANGE: [112, 118]
13
+ TYPE: julian
14
+ - NAME: 0HHMMSS
15
+ RANGE: [119, 125]
16
+ TYPE: numeric
17
+ CHARGEBACK_DETAIL_RECORD:
18
+ RECURRING: true
19
+ FIELDS:
20
+ - NAME: REC_TYPE
21
+ RANGE: [0, 0]
22
+ - NAME: SE_NUMB
23
+ RANGE: [6, 15]
24
+ - NAME: CM_ACCT_NUMB
25
+ RANGE: [26, 44]
26
+ - NAME: CURRENT_CASE_NUMBER
27
+ RANGE: [46, 56]
28
+ - NAME: CURRENT_ACTION_NUMBER
29
+ RANGE: [57, 58]
30
+ - NAME: PREVIOUS_CASE_NUMBER
31
+ RANGE: [59, 69]
32
+ - NAME: PREVIOUS_ACTION_NUMBER
33
+ RANGE: [70, 71]
34
+ - NAME: RESOLUTION
35
+ RANGE: [72, 72]
36
+ - NAME: FROM_SYSTEM
37
+ RANGE: [73, 73]
38
+ - NAME: REJECTS_TO_SYSTEM
39
+ RANGE: [74, 74]
40
+ - NAME: DISPUTES_TO_SYSTEM
41
+ RANGE: [75, 75]
42
+ - NAME: DATE_OF_ADJUSTMENT
43
+ RANGE: [76, 83]
44
+ TYPE: date(%Y%m%d)
45
+ - NAME: DATE_OF_CHARGE
46
+ RANGE: [84, 91]
47
+ TYPE: date(%Y%m%d)
48
+ - NAME: AMEX_ID
49
+ RANGE: [92, 98]
50
+ - NAME: CASE_TYPE
51
+ RANGE: [104, 109]
52
+ - NAME: LOC_NUMB
53
+ RANGE: [110, 124]
54
+ - NAME: CB_REAS_CODE
55
+ RANGE: [125, 127]
56
+ - NAME: CB_AMOUNT
57
+ RANGE: [128, 144]
58
+ TYPE: numeric
59
+ - NAME: CB_ADJUSTMENT_NUMBER
60
+ RANGE: [145, 150]
61
+ - NAME: CB_RESOLUTION_ADJ_NUMBER
62
+ RANGE: [151, 156]
63
+ - NAME: CB_REFERENCE_CODE
64
+ RANGE: [157, 168]
65
+ - NAME: BILLED_AMOUNT
66
+ RANGE: [182, 198]
67
+ TYPE: numeric
68
+ - NAME: SOC_AMOUNT
69
+ RANGE: [199, 215]
70
+ TYPE: numeric
71
+ - NAME: SOC_INVOICE_NUMBER
72
+ RANGE: [216, 221]
73
+ - NAME: ROC_INVOICE_NUMBER
74
+ RANGE: [222, 227]
75
+ - NAME: FOREIGN_AMT
76
+ RANGE: [228, 242]
77
+ - NAME: CURRENCY
78
+ RANGE: [243, 245]
79
+ - NAME: SUPP_TO_FOLLOW
80
+ RANGE: [246, 246]
81
+ - NAME: CM_NAME1
82
+ RANGE: [247, 276]
83
+ - NAME: CM_NAME2
84
+ RANGE: [277, 306]
85
+ - NAME: CM_ADDR1
86
+ RANGE: [307, 336]
87
+ - NAME: CM_ADDR2
88
+ RANGE: [337, 366]
89
+ - NAME: CM_CITY_STATE
90
+ RANGE: [367, 396]
91
+ - NAME: CM_ZIP
92
+ RANGE: [397, 405]
93
+ - NAME: CM_FIRST_NAME_1
94
+ RANGE: [406, 417]
95
+ - NAME: CM_MIDDLE_NAME_1
96
+ RANGE: [418, 429]
97
+ - NAME: CM_LAST_NAME_1
98
+ RANGE: [430, 449]
99
+ - NAME: CM_ORIG_ACCT_NUM
100
+ RANGE: [450, 464]
101
+ - NAME: CM_ORIG_NAME
102
+ RANGE: [465, 494]
103
+ - NAME: CM_ORIG_FIRST_NAME
104
+ RANGE: [495, 506]
105
+ - NAME: CM_ORIG_MIDDLE_NAME
106
+ RANGE: [507, 518]
107
+ - NAME: CM_ORIG_LAST_NAME
108
+ RANGE: [519, 538]
109
+ - NAME: NOTE1
110
+ RANGE: [539, 604]
111
+ - NAME: NOTE2
112
+ RANGE: [605, 682]
113
+ - NAME: NOTE3
114
+ RANGE: [683, 742]
115
+ - NAME: NOTE4
116
+ RANGE: [743, 802]
117
+ - NAME: NOTE5
118
+ RANGE: [803, 862]
119
+ - NAME: NOTE6
120
+ RANGE: [863, 922]
121
+ - NAME: NOTE7
122
+ RANGE: [923, 982]
123
+ - NAME: TRIUMPH_SEQ_NO
124
+ RANGE: [983, 984]
125
+ - NAME: AIRLINE_TKT_NUM
126
+ RANGE: [1030, 1043]
127
+ - NAME: AL_SEQUENCE_NUMBER
128
+ RANGE: [1044, 1045]
129
+ - NAME: FOLIO_REF
130
+ RANGE: [1046, 1063]
131
+ - NAME: MERCH_ORDER_NUM
132
+ RANGE: [1064, 1073]
133
+ - NAME: MERCH_ORDER_DATE
134
+ RANGE: [1074, 1081]
135
+ TYPE: date(%Y%m%d)
136
+ - NAME: CANC_NUM
137
+ RANGE: [1082, 1101]
138
+ - NAME: CANC_DATE
139
+ RANGE: [1102, 1109]
140
+ TYPE: date(%Y%m%d)
141
+ - NAME: FINCAP_TRACKING_ID
142
+ RANGE: [1110, 1120]
143
+ - NAME: FINCAP_FILE_SEQ_NUM
144
+ RANGE: [1121, 1126]
145
+ - NAME: FINCAP_BATCH_NUMBER
146
+ RANGE: [1127, 1130]
147
+ - NAME: FINCAP_BATCH_INVOICE_DT
148
+ RANGE: [1131, 1138]
149
+ TYPE: date(%Y%m%d)
150
+ - NAME: LABEL1
151
+ RANGE: [1139, 1163]
152
+ - NAME: DATA1
153
+ RANGE: [1164, 1188]
154
+ - NAME: LABEL2
155
+ RANGE: [1189, 1213]
156
+ - NAME: DATA2
157
+ RANGE: [1214, 1238]
158
+ - NAME: LABEL3
159
+ RANGE: [1239, 1263]
160
+ - NAME: DATA3
161
+ RANGE: [1264, 1288]
162
+ - NAME: LABEL4
163
+ RANGE: [1289, 1313]
164
+ - NAME: DATA4
165
+ RANGE: [1314, 1338]
166
+ - NAME: LABEL5
167
+ RANGE: [1339, 1363]
168
+ - NAME: DATA5
169
+ RANGE: [1364, 1388]
170
+ - NAME: LABEL6
171
+ RANGE: [1389, 1413]
172
+ - NAME: DATA6
173
+ RANGE: [1414, 1438]
174
+ - NAME: LABEL7
175
+ RANGE: [1439, 1463]
176
+ - NAME: DATA7
177
+ RANGE: [1464, 1488]
178
+ - NAME: LABEL8
179
+ RANGE: [1489, 1513]
180
+ - NAME: DATA8
181
+ RANGE: [1514, 1538]
182
+ - NAME: LABEL9
183
+ RANGE: [1539, 1563]
184
+ - NAME: DATA9
185
+ RANGE: [1564, 1588]
186
+ - NAME: LABEL10
187
+ RANGE: [1589, 1613]
188
+ - NAME: DATA10
189
+ RANGE: [1614, 1638]
190
+ - NAME: LABEL11
191
+ RANGE: [1639, 1663]
192
+ - NAME: DATA11
193
+ RANGE: [1664, 1688]
194
+ - NAME: CM_ACCNT_NUMB_EXD
195
+ RANGE: [1689, 1707]
196
+ - NAME: CASE_NUMBER_EXD
197
+ RANGE: [1714, 1729]
198
+ - NAME: IND_FORM_CODE
199
+ RANGE: [1765, 1766]
200
+ - NAME: IND_REF_NUMBER
201
+ RANGE: [1767, 1796]
202
+ - NAME: LOC_REF_NUMBER
203
+ RANGE: [1800, 1814]
204
+ - NAME: PASSENGER_NAME
205
+ RANGE: [1815, 1834]
206
+ - NAME: PASSENGER_FIRST_NAME
207
+ RANGE: [1835, 1846]
208
+ - NAME: PASSENGER_MIDDLE_NAME
209
+ RANGE: [1847, 1858]
210
+ - NAME: PASSENGER_LAST_NAME
211
+ RANGE: [1859, 1878]
212
+ - NAME: SE_PROCESS_DATE
213
+ RANGE: [1879, 1881]
214
+ TYPE: julian
215
+ - NAME: RETURN_DATE
216
+ RANGE: [1882, 1887]
217
+ TYPE: date(%y%m%d)
218
+ - NAME: CREDIT_RECEIPT_NUMBER
219
+ RANGE: [1888, 1902]
220
+ - NAME: RETURN_TO_NAME
221
+ RANGE: [1903, 1926]
222
+ - NAME: RETURN_TO_STREET
223
+ RANGE: [1927, 1943]
224
+ - NAME: CARD_DEPOSIT
225
+ RANGE: [1944, 1944]
226
+ - NAME: ASSURED_RESERVATION
227
+ RANGE: [1945, 1945]
228
+ - NAME: RES_CANCELLED
229
+ RANGE: [1946, 1946]
230
+ - NAME: RES_CANCELLED_DATE
231
+ RANGE: [1947, 1952]
232
+ TYPE: date(%y%m%d)
233
+ - NAME: CANCEL_ZONE
234
+ RANGE: [1953, 1953]
235
+ - NAME: RESERVATION_MADE_FOR
236
+ RANGE: [1954, 1959]
237
+ - NAME: RESERVATION_LOCATION
238
+ RANGE: [1960, 1979]
239
+ - NAME: RESERVATION_MADE_ON
240
+ RANGE: [1980, 1985]
241
+ TYPE: date(%y%m%d)
242
+ - NAME: RENTAL_AGREEMENT_NUMBER
243
+ RANGE: [1986, 2003]
244
+ - NAME: MERCHANDISE_TYPE
245
+ RANGE: [2004, 2023]
246
+ - NAME: MERCHANDISE_RETURNED
247
+ RANGE: [2024, 2024]
248
+ - NAME: RETURNED_NAME
249
+ RANGE: [2025, 2048]
250
+ - NAME: RETURNED_DATE
251
+ RANGE: [2049, 2054]
252
+ TYPE: date(%y%m%d)
253
+ - NAME: RETURNED_HOW
254
+ RANGE: [2055, 2062]
255
+ - NAME: RETURNED_REASON
256
+ RANGE: [2063, 2112]
257
+ - NAME: STORE_CREDIT_RECEIVED
258
+ RANGE: [2113, 2113]
259
+ DATA_FILE_TRAILER_RECORD:
260
+ TRAILER: true
261
+ FIELDS:
262
+ - NAME: REC_TYPE
263
+ RANGE: [0, 0]
264
+ - NAME: AMEX_APPL_AREA
265
+ RANGE: [1, 100]
266
+ - NAME: SAID
267
+ RANGE: [101, 106]
268
+ - NAME: DATATYPE
269
+ RANGE: [107, 111]
270
+ - NAME: CCYYDDD
271
+ RANGE: [112, 118]
272
+ TYPE: julian
273
+ - NAME: 0HHMMSS
274
+ RANGE: [119, 125]
275
+ TYPE: numeric
276
+ - NAME: STARS_FILESEQ_NB
277
+ RANGE: [126, 128]
278
+ TYPE: numeric
data/lib/paxmex/parser.rb CHANGED
@@ -3,7 +3,7 @@ require 'paxmex/schema'
3
3
  require 'paxmex/parsed_section'
4
4
 
5
5
  class Paxmex::Parser
6
- SCHEMATA = %w(epraw eptrn epa).reduce({}) do |h, fn|
6
+ SCHEMATA = %w(epraw eptrn epa cbnot).reduce({}) do |h, fn|
7
7
  file = File.expand_path("../../config/#{fn}.yml", File.dirname(__FILE__))
8
8
  h.merge(fn => Paxmex::Schema.new(YAML.load(File.open(file))))
9
9
  end
@@ -36,9 +36,10 @@ class Paxmex::Parser
36
36
  trailer_content = [content.slice!(-1)]
37
37
  @parsed = parse_section(trailer_section, trailer_content, raw: opts[:raw_values])
38
38
 
39
- schema.sections.reject(&:trailer?).each.with_object(@parsed) do |s, o|
40
- section_content = s.recurring? ? content : [content.slice!(0)]
41
- o.update(parse_section(s, section_content, raw: opts[:raw_values]))
39
+ schema.sections.reject(&:trailer?).each_with_object(@parsed) do |section, parsed|
40
+ break parsed if content.size == 0
41
+ section_content = section.recurring? ? content : [content.slice!(0)]
42
+ parsed.update(parse_section(section, section_content, raw: opts[:raw_values]))
42
43
  end
43
44
  end
44
45
 
@@ -2,6 +2,9 @@ require 'bigdecimal'
2
2
  require 'paxmex/schema'
3
3
 
4
4
  class Paxmex::Schema::Field
5
+ DATE_PATTERN = /^date\((.+)\)$/
6
+ TIME_PATTERN = /^time\((.+)\)$/
7
+
5
8
  attr_reader :name, :start, :final, :type
6
9
 
7
10
  def initialize(opts = {})
@@ -12,21 +15,28 @@ class Paxmex::Schema::Field
12
15
  end
13
16
 
14
17
  def parse(raw_value)
15
- date_pattern = /^date\((.+)\)$/
16
- time_pattern = /^time\((.+)\)$/
17
-
18
18
  case type
19
19
  when 'string' then raw_value.rstrip
20
- when 'julian' then parse_julian_date(raw_value)
21
- when 'date' then Date.strptime(raw_value, '%m%d%Y')
20
+ when 'julian' then parse_julian_date(raw_value) rescue nil
21
+ when 'date' then Date.strptime(raw_value, '%m%d%Y') rescue nil
22
22
  when 'numeric' then raw_value.strip.to_i
23
23
  when 'decimal' then parse_decimal(raw_value)
24
- when date_pattern then Date.strptime(raw_value, date_pattern.match(type).captures.first)
25
- when time_pattern then Time.strptime(raw_value, time_pattern.match(type).captures.first)
24
+ when DATE_PATTERN then parse_date_pattern(raw_value) rescue nil
25
+ when TIME_PATTERN then parse_time_pattern(raw_value) rescue nil
26
26
  else fail "Could not parse field type #{type}. Supported types: string, julian, date, numeric, decimal, date(format), time(format)"
27
27
  end
28
28
  end
29
29
 
30
+ private
31
+
32
+ def parse_date_pattern(value)
33
+ Date.strptime(value, DATE_PATTERN.match(type).captures.first)
34
+ end
35
+
36
+ def parse_time_pattern(value)
37
+ Time.strptime(value, TIME_PATTERN.match(type).captures.first)
38
+ end
39
+
30
40
  def parse_decimal(value)
31
41
  # fields _may_ end with a letter
32
42
  unless value.match(/^[0-9]*[0-9A-R{}]$/)
@@ -1,3 +1,3 @@
1
1
  module Paxmex
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
  end
data/lib/paxmex.rb CHANGED
@@ -1,11 +1,27 @@
1
+ require 'paxmex/parser'
2
+
1
3
  module Paxmex
2
- require 'paxmex/parser'
4
+ class << self
5
+ def parse_cbnot(*args)
6
+ parse('cbnot', *args)
7
+ end
8
+
9
+ def parse_epa(*args)
10
+ parse('epa', *args)
11
+ end
12
+
13
+ def parse_epraw(*args)
14
+ parse('epraw', *args)
15
+ end
16
+
17
+ def parse_eptrn(*args)
18
+ parse('eptrn', *args)
19
+ end
20
+
21
+ private
3
22
 
4
- def self.method_missing(method_sym, *arguments, &block)
5
- if method_sym.to_s =~ /^parse_(.*)$/
6
- Parser.new(arguments.shift, $1).parse(*arguments)
7
- else
8
- super
23
+ def parse(schema, *args)
24
+ Parser.new(args.shift, schema).parse(*args)
9
25
  end
10
26
  end
11
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paxmex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daryl Yeo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-03-01 00:00:00.000000000 Z
12
+ date: 2017-03-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -50,6 +50,7 @@ files:
50
50
  - MIT-LICENSE
51
51
  - README.md
52
52
  - Rakefile
53
+ - config/cbnot.yml
53
54
  - config/epa.yml
54
55
  - config/epraw.yml
55
56
  - config/eptrn.yml