iso8583 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NjVlYWQ5YmQzY2ZlYWVjYWYxODliYTQ4NjViMzhiZDM3Y2NiY2I5Mw==
5
- data.tar.gz: !binary |-
6
- YzQ0OTBiYmI4MGQ0NjViMTI2YzNlM2NiZTUzNTIxZTliYWU4OTQzOQ==
2
+ SHA1:
3
+ metadata.gz: 9a014be2e1455129a38601f8f9490a0856e8f80e
4
+ data.tar.gz: e845890de100b7b09f52c2dea10709d759a09710
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NWU4Zjg3NDQwNjdmNThjOWYwZWYyOWEwZTQ5ZDU1ZDFkNWNlZDE5OWFiOTgw
10
- NjY4M2QzNWIxNTlkNDAwM2Y5ZjUzZTM3ZTc3ZGNhMGQ3ODI4Zjg1OWVmOGMx
11
- YmIzZWE4YWJlNDc5ZGIwNWJjMmMyZDBkZDE2M2EzMjdjNjU0OTg=
12
- data.tar.gz: !binary |-
13
- YzQ2YzU2N2E1YzM2YjRjZThiNTdiOWE2NGViYjA1NmMzNWQwZGNjZmJkMTg2
14
- MDBlOWU2MTdmOTkyOWZkYmQwYWVmNjJkMTkxMDkyMTY3NDk1MjcyYjI3OWM2
15
- MGU1MDVlN2QzNTAxNTAzZjQ4YzA0NmQ2ZmVmMzI0ZDlkMzYyZWQ=
6
+ metadata.gz: 883e27a230ef51981e2a6fdd95776c4fb310a02712554526bc2f7928835864ffa2c2a2cb1eb38757ec1f736447922d424820bbb84afb1e882512310fdf1693c7
7
+ data.tar.gz: 692b9a633fd89d7916888c39f9440920e206eef24f979eda4672684eb13864703d94b7484bc363d1240a4ee69a765a8267a08245b7b12902f10d872a175a19c7
data/AUTHORS CHANGED
@@ -1,3 +1,5 @@
1
1
  Tim Becker (tim@kuriositaet.de)
2
2
  Slava Kravchenko (cordawyn@gmail.com)
