da_funk 0.4.10 → 0.4.11
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +11 -2
- data/RELEASE_NOTES.md +10 -0
- data/Rakefile +1 -0
- data/lib/da_funk/helper.rb +164 -0
- data/lib/da_funk/iso8583.rb +11 -0
- data/lib/da_funk.rb +4 -2
- data/lib/device/helper.rb +2 -160
- data/lib/device/params_dat.rb +2 -2
- data/lib/device/version.rb +1 -1
- data/lib/device.rb +2 -0
- data/lib/file_db.rb +12 -2
- data/lib/iso8583/bitmap.rb +1 -1
- data/out/da_funk.mrb +0 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4496b68749b99cd7e94762b1b777bfac209f9c3c
|
4
|
+
data.tar.gz: 93fb97750b50f3b1d8f300f0c966ba711368b1f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60b5ebee450a3bdec5338790b9a25f12726690edb5cb715cb1ac8754ee2dcf44660d4fbe9faaf10dc2d1386ce3011520d2571dd1654d5c20b9ccc9d15830c043
|
7
|
+
data.tar.gz: 5fd1b4533020cb09e6e67376e6fb6b831adc9289e868a35d76f2ff52f21f0c25587cc76d473153bdf678b11f831a87bf9f17405554b2405319627480a0422ef6
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -7,14 +7,23 @@ Walk Framework API, responsible for managed compatibility between implemented de
|
|
7
7
|
1. Install Ruby 1.9.3 (mruby compatible)
|
8
8
|
|
9
9
|
2. Bundle `$ bundle install`
|
10
|
-
|
10
|
+
|
11
|
+
## Load
|
12
|
+
|
13
|
+
### All
|
14
|
+
require 'da_funk'
|
15
|
+
|
16
|
+
### Only ISO8583 module
|
17
|
+
|
18
|
+
require 'da_funk/iso8583'
|
19
|
+
|
11
20
|
|
12
21
|
## Docs (yard)
|
13
22
|
|
14
23
|
1. Generate: `$ rake yard`
|
15
24
|
2. Open: `open docs/index.html`
|
16
25
|
|
17
|
-
## How to
|
26
|
+
## How to create Device
|
18
27
|
|
19
28
|
### Steps
|
20
29
|
|
data/RELEASE_NOTES.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# DaFunk
|
2
2
|
|
3
|
+
### 0.4.11 - 2015-09-02 - Minor fixes and ISO
|
4
|
+
- Bug fix strip key and value strings of FileDb.
|
5
|
+
- Add FileDb#sanitize to strip and clean string(from quotes).
|
6
|
+
- Update connection message.
|
7
|
+
- Remove application crc check for while.
|
8
|
+
- Add UI message to Notification process.
|
9
|
+
- Fix application selection when just a single application is available.
|
10
|
+
- Create DaFunk::Helper from Device::Helper.
|
11
|
+
- Isolate ISO8583 to be load individually by require, `require 'da_funk/iso8583'`.
|
12
|
+
|
3
13
|
### 0.4.10 - 2015-08-14 - Check CRC during App Update
|
4
14
|
- Update CloudwalkHandshake version.
|
5
15
|
- Support to check CRC during app update, avoiding unnecessary download.
|
data/Rakefile
CHANGED
@@ -0,0 +1,164 @@
|
|
1
|
+
module DaFunk
|
2
|
+
module Helper
|
3
|
+
def self.included(base)
|
4
|
+
base.extend self
|
5
|
+
end
|
6
|
+
|
7
|
+
def form(label, options = {})
|
8
|
+
Device::Display.clear
|
9
|
+
options = form_default(options)
|
10
|
+
default = options.delete(:default)
|
11
|
+
puts "#{label} (#{default}):"
|
12
|
+
string = get_format(options.delete(:min), options.delete(:max), options)
|
13
|
+
return default if string.nil? || string.empty?
|
14
|
+
string
|
15
|
+
end
|
16
|
+
|
17
|
+
def attach
|
18
|
+
Device::Display.clear
|
19
|
+
puts "Connecting..."
|
20
|
+
if Device::Network.connected? < 0
|
21
|
+
if (ret = Device::Network.attach) == 0
|
22
|
+
puts "Successfully Connected"
|
23
|
+
else
|
24
|
+
puts "Attach fail #{ret}"
|
25
|
+
sleep 4
|
26
|
+
return false
|
27
|
+
end
|
28
|
+
else
|
29
|
+
puts "Already connected"
|
30
|
+
end
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
# TODO Add i18n or something
|
35
|
+
def check_download_error(ret)
|
36
|
+
value = true
|
37
|
+
case ret
|
38
|
+
when Device::Transaction::Download::SERIAL_NUMBER_NOT_FOUND
|
39
|
+
puts "Serial number not found."
|
40
|
+
value = false
|
41
|
+
when Device::Transaction::Download::FILE_NOT_FOUND
|
42
|
+
puts "File not found."
|
43
|
+
value = false
|
44
|
+
when Device::Transaction::Download::FILE_NOT_CHANGE
|
45
|
+
puts "File is the same."
|
46
|
+
when Device::Transaction::Download::SUCCESS
|
47
|
+
puts "Success."
|
48
|
+
when Device::Transaction::Download::COMMUNICATION_ERROR
|
49
|
+
puts "Communication failure."
|
50
|
+
value = false
|
51
|
+
when Device::Transaction::Download::MAPREDUCE_RESPONSE_ERROR
|
52
|
+
puts "Encoding error."
|
53
|
+
value = false
|
54
|
+
when Device::Transaction::Download::IO_ERROR
|
55
|
+
puts "IO Error."
|
56
|
+
value = false
|
57
|
+
else
|
58
|
+
puts "Communication fail."
|
59
|
+
value = false
|
60
|
+
end
|
61
|
+
|
62
|
+
value
|
63
|
+
end
|
64
|
+
|
65
|
+
# @example
|
66
|
+
# {
|
67
|
+
# :default => {:detail => 10}, # default value to return if enter
|
68
|
+
# :number => true, # Add number to label or not
|
69
|
+
# "option X" => {:detail => 10},
|
70
|
+
# "option Y" => {:detail => 11}
|
71
|
+
# }
|
72
|
+
def menu(title, selection, options = {})
|
73
|
+
options[:number] = true if options[:number].nil?
|
74
|
+
|
75
|
+
Device::Display.clear
|
76
|
+
print_title(title, options[:default])
|
77
|
+
values = Hash.new
|
78
|
+
selection.each_with_index do |value,i|
|
79
|
+
values[i.to_i] = value[1]
|
80
|
+
if options[:number]
|
81
|
+
Device::Display.print("#{i+1} - #{value[0]}", i+2, 0)
|
82
|
+
else
|
83
|
+
Device::Display.print(value[0], i+2, 0)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
key = getc
|
88
|
+
|
89
|
+
return options[:default] if key == IO::ENTER || key == IO::CANCEL
|
90
|
+
[values[key.to_i - 1]].flatten.first
|
91
|
+
end
|
92
|
+
|
93
|
+
def number_to_currency(value, options = {})
|
94
|
+
options[:delimiter] ||= ","
|
95
|
+
options[:precision] ||= 2
|
96
|
+
options[:separator] ||= "."
|
97
|
+
|
98
|
+
if value.is_a? Float
|
99
|
+
number, unit = value.to_s.split(".")
|
100
|
+
unit = unit.to_s
|
101
|
+
len = number.size + unit.size
|
102
|
+
else
|
103
|
+
len = value.to_s.size
|
104
|
+
unit = value.to_s[(len - options[:precision])..-1]
|
105
|
+
if len <= options[:precision]
|
106
|
+
number = ""
|
107
|
+
else
|
108
|
+
number = value.to_s[0..(len - (options[:precision] + 1)).abs]
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
text = ""
|
113
|
+
i = 0
|
114
|
+
number.reverse.each_char do |ch|
|
115
|
+
i += 1
|
116
|
+
text << ch
|
117
|
+
text << options[:delimiter] if (i % 3 == 0) && (len - unit.size) != i
|
118
|
+
end
|
119
|
+
currency = [rjust(text.reverse, 1, "0"),rjust(unit, options[:precision], "0")].join options[:separator]
|
120
|
+
if options[:label]
|
121
|
+
options[:label] + currency
|
122
|
+
else
|
123
|
+
currency
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def ljust(string, size, new_string)
|
128
|
+
string_plain = string.to_s
|
129
|
+
if size > string_plain.size
|
130
|
+
string_plain + (new_string * (size - string_plain.size))
|
131
|
+
else
|
132
|
+
string_plain
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def rjust(string, size, new_string)
|
137
|
+
string_plain = string.to_s
|
138
|
+
if size > string_plain.size
|
139
|
+
(new_string * (size - string_plain.size)) + string_plain
|
140
|
+
else
|
141
|
+
string_plain
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
private
|
146
|
+
def form_default(options = {})
|
147
|
+
options[:default] ||= ""
|
148
|
+
options[:mode] ||= Device::IO::IO_INPUT_LETTERS
|
149
|
+
options[:min] ||= 0
|
150
|
+
options[:max] ||= 20
|
151
|
+
options
|
152
|
+
end
|
153
|
+
|
154
|
+
def print_title(string, default)
|
155
|
+
if default
|
156
|
+
puts("#{string} (#{default}):")
|
157
|
+
else
|
158
|
+
puts("#{string}:")
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
unless Object.const_defined?(:MTest)
|
2
|
+
file_path = File.join(File.dirname(File.realpath(__FILE__)), "..")
|
3
|
+
require file_path + "/iso8583/bitmap.rb"
|
4
|
+
require file_path + "/iso8583/codec.rb"
|
5
|
+
require file_path + "/iso8583/exception.rb"
|
6
|
+
require file_path + "/iso8583/field.rb"
|
7
|
+
require file_path + "/iso8583/fields.rb"
|
8
|
+
require file_path + "/iso8583/message.rb"
|
9
|
+
require file_path + "/iso8583/util.rb"
|
10
|
+
require file_path + "/iso8583/version.rb"
|
11
|
+
end
|
data/lib/da_funk.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
unless Object.const_defined?(:MTest)
|
2
2
|
file_path = File.dirname(File.realpath(__FILE__))
|
3
|
+
require file_path + "/da_funk/helper.rb"
|
4
|
+
require file_path + "/da_funk/iso8583.rb"
|
5
|
+
require file_path + "/da_funk/rake_task.rb"
|
6
|
+
require file_path + "/da_funk/test.rb"
|
3
7
|
require file_path + "/device/support.rb"
|
4
8
|
require file_path + "/device/helper.rb"
|
5
9
|
require file_path + "/device/crypto.rb"
|
@@ -24,8 +28,6 @@ unless Object.const_defined?(:MTest)
|
|
24
28
|
require file_path + "/device/transaction/download.rb"
|
25
29
|
require file_path + "/device/transaction/emv.rb"
|
26
30
|
require file_path + "/device/transaction/iso.rb"
|
27
|
-
require file_path + "/da_funk/rake_task.rb"
|
28
|
-
require file_path + "/da_funk/test.rb"
|
29
31
|
require file_path + "/../utils/command_line_platform.rb"
|
30
32
|
end
|
31
33
|
|
data/lib/device/helper.rb
CHANGED
@@ -1,163 +1,5 @@
|
|
1
1
|
class Device
|
2
|
-
|
3
|
-
|
4
|
-
base.extend Device::Helper
|
5
|
-
end
|
6
|
-
|
7
|
-
def form(label, options = {})
|
8
|
-
Device::Display.clear
|
9
|
-
options = form_default(options)
|
10
|
-
default = options.delete(:default)
|
11
|
-
puts "#{label} (#{default}):"
|
12
|
-
string = get_format(options.delete(:min), options.delete(:max), options)
|
13
|
-
return default if string.nil? || string.empty?
|
14
|
-
string
|
15
|
-
end
|
16
|
-
|
17
|
-
def attach
|
18
|
-
Device::Display.clear
|
19
|
-
puts "Connecting..."
|
20
|
-
if Device::Network.connected? < 0
|
21
|
-
if (ret = Device::Network.attach) == 0
|
22
|
-
puts "Connected #{ret}"
|
23
|
-
else
|
24
|
-
puts "Attach fail #{ret}"
|
25
|
-
sleep 4
|
26
|
-
return false
|
27
|
-
end
|
28
|
-
else
|
29
|
-
puts "Already connected"
|
30
|
-
end
|
31
|
-
true
|
32
|
-
end
|
33
|
-
|
34
|
-
# TODO Add i18n or something
|
35
|
-
def check_download_error(ret)
|
36
|
-
value = true
|
37
|
-
case ret
|
38
|
-
when Device::Transaction::Download::SERIAL_NUMBER_NOT_FOUND
|
39
|
-
puts "Serial number not found."
|
40
|
-
value = false
|
41
|
-
when Device::Transaction::Download::FILE_NOT_FOUND
|
42
|
-
puts "File not found."
|
43
|
-
value = false
|
44
|
-
when Device::Transaction::Download::FILE_NOT_CHANGE
|
45
|
-
puts "File is the same."
|
46
|
-
when Device::Transaction::Download::SUCCESS
|
47
|
-
puts "Success."
|
48
|
-
when Device::Transaction::Download::COMMUNICATION_ERROR
|
49
|
-
puts "Communication failure."
|
50
|
-
value = false
|
51
|
-
when Device::Transaction::Download::MAPREDUCE_RESPONSE_ERROR
|
52
|
-
puts "Encoding error."
|
53
|
-
value = false
|
54
|
-
when Device::Transaction::Download::IO_ERROR
|
55
|
-
puts "IO Error."
|
56
|
-
value = false
|
57
|
-
else
|
58
|
-
puts "Communication fail."
|
59
|
-
value = false
|
60
|
-
end
|
61
|
-
|
62
|
-
value
|
63
|
-
end
|
64
|
-
|
65
|
-
# @example
|
66
|
-
# {
|
67
|
-
# :default => {:detail => 10}, # default value to return if enter
|
68
|
-
# :number => true, # Add number to label or not
|
69
|
-
# "option X" => {:detail => 10},
|
70
|
-
# "option Y" => {:detail => 11}
|
71
|
-
# }
|
72
|
-
def menu(title, selection, options = {})
|
73
|
-
options[:number] = true if options[:number].nil?
|
74
|
-
|
75
|
-
Device::Display.clear
|
76
|
-
print_title(title, options[:default])
|
77
|
-
values = Hash.new
|
78
|
-
selection.each_with_index do |value,i|
|
79
|
-
values[i.to_i] = value[1]
|
80
|
-
if options[:number]
|
81
|
-
Device::Display.print("#{i+1} - #{value[0]}", i+2, 0)
|
82
|
-
else
|
83
|
-
Device::Display.print(value[0], i+2, 0)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
key = getc
|
88
|
-
|
89
|
-
return options[:default] if key == IO::ENTER || key == IO::CANCEL
|
90
|
-
[values[key.to_i - 1]].flatten.first
|
91
|
-
end
|
92
|
-
|
93
|
-
def number_to_currency(value, options = {})
|
94
|
-
options[:delimiter] ||= ","
|
95
|
-
options[:precision] ||= 2
|
96
|
-
options[:separator] ||= "."
|
97
|
-
|
98
|
-
if value.is_a? Float
|
99
|
-
number, unit = value.to_s.split(".")
|
100
|
-
unit = unit.to_s
|
101
|
-
len = number.size + unit.size
|
102
|
-
else
|
103
|
-
len = value.to_s.size
|
104
|
-
unit = value.to_s[(len - options[:precision])..-1]
|
105
|
-
if len <= options[:precision]
|
106
|
-
number = ""
|
107
|
-
else
|
108
|
-
number = value.to_s[0..(len - (options[:precision] + 1)).abs]
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
text = ""
|
113
|
-
i = 0
|
114
|
-
number.reverse.each_char do |ch|
|
115
|
-
i += 1
|
116
|
-
text << ch
|
117
|
-
text << options[:delimiter] if (i % 3 == 0) && (len - unit.size) != i
|
118
|
-
end
|
119
|
-
currency = [rjust(text.reverse, 1, "0"),rjust(unit, options[:precision], "0")].join options[:separator]
|
120
|
-
if options[:label]
|
121
|
-
options[:label] + currency
|
122
|
-
else
|
123
|
-
currency
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
def ljust(string, size, new_string)
|
128
|
-
string_plain = string.to_s
|
129
|
-
if size > string_plain.size
|
130
|
-
string_plain + (new_string * (size - string_plain.size))
|
131
|
-
else
|
132
|
-
string_plain
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
def rjust(string, size, new_string)
|
137
|
-
string_plain = string.to_s
|
138
|
-
if size > string_plain.size
|
139
|
-
(new_string * (size - string_plain.size)) + string_plain
|
140
|
-
else
|
141
|
-
string_plain
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
private
|
146
|
-
def form_default(options = {})
|
147
|
-
options[:default] ||= ""
|
148
|
-
options[:mode] ||= Device::IO::IO_INPUT_LETTERS
|
149
|
-
options[:min] ||= 0
|
150
|
-
options[:max] ||= 20
|
151
|
-
options
|
152
|
-
end
|
153
|
-
|
154
|
-
def print_title(string, default)
|
155
|
-
if default
|
156
|
-
puts("#{string} (#{default}):")
|
157
|
-
else
|
158
|
-
puts("#{string}:")
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
2
|
+
# Backward compatibility
|
3
|
+
Helper = DaFunk::Helper
|
162
4
|
end
|
163
5
|
|
data/lib/device/params_dat.rb
CHANGED
@@ -78,7 +78,7 @@ class Device
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def self.update_app(application)
|
81
|
-
if attach && application
|
81
|
+
if attach && application
|
82
82
|
Device::Display.clear
|
83
83
|
puts "Downloading #{application.file}..."
|
84
84
|
ret = Device::Transaction::Download.request_file(application.file, application.zip)
|
@@ -97,7 +97,7 @@ class Device
|
|
97
97
|
def self.executable_app
|
98
98
|
selected = self.executable_apps
|
99
99
|
if selected.size == 1
|
100
|
-
selected
|
100
|
+
selected.first
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
data/lib/device/version.rb
CHANGED
data/lib/device.rb
CHANGED
data/lib/file_db.rb
CHANGED
@@ -20,8 +20,9 @@ class FileDb
|
|
20
20
|
def parse(text)
|
21
21
|
text.split("\n").compact.each do |line|
|
22
22
|
key_value = line.split("=")
|
23
|
-
|
24
|
-
|
23
|
+
key, value = sanitize(key_value[0]), sanitize(key_value[1])
|
24
|
+
if key_value[1] && (@hash[key].nil? || @hash[key].empty?)
|
25
|
+
@hash[key] = value
|
25
26
|
end
|
26
27
|
end
|
27
28
|
end
|
@@ -43,5 +44,14 @@ class FileDb
|
|
43
44
|
def [](key)
|
44
45
|
@hash[key]
|
45
46
|
end
|
47
|
+
|
48
|
+
private
|
49
|
+
def sanitize(string)
|
50
|
+
new_string = string.to_s.strip
|
51
|
+
if new_string[0] == "\"" && new_string[-1] == "\""
|
52
|
+
new_string = new_string[1..-2]
|
53
|
+
end
|
54
|
+
new_string
|
55
|
+
end
|
46
56
|
end
|
47
57
|
|
data/lib/iso8583/bitmap.rb
CHANGED
@@ -11,7 +11,7 @@ module ISO8583
|
|
11
11
|
# In all likelyhood, you won't be using this class much, it's used
|
12
12
|
# transparently by the Message class.
|
13
13
|
class Bitmap
|
14
|
-
include
|
14
|
+
include DaFunk::Helper
|
15
15
|
# create a new Bitmap object. In case an iso message
|
16
16
|
# is passed in, that messages bitmap will be parsed. If
|
17
17
|
# not, this initializes and empty bitmap.
|
data/out/da_funk.mrb
CHANGED
Binary file
|
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.4.
|
4
|
+
version: 0.4.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thiago Scalone
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -96,6 +96,8 @@ files:
|
|
96
96
|
- guides/sample_transaction_iso8583.rb
|
97
97
|
- imgs/daft-punk-da-funk.jpg
|
98
98
|
- lib/da_funk.rb
|
99
|
+
- lib/da_funk/helper.rb
|
100
|
+
- lib/da_funk/iso8583.rb
|
99
101
|
- lib/da_funk/rake_task.rb
|
100
102
|
- lib/da_funk/test.rb
|
101
103
|
- lib/device.rb
|