iso8583 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +7 -0
- data/lib/iso8583/codec.rb +19 -0
- data/lib/iso8583/version.rb +1 -1
- data/test/BitmapTests.rb +11 -0
- data/test/test_codec.rb +38 -0
- data/test/test_message_metaclass.rb +30 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31f7f975a6cd80dbfcdb1aa4e59ceb295d8fae42
|
4
|
+
data.tar.gz: d0521763d3f6aadaef2098709462488c73f160c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfa7d0d9c6bf2a376f9485f59d2f5127a017213faa99ab624a2d966c1aaf6d251b0e59019ea6e4f0939912d0891a2d99dbd4c9a25b0fbb2dddbcd9253c624947
|
7
|
+
data.tar.gz: 76a1046d1c987139cad5f74be878983d7fbf06a5d831d1187696022852b2c60a54bdb9f40b869db085ff23c21b6b6ec4f9df431a7222c263a5843e5ade50c7f2
|
data/CHANGELOG
CHANGED
data/lib/iso8583/codec.rb
CHANGED
@@ -53,6 +53,8 @@ module ISO8583
|
|
53
53
|
# during encoding, no validity check during decoding.
|
54
54
|
# [+ANS_Codec+] passes through ASCII string checking they conform to [\x20-\x7E]
|
55
55
|
# during encoding, no validity check during decoding.
|
56
|
+
# [BE_U16] 16-bit unsigned, network (big-endian) byte order
|
57
|
+
# [BE_U32] 32-bit unsigned, network (big-endian) byte order
|
56
58
|
# [+Null_Codec+] passes anything along untouched.
|
57
59
|
# [<tt>Track2</tt>] rudimentary check that string conforms to Track2
|
58
60
|
# [+MMDDhhmmssCodec+] encodes Time, Datetime or String to the described date format, checking
|
@@ -141,6 +143,23 @@ module ISO8583
|
|
141
143
|
str
|
142
144
|
}
|
143
145
|
ANS_Codec.decoder = PASS_THROUGH_DECODER
|
146
|
+
|
147
|
+
BE_U16 = Codec.new
|
148
|
+
BE_U16.encoder = lambda {|num|
|
149
|
+
raise ISO8583Exception.new("Invalid value: #{num} must be 0<= X <=2^16-1") unless 0 <= num && num <= 2**16-1
|
150
|
+
[num].pack("n")
|
151
|
+
}
|
152
|
+
BE_U16.decoder = lambda { |encoded|
|
153
|
+
encoded.unpack("n")[0]
|
154
|
+
}
|
155
|
+
BE_U32 = Codec.new
|
156
|
+
BE_U32.encoder = lambda {|num|
|
157
|
+
raise ISO8583Exception.new("Invalid value: #{num} must be 0<= X <=2^32-1") unless 0 <= num && num <= 2**32-1
|
158
|
+
[num].pack("N")
|
159
|
+
}
|
160
|
+
BE_U32.decoder = lambda { |encoded|
|
161
|
+
encoded.unpack("N")[0]
|
162
|
+
}
|
144
163
|
|
145
164
|
Null_Codec = Codec.new
|
146
165
|
Null_Codec.encoder = lambda {|str|
|
data/lib/iso8583/version.rb
CHANGED
data/test/BitmapTests.rb
CHANGED
@@ -76,5 +76,16 @@ class BitmapTests < Test::Unit::TestCase
|
|
76
76
|
assert_equal [2,3,5,6], arr
|
77
77
|
end
|
78
78
|
|
79
|
+
def test_each_w_two_bitmaps_doesnt_yield_first_field
|
80
|
+
#10000000000000000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000000100000010000001000
|
81
|
+
# generated by: 20.step(128,7) {|i| mp.set(i)}
|
82
|
+
tst = "\x80\x00\x10\x20\x40\x81\x02\x04\x08\x10\x20\x40\x81\x02\x04\x08"
|
83
|
+
bmp = Bitmap.new tst
|
84
|
+
arr = []
|
85
|
+
first = bmp.each{|bit|
|
86
|
+
arr.push bit
|
87
|
+
}
|
88
|
+
assert_equal 20, arr.first
|
89
|
+
end
|
79
90
|
end
|
80
91
|
|
data/test/test_codec.rb
CHANGED
@@ -139,4 +139,42 @@ class FieldTest < Test::Unit::TestCase
|
|
139
139
|
dt = Packed_Number.encode "F"
|
140
140
|
}
|
141
141
|
end
|
142
|
+
|
143
|
+
def test_BE_U16
|
144
|
+
assert_raise(ISO8583Exception) {
|
145
|
+
BE_U16.encode 2**16
|
146
|
+
}
|
147
|
+
assert_raise(ISO8583Exception) {
|
148
|
+
BE_U16.encode -1
|
149
|
+
}
|
150
|
+
assert_equal "\0\0", BE_U16.encode(0)
|
151
|
+
expected = "\xff\xff".force_encoding('ASCII-8BIT')
|
152
|
+
assert_equal expected, BE_U16.encode(2**16-1)
|
153
|
+
expected = "\x0f\xf0".force_encoding('ASCII-8BIT')
|
154
|
+
assert_equal expected, BE_U16.encode(0x00000ff0)
|
155
|
+
expected = "\xf0\x0f".force_encoding('ASCII-8BIT')
|
156
|
+
assert_equal expected, BE_U16.encode(0x0000f00f)
|
157
|
+
expected = "\x5A\xA5".force_encoding('ASCII-8BIT')
|
158
|
+
assert_equal expected, BE_U16.encode(0b0101101010100101)
|
159
|
+
|
160
|
+
assert_equal 0x5aa5, BE_U16.decode(expected)
|
161
|
+
end
|
162
|
+
def test_BE_U32
|
163
|
+
assert_raise(ISO8583Exception) {
|
164
|
+
BE_U32.encode 2**32
|
165
|
+
}
|
166
|
+
assert_raise(ISO8583Exception) {
|
167
|
+
BE_U32.encode -1
|
168
|
+
}
|
169
|
+
assert_equal "\0\0\0\0", BE_U32.encode(0)
|
170
|
+
expected = "\xff\xff\xff\xff".force_encoding('ASCII-8BIT')
|
171
|
+
assert_equal expected, BE_U32.encode(2**32-1)
|
172
|
+
expected = "\xf0\xf0\x0f\x0f".force_encoding('ASCII-8BIT')
|
173
|
+
assert_equal expected, BE_U32.encode(0xf0f00f0f)
|
174
|
+
expected = "\0\0\0\x1".force_encoding('ASCII-8BIT')
|
175
|
+
assert_equal expected, BE_U32.encode(1)
|
176
|
+
|
177
|
+
assert_equal 1, BE_U32.decode(expected)
|
178
|
+
assert_equal 10, BE_U32.decode("\0\0\0\xa")
|
179
|
+
end
|
142
180
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'lib/iso8583'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
|
5
|
+
class TestMessage < Message
|
6
|
+
mti_format N, :length => 4
|
7
|
+
mti 1100, "Authorization Request Acquirer Gateway"
|
8
|
+
end
|
9
|
+
|
10
|
+
class TestMessage2 < Message
|
11
|
+
mti_format N_BCD, :length => 4
|
12
|
+
mti 1100, "Authorization Request Acquirer Gateway"
|
13
|
+
end
|
14
|
+
|
15
|
+
class MessageMetaclassTest < Test::Unit::TestCase
|
16
|
+
def test_mti
|
17
|
+
t = TestMessage.new
|
18
|
+
t.mti = 1100
|
19
|
+
expected = "1100\0\0\0\0\0\0\0\0"
|
20
|
+
bs = t.to_b
|
21
|
+
assert_equal expected, bs
|
22
|
+
end
|
23
|
+
def test_len_prefix
|
24
|
+
t = TestMessage2.new
|
25
|
+
t.mti = 1100
|
26
|
+
expected = "\x11\0\0\0\0\0\0\0\0\0"
|
27
|
+
bs = t.to_b
|
28
|
+
assert_equal expected, bs
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iso8583
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Becker
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-02-16 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: |
|
15
15
|
Ruby implementation of ISO 8583 financial messaging
|
@@ -43,6 +43,7 @@ files:
|
|
43
43
|
- test/message_test.rb
|
44
44
|
- test/test_codec.rb
|
45
45
|
- test/test_fields.rb
|
46
|
+
- test/test_message_metaclass.rb
|
46
47
|
- test/test_seperate_msg.rb
|
47
48
|
- test/test_util.rb
|
48
49
|
homepage: http://github.com/a2800276/8583/
|