da_funk 0.4.5 → 0.4.8
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 +3 -0
- data/Gemfile.lock +11 -1
- data/RELEASE_NOTES.md +15 -0
- data/Rakefile +1 -3
- data/da_funk.gemspec +2 -1
- data/lib/da_funk.rb +0 -2
- data/lib/da_funk/rake_task.rb +4 -9
- data/lib/device.rb +1 -0
- data/lib/device/network.rb +9 -60
- data/lib/device/notification.rb +26 -2
- data/lib/device/notification_event.rb +13 -3
- data/lib/device/params_dat.rb +0 -6
- data/lib/device/setting.rb +2 -0
- data/lib/device/transaction/download.rb +4 -3
- data/lib/device/version.rb +2 -0
- data/lib/serfx/commands.rb +3 -1
- data/lib/serfx/connection.rb +8 -11
- data/test/integration/mrb_eval_test.rb +2 -2
- data/test/integration/notification_test.rb +27 -0
- data/utils/command_line_platform.rb +1 -1
- metadata +16 -4
- data/lib/device/walk.rb +0 -8
- data/lib/version.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1446cb5bdb03736d85f243da9e8a9bd46e6f8de
|
4
|
+
data.tar.gz: c4b5cde8b5971c7df4aec2f22fa7031d51149769
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 340d76d27f72033a38bd09af0e566f36f17f5a536fc4787724d982a8837660c7a7fbad209568157e229d43e90a9b70ad87a95bd22db7476c360e8bb0b3675196
|
7
|
+
data.tar.gz: 9a8412f650cd4c0b40885a2d5b2da3f22ee689330b000420c94410820c37147aeb18df16e08cb56b04f65de9960ecf98eec134777eec7b5960f23f76ce7ce8a5
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,22 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/scalone/walk-simplehttp-poc.git
|
3
|
+
revision: 9dad485f7a7c4e783651805b3e75a4779629b0cb
|
4
|
+
specs:
|
5
|
+
simplehttp (0.4.0)
|
6
|
+
|
1
7
|
PATH
|
2
8
|
remote: .
|
3
9
|
specs:
|
4
|
-
da_funk (0.4.
|
10
|
+
da_funk (0.4.8)
|
5
11
|
bundler (~> 1.7)
|
12
|
+
cloudwalk_handshake (~> 0.2.0)
|
6
13
|
rake (~> 10.4)
|
7
14
|
yard (~> 0.8)
|
8
15
|
|
9
16
|
GEM
|
10
17
|
remote: https://rubygems.org/
|
11
18
|
specs:
|
19
|
+
cloudwalk_handshake (0.2.0)
|
12
20
|
rake (10.4.2)
|
13
21
|
yard (0.8.7.6)
|
14
22
|
|
@@ -17,5 +25,7 @@ PLATFORMS
|
|
17
25
|
x86-mingw32
|
18
26
|
|
19
27
|
DEPENDENCIES
|
28
|
+
cloudwalk_handshake
|
20
29
|
da_funk!
|
30
|
+
simplehttp!
|
21
31
|
yard
|
data/RELEASE_NOTES.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
# DaFunk
|
2
2
|
|
3
|
+
### 0.4.8 - 2015-07-29 - CloudwalkHandshake as dependency
|
4
|
+
- Add CloudwalkHandshake as dependency.
|
5
|
+
|
6
|
+
### 0.4.7 - 2015-06-09 - New Notication Spec
|
7
|
+
- Fix gem out moving on mrb compilation.
|
8
|
+
- Abstract CloudWalk Handshake to other gem.
|
9
|
+
- Support new CloudWalk Notifcation spec.
|
10
|
+
- Support Notification timezone update.
|
11
|
+
- Support Notification show message.
|
12
|
+
- Changed Notification event check timeout for 5 seconds.
|
13
|
+
|
14
|
+
### 0.4.6 - 2015-06-12 - Timezone Setting
|
15
|
+
- Support cw_pos_timezone.
|
16
|
+
- Support cw_pos_version.
|
17
|
+
|
3
18
|
### 0.4.5 - 2015-06-09 - ISO8583, environment and abstraction classes
|
4
19
|
- Implementing support to change host environment configuration with Setting.to_production! and Setting.to_staging!.
|
5
20
|
- Fix da_funk.mrb out path getting the app name to output da_funk.mrb.
|
data/Rakefile
CHANGED
@@ -9,6 +9,7 @@ DA_FUNK_ROOT = File.dirname(File.expand_path(__FILE__))
|
|
9
9
|
FileUtils.cd DA_FUNK_ROOT
|
10
10
|
|
11
11
|
FILES = FileList[
|
12
|
+
"lib/device/version.rb",
|
12
13
|
"lib/da_funk.rb",
|
13
14
|
"lib/da_funk/test.rb",
|
14
15
|
"lib/device.rb",
|
@@ -26,8 +27,6 @@ FILES = FileList[
|
|
26
27
|
"lib/device/system.rb",
|
27
28
|
"lib/device/transaction/download.rb",
|
28
29
|
"lib/device/transaction/emv.rb",
|
29
|
-
"lib/device/version.rb",
|
30
|
-
"lib/device/walk.rb",
|
31
30
|
"lib/file_db.rb",
|
32
31
|
"lib/iso8583/bitmap.rb",
|
33
32
|
"lib/iso8583/codec.rb",
|
@@ -37,7 +36,6 @@ FILES = FileList[
|
|
37
36
|
"lib/iso8583/message.rb",
|
38
37
|
"lib/iso8583/util.rb",
|
39
38
|
"lib/iso8583/version.rb",
|
40
|
-
"lib/version.rb",
|
41
39
|
"lib/device/transaction/iso.rb",
|
42
40
|
"lib/serfx.rb",
|
43
41
|
"lib/serfx/commands.rb",
|
data/da_funk.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
tasks = File.expand_path('../tasks', __FILE__)
|
6
6
|
$LOAD_PATH.unshift(tasks) unless $LOAD_PATH.include?(tasks)
|
7
7
|
|
8
|
-
require 'version.rb'
|
8
|
+
require 'device/version.rb'
|
9
9
|
|
10
10
|
Gem::Specification.new do |spec|
|
11
11
|
spec.name = "da_funk"
|
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_dependency "rake", "~> 10.4"
|
29
29
|
spec.add_dependency "bundler", "~> 1.7"
|
30
30
|
spec.add_dependency "yard", "~> 0.8"
|
31
|
+
spec.add_dependency "cloudwalk_handshake", "~> 0.2.0"
|
31
32
|
end
|
data/lib/da_funk.rb
CHANGED
@@ -10,7 +10,6 @@ unless Object.const_defined?(:MTest)
|
|
10
10
|
require file_path + "/device/setting.rb"
|
11
11
|
require file_path + "/device/system.rb"
|
12
12
|
require file_path + "/device/version.rb"
|
13
|
-
require file_path + "/device/walk.rb"
|
14
13
|
require file_path + "/device/params_dat.rb"
|
15
14
|
require file_path + "/device.rb"
|
16
15
|
require file_path + "/file_db.rb"
|
@@ -22,7 +21,6 @@ unless Object.const_defined?(:MTest)
|
|
22
21
|
require file_path + "/iso8583/message.rb"
|
23
22
|
require file_path + "/iso8583/util.rb"
|
24
23
|
require file_path + "/iso8583/version.rb"
|
25
|
-
require file_path + "/version.rb"
|
26
24
|
require file_path + "/device/transaction/download.rb"
|
27
25
|
require file_path + "/device/transaction/emv.rb"
|
28
26
|
require file_path + "/device/transaction/iso.rb"
|
data/lib/da_funk/rake_task.rb
CHANGED
@@ -70,7 +70,7 @@ module DaFunk
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def check_gem_out(gem)
|
73
|
-
if File.exists?(path = File.join(gem.full_gem_path, "out", gem.name)) && File.file?(path)
|
73
|
+
if File.exists?(path = File.join(gem.full_gem_path, "out", "#{gem.name}.mrb")) && File.file?(path)
|
74
74
|
elsif File.exists?(path = File.join(gem.full_gem_path, "out", gem.name, "main.mrb")) && File.file?(path)
|
75
75
|
elsif File.exists?(path = File.join(gem.full_gem_path, "out", gem.name, "#{gem.name}.mrb")) && File.file?(path)
|
76
76
|
else
|
@@ -89,26 +89,21 @@ module DaFunk
|
|
89
89
|
resources.each_with_index do |file,dest_i|
|
90
90
|
FileUtils.cp(file, resources_out[dest_i]) if File.file?(file)
|
91
91
|
end
|
92
|
-
end
|
93
|
-
|
94
|
-
desc "Compile app to mrb and process resources"
|
95
|
-
task :build => :resources do
|
96
|
-
FileUtils.mkdir_p out_path
|
97
92
|
|
98
93
|
Bundler.load.specs.each do |gem|
|
99
94
|
path = check_gem_out(gem)
|
100
95
|
FileUtils.cp(path, File.join(out_path, "#{gem.name}.mrb")) if path
|
101
96
|
end
|
97
|
+
end
|
102
98
|
|
99
|
+
desc "Compile app to mrb and process resources"
|
100
|
+
task :build => :resources do
|
103
101
|
sh "#{mrbc} -g -o #{main_out} #{libs} "
|
104
102
|
end
|
105
103
|
|
106
104
|
namespace :test do
|
107
105
|
task :setup => :resources do
|
108
106
|
ENV["RUBY_PLATFORM"] = "mruby"
|
109
|
-
Bundler.load.specs.each do |gem|
|
110
|
-
sh "cp #{File.join(gem.full_gem_path, "out", gem.name)}.mrb #{out_path}/#{gem.name}.mrb" if File.exists? "#{File.join(gem.full_gem_path, "out", gem.name)}.mrb"
|
111
|
-
end
|
112
107
|
end
|
113
108
|
|
114
109
|
desc "Run unit test on mruby"
|
data/lib/device.rb
CHANGED
data/lib/device/network.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
|
2
|
+
require 'cloudwalk_handshake'
|
3
|
+
|
2
4
|
class Device
|
3
5
|
class Network
|
4
6
|
|
@@ -35,7 +37,13 @@ class Device
|
|
35
37
|
#AUTH_WPA_WPA2_EAP = "wpa_wpa2_eap"
|
36
38
|
|
37
39
|
class << self
|
38
|
-
attr_accessor :type, :apn, :user, :password, :socket
|
40
|
+
attr_accessor :type, :apn, :user, :password, :socket
|
41
|
+
end
|
42
|
+
|
43
|
+
self.socket = Proc.new do |avoid_walk|
|
44
|
+
sock = CloudwalkSocket.new
|
45
|
+
sock.connect(avoid_walk)
|
46
|
+
sock
|
39
47
|
end
|
40
48
|
|
41
49
|
def self.adapter
|
@@ -84,65 +92,6 @@ class Device
|
|
84
92
|
ret
|
85
93
|
end
|
86
94
|
|
87
|
-
def self.handshake_ssl!
|
88
|
-
@socket_ssl = self.handshake_ssl(@socket_tcp)
|
89
|
-
@ssl = true
|
90
|
-
@socket = @socket_ssl
|
91
|
-
end
|
92
|
-
|
93
|
-
def self.handshake_ssl(tcp)
|
94
|
-
return if tcp.closed?
|
95
|
-
entropy = PolarSSL::Entropy.new
|
96
|
-
ctr_drbg = PolarSSL::CtrDrbg.new entropy
|
97
|
-
s_ssl = PolarSSL::SSL.new
|
98
|
-
s_ssl.set_endpoint PolarSSL::SSL::SSL_IS_CLIENT
|
99
|
-
s_ssl.set_rng ctr_drbg
|
100
|
-
s_ssl.set_socket tcp
|
101
|
-
s_ssl.handshake
|
102
|
-
s_ssl
|
103
|
-
end
|
104
|
-
|
105
|
-
def self.handshake!
|
106
|
-
handshake = "#{Device::System.serial};#{Device::System.app};#{Device::Setting.logical_number};#{Device.version}"
|
107
|
-
socket.write("#{handshake.size.chr}#{handshake}")
|
108
|
-
|
109
|
-
company_name = socket_tcp.closed? ? nil : socket.read(3)
|
110
|
-
return false if company_name == "err" || company_name.nil?
|
111
|
-
|
112
|
-
Device::Setting.company_name = company_name
|
113
|
-
true
|
114
|
-
end
|
115
|
-
|
116
|
-
# Create Socket in Walk Switch
|
117
|
-
def self.walk_socket
|
118
|
-
if @socket
|
119
|
-
@socket
|
120
|
-
else
|
121
|
-
@socket_tcp = create_socket
|
122
|
-
if Device::Setting.ssl == "1"
|
123
|
-
handshake_ssl!
|
124
|
-
else
|
125
|
-
@socket = @socket_tcp
|
126
|
-
end
|
127
|
-
handshake!
|
128
|
-
@socket
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
def self.create_socket
|
133
|
-
TCPSocket.new(Device::Setting.host, Device::Setting.host_port)
|
134
|
-
end
|
135
|
-
|
136
|
-
def self.close_socket
|
137
|
-
@socket.close
|
138
|
-
if @socket != @socket_tcp
|
139
|
-
@socket_tcp.close
|
140
|
-
end
|
141
|
-
@socket = nil
|
142
|
-
@socket_tcp = nil
|
143
|
-
@socket_ssl = nil
|
144
|
-
end
|
145
|
-
|
146
95
|
def self.attach
|
147
96
|
Device::Network.init(*self.config)
|
148
97
|
ret = Device::Network.connect
|
data/lib/device/notification.rb
CHANGED
@@ -51,6 +51,11 @@ class Device
|
|
51
51
|
|
52
52
|
NotificationCallback.new "SYSTEM_UPDATE", :on => Proc.new { |file| }
|
53
53
|
NotificationCallback.new "CANCEL_SYSTEM_UPDATE", :on => Proc.new { }
|
54
|
+
NotificationCallback.new "TIMEZONE_UPDATE", :on => Proc.new { Device::Setting.cw_pos_timezone = "" }
|
55
|
+
NotificationCallback.new "SHOW_MESSAGE", :on => Proc.new { |message,datetime|
|
56
|
+
Device::Display.clear
|
57
|
+
Device::Display.print_line(message, 3)
|
58
|
+
}
|
54
59
|
end
|
55
60
|
|
56
61
|
def initialize(timeout = DEFAULT_TIMEOUT, interval = DEFAULT_INTERVAL, stream_timeout = DEFAULT_STREAM_TIMEOUT)
|
@@ -89,15 +94,34 @@ class Device
|
|
89
94
|
end
|
90
95
|
|
91
96
|
private
|
97
|
+
def reply(conn, ev)
|
98
|
+
if ev.is_a?(Hash)
|
99
|
+
if ev["Event"] == "user" && ev["Payload"] && ev["Payload"].include?("Id")
|
100
|
+
index = ev["Payload"].index("\"Id")
|
101
|
+
id = ev["Payload"][(index+7)..(index+38)]
|
102
|
+
conn.event(event_name, "{\"Id\"=>\"#{id}\"}", false)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
92
107
|
def create_fiber
|
93
108
|
Fiber.new do
|
94
|
-
|
95
|
-
|
109
|
+
auth = CloudwalkTOTP.at
|
110
|
+
Serfx.connect(authkey: auth, socket_block: Device::Network.socket, timeout: timeout, stream_timeout: stream_timeout) do |conn|
|
111
|
+
conn.stream(subscription) { |ev| reply(conn, ev) }
|
96
112
|
end
|
97
113
|
true
|
98
114
|
end
|
99
115
|
end
|
100
116
|
|
117
|
+
def subscription
|
118
|
+
"user:#{event_name}"
|
119
|
+
end
|
120
|
+
|
121
|
+
def event_name
|
122
|
+
"#{Device::Setting.company_name};#{Device::Setting.logical_number}"
|
123
|
+
end
|
124
|
+
|
101
125
|
def socket_callback
|
102
126
|
Proc.new do
|
103
127
|
socket_tcp = Device::Network.create_socket
|
@@ -19,11 +19,21 @@ class Device
|
|
19
19
|
@name = values["Name"]
|
20
20
|
@event = values["Event"]
|
21
21
|
|
22
|
-
@message = payload.gsub(
|
23
|
-
@value = JSON.parse(message)
|
24
|
-
@body = value
|
22
|
+
@message = payload.to_s.gsub("=>", " : ")
|
23
|
+
@value = JSON.parse(@message) unless @message.empty?
|
24
|
+
@body = extract_body(value)
|
25
25
|
|
26
26
|
@callback, *@parameters = @body.to_s.split("|")
|
27
27
|
end
|
28
|
+
|
29
|
+
def extract_body(value)
|
30
|
+
unless value.nil?
|
31
|
+
return value["Body"] if value["Body"]
|
32
|
+
# TODO: For some reason the JSON parse has a problem
|
33
|
+
# and extract "B" from "Body"
|
34
|
+
return value["ody"] if value["ody"]
|
35
|
+
end
|
36
|
+
end
|
28
37
|
end
|
29
38
|
end
|
39
|
+
|
data/lib/device/params_dat.rb
CHANGED
@@ -51,9 +51,6 @@ class Device
|
|
51
51
|
ret = Device::Transaction::Download.request_param_file(FILE_NAME)
|
52
52
|
if value = check_download_error(ret)
|
53
53
|
puts "Downloaded Successfully"
|
54
|
-
Device::Network.close_socket
|
55
|
-
# TODO
|
56
|
-
#Device::Network.walk_socket.close unless Device::Network.walk_socket.closed?
|
57
54
|
parse_apps
|
58
55
|
end
|
59
56
|
value
|
@@ -85,9 +82,6 @@ class Device
|
|
85
82
|
Device::Display.clear
|
86
83
|
puts "Downloading #{application.file}..."
|
87
84
|
ret = Device::Transaction::Download.request_file(application.file, application.zip)
|
88
|
-
Device::Network.close_socket
|
89
|
-
# TODO
|
90
|
-
#Device::Network.walk_socket.close unless Device::Network.walk_socket.closed?
|
91
85
|
|
92
86
|
unless check_download_error ret
|
93
87
|
sleep 2
|
data/lib/device/setting.rb
CHANGED
@@ -22,7 +22,7 @@ class Device
|
|
22
22
|
|
23
23
|
def self.request_file(remote_path, local_path)
|
24
24
|
download = Device::Transaction::Download.new(Device::System.serial, "", Device.version)
|
25
|
-
download.perform(Device::Network.
|
25
|
+
download.perform(Device::Network.socket,
|
26
26
|
Device::Setting.company_name,
|
27
27
|
remote_path, local_path, Device::System.app,
|
28
28
|
Device::Setting.logical_number)
|
@@ -44,8 +44,8 @@ class Device
|
|
44
44
|
# -1: Commnucation error
|
45
45
|
# -2: Mapreduce response error
|
46
46
|
# -3: IO Error
|
47
|
-
def perform(
|
48
|
-
@socket, @buffer, @request, @first_packet =
|
47
|
+
def perform(socket_proc, company_name, remote_path, filepath, current_app, logical_number, file_crc = nil)
|
48
|
+
@socket, @buffer, @request, @first_packet = socket_proc.call, "", "", ""
|
49
49
|
@crc = file_crc ? file_crc : generate_crc(filepath)
|
50
50
|
key = "#{company_name}_#{remote_path}"
|
51
51
|
|
@@ -107,6 +107,7 @@ class Device
|
|
107
107
|
|
108
108
|
# receive 6A
|
109
109
|
@socket.read(1) if response_size > 1024
|
110
|
+
@socket.close unless @socket.closed?
|
110
111
|
|
111
112
|
return_code
|
112
113
|
end
|
data/lib/device/version.rb
CHANGED
data/lib/serfx/commands.rb
CHANGED
@@ -7,7 +7,7 @@ module Serfx
|
|
7
7
|
#
|
8
8
|
# @return [Response]
|
9
9
|
def handshake
|
10
|
-
tcp_send(:handshake, 'Version' => 1)
|
10
|
+
tcp_send(:handshake, 'Version' => 1, 'SerialNumber' => Device::System.serial)
|
11
11
|
read_response(:handshake)
|
12
12
|
end
|
13
13
|
|
@@ -97,6 +97,7 @@ module Serfx
|
|
97
97
|
loop do
|
98
98
|
header, ev = read_data(self.stream_timeout)
|
99
99
|
check_rpc_error!(header)
|
100
|
+
block.call(ev) if block_given?
|
100
101
|
break unless fiber_yield!(ev)
|
101
102
|
end
|
102
103
|
res
|
@@ -136,6 +137,7 @@ module Serfx
|
|
136
137
|
loop do
|
137
138
|
header, ev = read_data
|
138
139
|
check_rpc_error!(header)
|
140
|
+
block.call(ev) if block_given?
|
139
141
|
break unless fiber_yield!(ev)
|
140
142
|
end
|
141
143
|
res
|
data/lib/serfx/connection.rb
CHANGED
@@ -4,7 +4,7 @@ module Serfx
|
|
4
4
|
# implement the actual RPC commands available via [Commands]
|
5
5
|
class Connection
|
6
6
|
MAX_MESSAGE_SIZE = 1024
|
7
|
-
DEFAULT_TIMEOUT =
|
7
|
+
DEFAULT_TIMEOUT = 5
|
8
8
|
COMMANDS = {
|
9
9
|
handshake: [:header],
|
10
10
|
auth: [:header],
|
@@ -29,29 +29,26 @@ module Serfx
|
|
29
29
|
|
30
30
|
include Serfx::Commands
|
31
31
|
|
32
|
-
attr_reader :host, :port, :seq, :socket, :
|
32
|
+
attr_reader :host, :port, :seq, :socket, :socket_block, :timeout, :stream_timeout
|
33
33
|
|
34
34
|
def close
|
35
|
-
@socket_tcp.close
|
36
35
|
@socket.close
|
37
36
|
end
|
38
37
|
|
39
38
|
def closed?
|
40
|
-
@
|
39
|
+
@socket.closed?
|
41
40
|
end
|
42
41
|
|
43
42
|
# @param opts [Hash] Specify the RPC connection details
|
44
|
-
# @option opts [TCPSocket] :socket_tcp Socket
|
45
43
|
# @option opts [SSL] :socket Socket SSL or normal tcp socket
|
46
44
|
# @option opts [Fixnum] :timeout Timeout in seconds to wait for a event and return Fiber
|
47
45
|
# @option opts [Symbol] :authkey encryption key for RPC communication
|
48
|
-
# @option opts [Block] :socket_block Callback to create socket if socket was closed, should return [socket
|
46
|
+
# @option opts [Block] :socket_block Callback to create socket if socket was closed, should return [socket]
|
49
47
|
def initialize(opts = {})
|
50
48
|
if @socket_block = opts[:socket_block]
|
51
|
-
@socket
|
49
|
+
@socket = @socket_block.call(true)
|
52
50
|
else
|
53
51
|
@socket = opts[:socket]
|
54
|
-
@socket_tcp = opts[:socket_tcp]
|
55
52
|
end
|
56
53
|
@timeout = opts[:timeout] || DEFAULT_TIMEOUT
|
57
54
|
@stream_timeout = opts[:stream_timeout] || DEFAULT_TIMEOUT
|
@@ -70,11 +67,11 @@ module Serfx
|
|
70
67
|
return if buf.nil?
|
71
68
|
|
72
69
|
# TODO Check first and second(header and body) packet size
|
73
|
-
first_packet, second_packet = buf
|
74
|
-
if second_packet.nil?
|
70
|
+
first_packet, second_packet = buf[0..12], buf[13..-1]
|
71
|
+
if second_packet.nil? || second_packet.empty?
|
75
72
|
[MessagePack.unpack(first_packet), nil]
|
76
73
|
else
|
77
|
-
[MessagePack.unpack(first_packet), MessagePack.unpack(
|
74
|
+
[MessagePack.unpack(first_packet), MessagePack.unpack(second_packet)]
|
78
75
|
end
|
79
76
|
end
|
80
77
|
|
@@ -10,7 +10,7 @@ class MrbEvalTest < DaFunk::Test.case
|
|
10
10
|
Device::Notification.check
|
11
11
|
|
12
12
|
http = SimpleHttp.new('http', 'http://google.com', 443)
|
13
|
-
http.socket = Device::Network.
|
13
|
+
http.socket = Device::Network.socket.call
|
14
14
|
assert_equal 302, http.get('/').code
|
15
15
|
|
16
16
|
command =<<EOF
|
@@ -24,7 +24,7 @@ class MrbEvalTest < DaFunk::Test.case
|
|
24
24
|
|
25
25
|
Device::Network.socket = nil
|
26
26
|
http = SimpleHttp.new('http', 'http://google.com', 80)
|
27
|
-
http.socket = Device::Network.
|
27
|
+
http.socket = Device::Network.socket.call
|
28
28
|
response = http.get('/')
|
29
29
|
Device::Network.socket = nil
|
30
30
|
response.code
|
@@ -1,9 +1,12 @@
|
|
1
1
|
|
2
2
|
class NotificationTest < DaFunk::Test.case
|
3
3
|
def test_notification
|
4
|
+
Device::Setting.to_staging!
|
4
5
|
Device::Setting.company_name = "pc1"
|
5
6
|
Device::Setting.logical_number = "0101"
|
7
|
+
Device::Notification.setup
|
6
8
|
notification = Device::Notification.new
|
9
|
+
|
7
10
|
assert_equal nil, notification.check
|
8
11
|
notification.check
|
9
12
|
notification.check
|
@@ -16,5 +19,29 @@ class NotificationTest < DaFunk::Test.case
|
|
16
19
|
notification.close
|
17
20
|
assert notification.closed?
|
18
21
|
end
|
22
|
+
|
23
|
+
def test_notification_SHOW_MESSAGE
|
24
|
+
$status = nil
|
25
|
+
Device::Setting.to_staging!
|
26
|
+
Device::Setting.company_name = "pc1"
|
27
|
+
Device::Setting.logical_number = "0101"
|
28
|
+
Device::Notification.setup
|
29
|
+
NotificationCallback.new "SHOW_MESSAGE", :on => Proc.new { |message,datetime|
|
30
|
+
$status = message
|
31
|
+
}
|
32
|
+
|
33
|
+
notification = Device::Notification.new
|
34
|
+
|
35
|
+
puts "Must create message AAAA"
|
36
|
+
time = Time.now + 60
|
37
|
+
while(time > Time.now && $status.nil?) do
|
38
|
+
notification.check
|
39
|
+
sleep 2
|
40
|
+
end
|
41
|
+
assert_equal "AAAA", $status
|
42
|
+
|
43
|
+
notification.close
|
44
|
+
assert notification.closed?
|
45
|
+
end
|
19
46
|
end
|
20
47
|
|
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.8
|
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-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: cloudwalk_handshake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.2.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.2.0
|
55
69
|
description: DaFunk is a Embedded System Framework optimized for programmer happiness
|
56
70
|
and sustainable productivity. It encourages beautiful code by favoring convention
|
57
71
|
over configuration.
|
@@ -109,7 +123,6 @@ files:
|
|
109
123
|
- lib/device/transaction/emv.rb
|
110
124
|
- lib/device/transaction/iso.rb
|
111
125
|
- lib/device/version.rb
|
112
|
-
- lib/device/walk.rb
|
113
126
|
- lib/ext/kernel.rb
|
114
127
|
- lib/file_db.rb
|
115
128
|
- lib/iso8583/bitmap.rb
|
@@ -125,7 +138,6 @@ files:
|
|
125
138
|
- lib/serfx/connection.rb
|
126
139
|
- lib/serfx/exceptions.rb
|
127
140
|
- lib/serfx/response.rb
|
128
|
-
- lib/version.rb
|
129
141
|
- lib/zip.rb
|
130
142
|
- test/integration/getc_test.rb
|
131
143
|
- test/integration/mrb_eval_test.rb
|
data/lib/device/walk.rb
DELETED