3
3
  Tonni Aagesen (https://github.com/ta)
4
+ Lasse Skindstad Ebert (https://github.com/lasseebert)
5
+ Joel Ibaceta (https://github.com/joelibaceta)
data/CHANGELOG CHANGED
@@ -1,12 +1,21 @@
1
+ 0.2.0
2
+ =========
3
+ no more 1.8 compatibility, byte encoding for 1.9+, ci
4
+ Inherit ISOException from StandardError
5
+ Add bundler stuff, and dev dependancy for test-unit which was removed
6
+ for no good reason in 2.2
7
+ Use ASCII for all forced_encodings
8
+
1
9
  0.1.6
2
10
  =========
3
- restrict to ruby < 2
4
- allow removal of empty fields
11
+ restrict to ruby < 2
12
+ allow removal of empty fields
13
+ Thanks: Lasse Skindstad Ebert https://github.com/lasseebert
5
14
 
6
15
  0.1.5
7
16
  =========
8
- MMDD Codec
9
- BCD encoder checks odd length fields
17
+ MMDD Codec
18
+ BCD encoder checks odd length fields
10
19
 
11
20
  0.1.4
12
21
  =========
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,18 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ iso8583 (0.1.6)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.4.2)
10
+ test-unit (2.1.2.0)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ iso8583!
17
+ rake
18
+ test-unit
data/README CHANGED
@@ -3,17 +3,18 @@
3
3
  This package currently contains code for coding an decoding ISO 8583
4
4
  Financial Message.
5
5
 
6
- == Using
6
+ == Developing
7
7
 
8
- The best place to get started using the library is the documentation of the
9
- Message class. Once a stable state is reached, this should be the only
10
- class you need to use ...
8
+ In case you're using a ruby version >= 2.2, test-unit is no longer in
9
+ the std lib, so it needs to be available. Bundler installs this, if not
10
+ using bundler, you need to run `gem install test-unit` before running
11
+ the tests.
11
12
 
12
13
  == Installing
13
14
 
14
- You can install the +iso8583+ package by executing:
15
+ You can install the last version of the +iso8583+ package by executing:
15
16
 
16
- gem install iso8583
17
+ gem install iso8583
17
18
 
18
19
  == Source
19
20
 
@@ -24,3 +25,5 @@ The source is most readily available on github[http://github.com/a2800276/8583].
24
25
  In case you discover bugs, spelling errors, offer suggestions for
25
26
  improvements or would like to help out with the project, you can contact
26
27
  me directly (tim@kuriositaet.de).
28
+
29
+ [![Build Status](https://travis-ci.org/a2800276/8583.svg?branch=master)](https://travis-ci.org/a2800276/8583)
@@ -17,9 +17,7 @@ module ISO8583
17
17
  # not, this initializes and empty bitmap.
18
18
  def initialize(message = nil)
19
19
  @bmp = Array.new(128, false)
20
- if !message
21
-
22
- else
20
+ if message
23
21
  initialize_from_message message
24
22
  end
25
23
  end
@@ -76,7 +74,7 @@ module ISO8583
76
74
  break
77
75
  end
78
76
  }
79
- str = ""
77
+ str = "".force_encoding("ASCII-8BIT")
80
78
  1.upto(self[1] ? 128 : 64) {|i|
81
79
  str << (self[i] ? "1" : "0")
82
80
  }
@@ -1,4 +1,4 @@
1
1
  module ISO8583
2
- class ISO8583Exception < Exception; end
2
+ class ISO8583Exception < StandardError; end
3
3
  class ISO8583ParseException < ISO8583Exception; end
4
4
  end
@@ -27,7 +27,7 @@ module ISO8583
27
27
  raise ISO8583Exception.new("Cannot determine the length of '#{name}' field")
28
28
  end
29
29
 
30
- raw_value = raw[0,len]
30
+ raw_value = raw.byteslice(0,len)
31
31
 
32
32
  # make sure we have enough data ...
33
33
  if raw_value.length != len
@@ -35,7 +35,7 @@ module ISO8583
35
35
  raise ISO8583ParseException.new(mes)
36
36
  end
37
37
 
38
- rest = raw[len, raw.length]
38
+ rest = raw.byteslice(len, raw.length)
39
39
  begin
40
40
  real_value = codec.decode(raw_value)
41
41
  rescue
@@ -70,7 +70,7 @@ module ISO8583
70
70
  when Fixnum
71
71
  raise ISO8583Exception.new("Too long: #{value} (#{name})! length=#{length}") if encoded_value.length > length
72
72
  raise ISO8583Exception.new("Too short: #{value} (#{name})! length=#{length}") if encoded_value.length < length
73
- ""
73
+ "".force_encoding("ASCII-8BIT")
74
74
  when Field
75
75
  raise ISO8583Exception.new("Max lenth exceeded: #{value}, max: #{max}") if max && encoded_value.length > max
76
76
  length.encode(encoded_value.length)
@@ -173,8 +173,10 @@ module ISO8583
173
173
  # Retrieve the byte representation of the bitmap.
174
174
  def to_b
175
175
  raise ISO8583Exception.new "no MTI set!" unless mti
176
- mti_enc = self.class._mti_format.encode(mti)
177
- mti_enc << _body.join
176
+ mti_enc = self.class._mti_format.encode(mti)
177
+ str_body="".force_encoding('ASCII-8BIT')
178
+ _body.map {|b| str_body+=b.force_encoding('ASCII-8BIT')}
179
+ mti_enc << str_body
178
180
  end
179
181
 
180
182
  # Returns a nicely formatted representation of this
@@ -202,7 +204,7 @@ module ISO8583
202
204
  # [bitmap_bytes, message_bytes]
203
205
  def _body
204
206
  bitmap = Bitmap.new
205
- message = ""
207
+ message = "".force_encoding('ASCII-8BIT')
206
208
  @values.keys.sort.each do |bmp_num|
207
209
  bitmap.set(bmp_num)
208
210
  enc_value = @values[bmp_num].encode
@@ -344,6 +346,7 @@ module ISO8583
344
346
 
345
347
  # Parse the bytes `str` returning a message of the defined type.
346
348
  def parse(str)
349
+ str = str.force_encoding('ASCII-8BIT')
347
350
  message = self.new
348
351
  message.mti, rest = _mti_format.parse(str)
349
352
  bmp,rest = Bitmap.parse(rest)
@@ -19,20 +19,25 @@ module ISO8583
19
19
  #
20
20
  # Convert a String containing hex data to
21
21
  # a String containing the corresponding bytes:
22
- #
22
+ #
23
23
  # hex2b "abcd12" => "\xa\cd\12"
24
24
  #
25
25
  def hex2b(hex_string)
26
+
26
27
  string = hex_string.gsub(/\s+/, "")
28
+
27
29
  raise ISO8583Exception.new("Invalid Hex chars: #{hex_string}") unless string =~ /^[A-Fa-f0-9]*$/
28
30
  raise ISO8583Exception.new("Uneven number of Hex chars #{hex_string}") unless ( (string.length % 2) == 0)
29
- [string].pack("H*")
31
+
32
+ [string].pack("H*").force_encoding('ASCII-8BIT')
33
+
30
34
  end
31
35
 
36
+
32
37
  def _conv(str, mapping)
33
- _str = ""
38
+ _str = "".force_encoding('ASCII-8BIT')
34
39
  str.each_byte{|byte|
35
- _str << mapping[byte]
40
+ _str << [mapping[byte]].pack("C")
36
41
  }
37
42
  _str
38
43
  end
@@ -1,4 +1,4 @@
1
1
  # -*- mode: ruby; encoding: utf-8; tab-width: 2; indent-tabs-mode: nil -*-
2
2
  module ISO8583
3
- VERSION = "0.1.6"
3
+ VERSION = "0.2.0"
4
4
  end
@@ -45,6 +45,17 @@ class MessageTest < Test::Unit::TestCase
45
45
  assert_equal 1430, mes.mti
46
46
  end
47
47
 
48
+ def test_rescue_standard_error
49
+ rescued = false
50
+ begin
51
+ BerlinMessage.parse("bogus")
52
+ rescue => error
53
+ rescued = true
54
+ end
55
+
56
+ assert rescued
57
+ end
58
+
48
59
  def test_to_s
49
60
  mes = BerlinMessage.new
50
61
  mes.mti = "Network Management Request Response Issuer Gateway or Acquirer Gateway"
@@ -5,9 +5,18 @@ include ISO8583
5
5
 
6
6
  class UtilTest < Test::Unit::TestCase
7
7
  def test_hex2b
8
- assert_equal "\xab\xcd\x12", hex2b("abcd12")
9
- assert_equal "\xab\xcd\x12", hex2b("a b c d 1 2")
10
- assert_equal "\xab\xcd\x12", hex2b("ABCD12")
8
+ # weird ruby 2.0 workaround:
9
+ # literal:
10
+ # "\xab\xcd\x12"
11
+ # is interpretted as:
12
+ # "\xAB\xCD\u0012"
13
+ # ...force_encoding(...) fixes this.
14
+
15
+ expected = "\xab\xcd\x12".force_encoding("ASCII-8BIT")
16
+
17
+ assert_equal expected, hex2b("abcd12")
18
+ assert_equal expected, hex2b("a b c d 1 2")
19
+ assert_equal expected, hex2b("ABCD12")
11
20
  assert_raise(ISO8583Exception){
12
21
  # non hex
13
22
  hex2b("ABCDEFGH")
@@ -27,6 +36,6 @@ class UtilTest < Test::Unit::TestCase
27
36
  end
28
37
 
29
38
  def test_ascii2ebcdic
30
- assert_equal "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9", ascii2ebcdic("0123456789")
39
+ assert_equal "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9".force_encoding('ASCII-8BIT'), ascii2ebcdic("0123456789")
31
40
  end
32
41
  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.1.6
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Becker
@@ -9,11 +9,10 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-10 00:00:00.000000000 Z
12
+ date: 2015-09-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: ! 'Ruby implementation of ISO 8583 financial messaging
15
-
16
- '
14
+ description: |
15
+ Ruby implementation of ISO 8583 financial messaging
17
16
  email:
18
17
  - tim.becker@kuriositaet.de
19
18
  - cordawyn@gmail.com
@@ -23,6 +22,8 @@ extra_rdoc_files: []
23
22
  files:
24
23
  - AUTHORS
25
24
  - CHANGELOG
25
+ - Gemfile
26
+ - Gemfile.lock
26
27
  - LICENSE
27
28
  - README
28
29
  - Rakefile
@@ -53,19 +54,19 @@ require_paths:
53
54
  - lib
54
55
  required_ruby_version: !ruby/object:Gem::Requirement
55
56
  requirements:
56
- - - ! '>='
57
+ - - '>='
57
58
  - !ruby/object:Gem::Version
58
59
  version: '0'
59
60
  required_rubygems_version: !ruby/object:Gem::Requirement
60
61
  requirements:
61
- - - ! '>='
62
+ - - '>='
62
63
  - !ruby/object:Gem::Version
63
64
  version: '0'
64
65
  requirements:
65
66
  - none
66
67
  rubyforge_project: iso8583
67
- rubygems_version: 2.2.2
68
+ rubygems_version: 2.4.6
68
69
  signing_key:
69
70
  specification_version: 4
70
- summary: ! 'iso8583: Ruby implementation of ISO 8583 financial messaging'
71
+ summary: 'iso8583: Ruby implementation of ISO 8583 financial messaging'
71
72
  test_files: []