da_funk 0.5.4 → 0.6.0

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.
@@ -11,16 +11,16 @@ module ISO8583
11
11
  end
12
12
  end
13
13
 
14
- def create_mti(klass, mti_format, mti_messages)
15
- klass.mti_format *mti_format
14
+ def self.create_mti(klass, format, mti_messages)
15
+ klass.mti_format(*format)
16
16
  mti_messages.each do |number, description|
17
17
  klass.mti number, description
18
18
  end
19
19
  end
20
20
 
21
- def parse_file(filepath)
22
- return [] unless File.exists?(path)
23
- file = File.open(path, "r")
21
+ def self.parse_file(filepath)
22
+ return [] unless File.exists?(filepath)
23
+ file = File.open(filepath, "r")
24
24
 
25
25
  file.readlines.inject([]) do |array, line|
26
26
  data = line.match(/([0-9]+)=\"ATT_([a-zA-Z]+);([0-9A-Z]+)/)
@@ -28,17 +28,15 @@ module ISO8583
28
28
  array << mount_parameters(data)
29
29
  end
30
30
  ensure
31
- file.close
31
+ file.close if file
32
32
  end
33
33
 
34
34
  def self.build_klass(mti_format, mti_messages, filepath = PATH_DEFAULT)
35
35
  Class.new(ISO8583::Message) do |klass|
36
36
  klass.include ISO8583
37
- #klass.mti_format ISO8583::N, :length => 4
38
- #klass.mti 200, "Authorization Request Acquirer Gateway"
39
- create_mti(klass, mti_format, mti_messages)
37
+ FileParser.create_mti(klass, mti_format, mti_messages)
40
38
 
41
- parse_file(filepath).each do |parameters|
39
+ FileParser.parse_file(filepath).each do |parameters|
42
40
  klass.bmp(*parameters)
43
41
  end
44
42
  end
@@ -40,7 +40,7 @@ module ISO8583
40
40
  # be accessed later either via their name or value:
41
41
  #
42
42
  # mes = MyMessage.new 1100
43
- #
43
+ #
44
44
  # or
45
45
  # mes = MyMessage.new "Authorization Request Acquirer Gateway"
46
46
  #
@@ -75,7 +75,7 @@ module ISO8583
75
75
  #
76
76
  # Constructing own messages works as follows:
77
77
  #
78
- # mes = MyMessage.new 1100
78
+ # mes = MyMessage.new 1100
79
79
  # mes[2]= 474747474747
80
80
  # # Alternatively
81
81
  # mes["Primary Account Number (PAN)"]= 4747474747
@@ -106,17 +106,17 @@ module ISO8583
106
106
  # Most of the work in implementing a new set of message type lays in
107
107
  # figuring out the correct fields to use defining the Message class via
108
108
  # bmp.
109
- #
109
+ #
110
110
  class Message
111
111
 
112
112
  # The value of the MTI (Message Type Indicator) of this message.
113
- attr_reader :mti
113
+ attr_reader :mti
114
114
 
115
115
  # ISO8583 allows hex or binary bitmap, so it should be configurable
116
116
  attr_reader :use_hex_bitmap
117
117
 
118
118
  # Instantiate a new instance of this type of Message
119
- # optionally specifying an mti.
119
+ # optionally specifying an mti.
120
120
  def initialize(mti = nil, use_hex_bitmap = false)
121
121
  # values is an internal field used to collect all the
122
122
  # bmp number | bmp name | field en/decoders | values
@@ -245,7 +245,7 @@ module ISO8583
245
245
 
246
246
  class << self
247
247
 
248
- # Defines how the message type indicator is encoded into bytes.
248
+ # Defines how the message type indicator is encoded into bytes.
249
249
  # ===Params:
250
250
  # * field : the decoder/encoder for the MTI
251
251
  # * opts : the options to pass to this field
@@ -268,7 +268,7 @@ module ISO8583
268
268
 
269
269
  # Defines the message types allowed for this type of message and
270
270
  # gives them names
271
- #
271
+ #
272
272
  # === Example
273
273
  # class MyMessage < Message
274
274
  # (...)
@@ -300,8 +300,8 @@ module ISO8583
300
300
  # (...)
301
301
  # end
302
302
  #
303
- # creates a class MyMessage that allows for a bitmap 2 which
304
- # is named "PAN" and encoded by an LLVAR_N Field. The maximum
303
+ # creates a class MyMessage that allows for a bitmap 2 which
304
+ # is named "PAN" and encoded by an LLVAR_N Field. The maximum
305
305
  # length of the value is 19. This class may be used as follows:
306
306
  #
307
307
  # mes = MyMessage.new
data/lib/zip.rb CHANGED
@@ -3,9 +3,9 @@ module Zip
3
3
  Miniz.zip(*args)
4
4
  end
5
5
 
6
- def self.uncompress(filezip, path = ".")
7
- dir = "#{path}/#{filezip.split(".")[0]}"
8
- clean(dir)
6
+ def self.uncompress(filezip, path = ".", application = true, clear_dir = true)
7
+ dir = "#{path}/#{filezip.split(".").first}" if application
8
+ clean(dir) if clear_dir
9
9
  Miniz.unzip(filezip, path)
10
10
  end
11
11
 
@@ -0,0 +1,128 @@
1
+ 001="ATT_B;128"
2
+ 002="ATT_AN;LLVAR"
3
+ 003="ATT_N;6"
4
+ 004="ATT_N;12"
5
+ 005="ATT_N;12"
6
+ 006="ATT_N;12"
7
+ 007="ATT_N;10"
8
+ 008="ATT_N;8"
9
+ 009="ATT_N;8"
10
+ 010="ATT_N;8"
11
+ 011="ATT_N;6"
12
+ 012="ATT_N;6"
13
+ 013="ATT_N;4"
14
+ 014="ATT_ANS;16"
15
+ 015="ATT_N;4"
16
+ 016="ATT_N;4"
17
+ 017="ATT_N;4"
18
+ 018="ATT_N;4"
19
+ 019="ATT_N;3"
20
+ 020="ATT_N;3"
21
+ 021="ATT_N;3"
22
+ 022="ATT_N;3"
23
+ 023="ATT_N;3"
24
+ 024="ATT_N;4"
25
+ 025="ATT_N;2"
26
+ 026="ATT_N;2"
27
+ 027="ATT_N;1"
28
+ 028="ATT_XN;8"
29
+ 029="ATT_XN;8"
30
+ 030="ATT_XN;8"
31
+ 031="ATT_XN;8"
32
+ 032="ATT_N;LLVAR"
33
+ 033="ATT_N;LLVAR"
34
+ 034="ATT_N;LLVAR"
35
+ 035="ATT_ANS;LLVAR"
36
+ 036="ATT_Z;LLLVAR"
37
+ 037="ATT_AN;24"
38
+ 038="ATT_N;6"
39
+ 039="ATT_AN;2"
40
+ 040="ATT_AN;3"
41
+ 041="ATT_ANS;8"
42
+ 042="ATT_ANS;15"
43
+ 043="ATT_ANS;40"
44
+ 044="ATT_ANS;LLVAR"
45
+ 045="ATT_ANS;LLVAR"
46
+ 046="ATT_ANS;LLLVAR"
47
+ 047="ATT_ANS;LLLVAR"
48
+ 048="ATT_ANS;LLLVAR"
49
+ 049="ATT_AN;3"
50
+ 050="ATT_AN;3"
51
+ 051="ATT_AN;3"
52
+ 052="ATT_ANS;16"
53
+ 053="ATT_ANS;LLVAR"
54
+ 054="ATT_ANS;LLLVAR"
55
+ 055="ATT_B;LLLVAR"
56
+ 056="ATT_ANS;LLLVAR"
57
+ 057="ATT_ANS;LLLVAR"
58
+ 058="ATT_ANS;LLVAR"
59
+ 059="ATT_ANS;LLLVAR"
60
+ 060="ATT_ANS;LLLVAR"
61
+ 061="ATT_ANS;LLLVAR"
62
+ 062="ATT_ANS;LLLVAR"
63
+ 063="ATT_ANS;LLLVAR"
64
+ 064="ATT_ANS;LLLVAR"
65
+ 065="UNKNOWN;0"
66
+ 066="ATT_N;1"
67
+ 067="ATT_N;2"
68
+ 068="ATT_N;3"
69
+ 069="ATT_N;3"
70
+ 070="ATT_N;3"
71
+ 071="ATT_N;4"
72
+ 072="ATT_N;4"
73
+ 073="ATT_N;6"
74
+ 074="ATT_N;10"
75
+ 075="ATT_N;10"
76
+ 076="ATT_N;10"
77
+ 077="ATT_N;10"
78
+ 078="ATT_N;10"
79
+ 079="ATT_N;10"
80
+ 080="ATT_N;10"
81
+ 081="ATT_N;10"
82
+ 082="ATT_N;12"
83
+ 083="ATT_N;12"
84
+ 084="ATT_N;12"
85
+ 085="ATT_N;12"
86
+ 086="ATT_N;16"
87
+ 087="ATT_N;16"
88
+ 088="ATT_N;16"
89
+ 089="ATT_N;16"
90
+ 090="ATT_N;20"
91
+ 091="ATT_AN;1"
92
+ 092="ATT_AN;2"
93
+ 093="ATT_AN;5"
94
+ 094="ATT_AN;7"
95
+ 095="ATT_AN;42"
96
+ 096="ATT_B;8"
97
+ 097="ATT_XN;16"
98
+ 098="ATT_ANS;25"
99
+ 099="ATT_N;LLVAR"
100
+ 100="ATT_N;LLVAR"
101
+ 101="ATT_ANS;LLVAR"
102
+ 102="ATT_ANS;LLVAR"
103
+ 103="ATT_ANS;LLVAR"
104
+ 104="ATT_ANS;LLLVAR"
105
+ 105="ATT_ANS;LLLVAR"
106
+ 106="ATT_ANS;LLLVAR"
107
+ 107="ATT_ANS;LLLVAR"
108
+ 108="ATT_ANS;LLLVAR"
109
+ 109="ATT_ANS;LLLVAR"
110
+ 110="ATT_ANS;LLLVAR"
111
+ 111="ATT_ANS;LLLVAR"
112
+ 112="ATT_ANS;LLLVAR"
113
+ 113="ATT_ANS;LLLVAR"
114
+ 114="ATT_ANS;LLLVAR"
115
+ 115="ATT_ANS;LLLVAR"
116
+ 116="ATT_ANS;LLLVAR"
117
+ 117="ATT_ANS;LLLVAR"
118
+ 118="ATT_ANS;LLLVAR"
119
+ 119="ATT_ANS;LLLVAR"
120
+ 120="ATT_ANS;LLLVAR"
121
+ 121="ATT_ANS;LLLVAR"
122
+ 122="ATT_ANS;LLLVAR"
123
+ 123="ATT_ANS;LLLVAR"
124
+ 124="ATT_ANS;LLLVAR"
125
+ 125="ATT_ANS;LLLVAR"
126
+ 126="ATT_ANS;LLLVAR"
127
+ 127="ATT_ANS;LLLVAR"
128
+ 128="ATT_B;8"
@@ -0,0 +1,44 @@
1
+
2
+ class MessageA < ISO8583::Message
3
+ include ISO8583
4
+ mti_format N, :length => 4
5
+
6
+ mti 800, ""
7
+ mti 810, ""
8
+
9
+ bmp 1 , "" , N , :length => 128
10
+ bmp 7 , "" , N , :length => 10
11
+ bmp 11 , "" , N , :length => 6
12
+ bmp 12 , "" , N , :length => 6
13
+ bmp 13 , "" , N , :length => 4
14
+ bmp 41 , "" , ANS , :length => 8
15
+ bmp 42 , "" , ANS , :length => 15
16
+ bmp 70 , "" , N , :length => 3
17
+ end
18
+
19
+ class DeviceISO8583BuildKlassTest < DaFunk::Test.case
20
+ def setup
21
+ @iso_a = MessageA.new 800
22
+ @klass = ISO8583::FileParser.build_klass([ISO8583::N, {length: 4}], {800 => ""}, "./shared/bitmap.dat")
23
+ @iso_b = @klass.new 800
24
+ end
25
+
26
+ def test_compare
27
+ @iso_a[7] = @iso_b[7] = 201175436
28
+ @iso_a[11] = @iso_b[11] = 2
29
+ @iso_a[12] = @iso_b[12] = 175436
30
+ @iso_a[13] = @iso_b[13] = 201
31
+ @iso_a[41] = @iso_b[41] = "00009815"
32
+ @iso_a[42] = @iso_b[42] = "636500050001800"
33
+ @iso_a[70] = @iso_b[70] = 1
34
+
35
+ assert_equal @iso_a.to_b, @iso_b.to_b
36
+ end
37
+
38
+ def test_parse_from_build_klass
39
+ iso = "08100038000002401004000043005016020300636500050001800924F7E771BC0F3C20690090020306376550063765599SS23S0EE0N00006043230060432399SS03S0FE0N0000"
40
+ @klass.mti 810, ""
41
+ assert_equal @klass.parse(iso, true)[42], "636500050001800"
42
+ end
43
+ end
44
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: da_funk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thiago Scalone
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-08 00:00:00.000000000 Z
11
+ date: 2016-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -110,10 +110,15 @@ files:
110
110
  - guides/sample_transaction_iso8583.rb
111
111
  - imgs/daft-punk-da-funk.jpg
112
112
  - lib/da_funk.rb
113
+ - lib/da_funk/callback_flow.rb
114
+ - lib/da_funk/file_parameter.rb
113
115
  - lib/da_funk/helper.rb
116
+ - lib/da_funk/i18n.rb
117
+ - lib/da_funk/i18n_error.rb
114
118
  - lib/da_funk/iso8583.rb
115
119
  - lib/da_funk/rake_task.rb
116
120
  - lib/da_funk/screen.rb
121
+ - lib/da_funk/screen_flow.rb
117
122
  - lib/da_funk/test.rb
118
123
  - lib/device.rb
119
124
  - lib/device/application.rb
@@ -160,6 +165,7 @@ files:
160
165
  - test/integration/mrb_eval_test.rb
161
166
  - test/integration/notification_test.rb
162
167
  - test/integration/params_dat_test.rb
168
+ - test/resources/shared/bitmap.dat
163
169
  - test/test_helper.rb
164
170
  - test/unit/device/application_test.rb
165
171
  - test/unit/device/display_test.rb
@@ -170,6 +176,7 @@ files:
170
176
  - test/unit/device/notification_test.rb
171
177
  - test/unit/ext/string_test.rb
172
178
  - test/unit/file_db_test.rb
179
+ - test/unit/iso8583_build_klass.rb
173
180
  - test/unit/iso8583_test.rb
174
181
  - test/unit/params_dat_test.rb
175
182
  - utils/command_line_platform.rb
@@ -203,6 +210,7 @@ test_files:
203
210
  - test/integration/mrb_eval_test.rb
204
211
  - test/integration/notification_test.rb
205
212
  - test/integration/params_dat_test.rb
213
+ - test/resources/shared/bitmap.dat
206
214
  - test/test_helper.rb
207
215
  - test/unit/device/application_test.rb
208
216
  - test/unit/device/display_test.rb
@@ -213,6 +221,7 @@ test_files:
213
221
  - test/unit/device/notification_test.rb
214
222
  - test/unit/ext/string_test.rb
215
223
  - test/unit/file_db_test.rb
224
+ - test/unit/iso8583_build_klass.rb
216
225
  - test/unit/iso8583_test.rb
217
226
  - test/unit/params_dat_test.rb
218
227
  has_rdoc: