da_funk 0.4.4
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 +7 -0
- data/.gitignore +11 -0
- data/.yardopts +12 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +21 -0
- data/README.md +108 -0
- data/README_GUIDE.md +52 -0
- data/RELEASE_NOTES.md +23 -0
- data/Rakefile +69 -0
- data/da_funk.gemspec +31 -0
- data/ext/da_funk/Makefile +5 -0
- data/ext/da_funk/extconf.rb +8 -0
- data/guides/sample_input_output.rb +14 -0
- data/guides/sample_message_iso8583.rb +14 -0
- data/guides/sample_network_gprs.rb +26 -0
- data/guides/sample_read_magnect_card.rb +8 -0
- data/guides/sample_socket.rb +29 -0
- data/guides/sample_transaction.rb +23 -0
- data/guides/sample_transaction_download_application.rb +9 -0
- data/guides/sample_transaction_download_file.rb +6 -0
- data/guides/sample_transaction_download_parameter_file.rb +18 -0
- data/guides/sample_transaction_iso8583.rb +222 -0
- data/imgs/daft-punk-da-funk.jpg +0 -0
- data/lib/da_funk/rake_task.rb +129 -0
- data/lib/da_funk/test.rb +87 -0
- data/lib/da_funk.rb +39 -0
- data/lib/device/application.rb +41 -0
- data/lib/device/audio.rb +17 -0
- data/lib/device/crypto.rb +52 -0
- data/lib/device/display.rb +47 -0
- data/lib/device/helper.rb +161 -0
- data/lib/device/io.rb +86 -0
- data/lib/device/magnetic.rb +79 -0
- data/lib/device/network.rb +192 -0
- data/lib/device/notification.rb +116 -0
- data/lib/device/notification_callback.rb +47 -0
- data/lib/device/notification_event.rb +29 -0
- data/lib/device/params_dat.rb +119 -0
- data/lib/device/printer.rb +35 -0
- data/lib/device/runtime.rb +22 -0
- data/lib/device/setting.rb +63 -0
- data/lib/device/support.rb +28 -0
- data/lib/device/system.rb +61 -0
- data/lib/device/transaction/download.rb +268 -0
- data/lib/device/transaction/emv.rb +45 -0
- data/lib/device/transaction/iso.rb +75 -0
- data/lib/device/version.rb +11 -0
- data/lib/device/walk.rb +8 -0
- data/lib/device.rb +28 -0
- data/lib/ext/kernel.rb +9 -0
- data/lib/file_db.rb +47 -0
- data/lib/iso8583/bitmap.rb +114 -0
- data/lib/iso8583/codec.rb +197 -0
- data/lib/iso8583/exception.rb +4 -0
- data/lib/iso8583/field.rb +90 -0
- data/lib/iso8583/fields.rb +171 -0
- data/lib/iso8583/message.rb +455 -0
- data/lib/iso8583/util.rb +91 -0
- data/lib/iso8583/version.rb +6 -0
- data/lib/serfx/commands.rb +191 -0
- data/lib/serfx/connection.rb +160 -0
- data/lib/serfx/exceptions.rb +5 -0
- data/lib/serfx/response.rb +28 -0
- data/lib/serfx.rb +27 -0
- data/lib/version.rb +5 -0
- data/lib/zip.rb +29 -0
- data/test/integration/getc_test.rb +6 -0
- data/test/integration/mrb_eval_test.rb +36 -0
- data/test/integration/notification_test.rb +20 -0
- data/test/integration/params_dat_test.rb +11 -0
- data/test/test_helper.rb +18 -0
- data/test/unit/device/display_test.rb +43 -0
- data/test/unit/device/helper_test.rb +61 -0
- data/test/unit/device/notification_callback_test.rb +6 -0
- data/test/unit/device/notification_event_test.rb +73 -0
- data/test/unit/device/notification_test.rb +21 -0
- data/utils/command_line_platform.rb +67 -0
- data/utils/test_run.rb +3 -0
- metadata +177 -0
@@ -0,0 +1,73 @@
|
|
1
|
+
|
2
|
+
class NotificationEventTest < DaFunk::Test.case
|
3
|
+
def setup
|
4
|
+
@stream_event = {
|
5
|
+
"Coalesce" => true,
|
6
|
+
"LTime" => 1792,
|
7
|
+
"Payload" => "{\"Body\"=>\"message 62\"}",
|
8
|
+
"Name" => "pc1;0101",
|
9
|
+
"Event" => "user"
|
10
|
+
}
|
11
|
+
@event = Device::NotificationEvent.new(@stream_event)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_attr_coalesce
|
15
|
+
assert_equal @stream_event["Coalesce"], @event.coalesce
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_attr_ltim
|
19
|
+
assert_equal @stream_event["LTime"], @event.ltime
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_attr_payload
|
23
|
+
assert_equal @stream_event["Payload"], @event.payload
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_attr_name
|
27
|
+
assert_equal @stream_event["Name"], @event.name
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_attr_event
|
31
|
+
assert_equal @stream_event["Event"], @event.event
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_attr_message
|
35
|
+
assert_equal "{\"Body\" : \"message 62\"}", @event.message
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_attr_value
|
39
|
+
hash = {"Body" => "message 62"}
|
40
|
+
assert_equal hash, @event.value
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_attr_value
|
44
|
+
assert_equal "message 62", @event.body
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_attr_callback
|
48
|
+
assert_equal "message 62", @event.callback
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_attr_callback
|
52
|
+
assert_equal "message 62", @event.callback
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_attr_none_parameters
|
56
|
+
assert_equal [], @event.parameters
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_attr_one_parameter
|
60
|
+
stream_event = @stream_event.dup
|
61
|
+
stream_event["Payload"].gsub!("a", "|")
|
62
|
+
event = Device::NotificationEvent.new(stream_event)
|
63
|
+
assert_equal ["ge 62"], event.parameters
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_attr_multiple_parameters
|
67
|
+
stream_event = @stream_event.dup
|
68
|
+
stream_event["Payload"].gsub!("e", "|")
|
69
|
+
event = Device::NotificationEvent.new(stream_event)
|
70
|
+
assert_equal ["ssag", " 62"], event.parameters
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
class NotificationTest < DaFunk::Test.case
|
3
|
+
def setup
|
4
|
+
@notification = Device::Notification.new(15, 10)
|
5
|
+
end
|
6
|
+
|
7
|
+
def test_interval_last_check_blank
|
8
|
+
assert @notification.valid_interval?
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_interval_expired
|
12
|
+
@notification.instance_eval { @last_check = (Time.now - 11) }
|
13
|
+
assert @notification.valid_interval?
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_interval_not_expired
|
17
|
+
@notification.instance_eval { @last_check = Time.now }
|
18
|
+
assert_equal false, @notification.valid_interval?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Kernel
|
2
|
+
def getc(timeout = 0)
|
3
|
+
gets.chomp[0]
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
class CommandLinePlatform
|
8
|
+
IO = ::IO
|
9
|
+
|
10
|
+
class IO
|
11
|
+
def self.get_string(min, max, option = nil)
|
12
|
+
str = ""
|
13
|
+
while
|
14
|
+
str << gets.chomp
|
15
|
+
return str if str.size >= min
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Display
|
21
|
+
def self.print_in_line(buf, row = nil, column = nil)
|
22
|
+
buf = (" " * column) + buf if column != nil && column > 0
|
23
|
+
puts buf
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.clear
|
27
|
+
# No way to clear from the CLI yet
|
28
|
+
# we could use ncurses, but that's painful
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.clear_line(line = nil)
|
32
|
+
# No way to clear from the CLI yet
|
33
|
+
# we could use ncurses, but that's painful
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.display_bitmap(path, row, column)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class Network
|
41
|
+
def self.started?
|
42
|
+
true
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.connected?
|
46
|
+
1
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class System
|
51
|
+
def self.serial
|
52
|
+
"50111541"
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.restart
|
56
|
+
puts "Restart terminal!"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.version
|
61
|
+
"0.0.1"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
Device.adapter ||= CommandLinePlatform
|
66
|
+
Device::System.klass = "main"
|
67
|
+
|
data/utils/test_run.rb
ADDED
metadata
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: da_funk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Thiago Scalone
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '10.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '10.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: yard
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.8'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.8'
|
55
|
+
description: DaFunk is a Embedded System Framework optimized for programmer happiness
|
56
|
+
and sustainable productivity. It encourages beautiful code by favoring convention
|
57
|
+
over configuration.
|
58
|
+
email:
|
59
|
+
- thiago@cloudwalk.io
|
60
|
+
executables: []
|
61
|
+
extensions:
|
62
|
+
- ext/da_funk/extconf.rb
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- .gitignore
|
66
|
+
- .yardopts
|
67
|
+
- Gemfile
|
68
|
+
- Gemfile.lock
|
69
|
+
- README.md
|
70
|
+
- README_GUIDE.md
|
71
|
+
- RELEASE_NOTES.md
|
72
|
+
- Rakefile
|
73
|
+
- da_funk.gemspec
|
74
|
+
- ext/da_funk/Makefile
|
75
|
+
- ext/da_funk/extconf.rb
|
76
|
+
- guides/sample_input_output.rb
|
77
|
+
- guides/sample_message_iso8583.rb
|
78
|
+
- guides/sample_network_gprs.rb
|
79
|
+
- guides/sample_read_magnect_card.rb
|
80
|
+
- guides/sample_socket.rb
|
81
|
+
- guides/sample_transaction.rb
|
82
|
+
- guides/sample_transaction_download_application.rb
|
83
|
+
- guides/sample_transaction_download_file.rb
|
84
|
+
- guides/sample_transaction_download_parameter_file.rb
|
85
|
+
- guides/sample_transaction_iso8583.rb
|
86
|
+
- imgs/daft-punk-da-funk.jpg
|
87
|
+
- lib/da_funk.rb
|
88
|
+
- lib/da_funk/rake_task.rb
|
89
|
+
- lib/da_funk/test.rb
|
90
|
+
- lib/device.rb
|
91
|
+
- lib/device/application.rb
|
92
|
+
- lib/device/audio.rb
|
93
|
+
- lib/device/crypto.rb
|
94
|
+
- lib/device/display.rb
|
95
|
+
- lib/device/helper.rb
|
96
|
+
- lib/device/io.rb
|
97
|
+
- lib/device/magnetic.rb
|
98
|
+
- lib/device/network.rb
|
99
|
+
- lib/device/notification.rb
|
100
|
+
- lib/device/notification_callback.rb
|
101
|
+
- lib/device/notification_event.rb
|
102
|
+
- lib/device/params_dat.rb
|
103
|
+
- lib/device/printer.rb
|
104
|
+
- lib/device/runtime.rb
|
105
|
+
- lib/device/setting.rb
|
106
|
+
- lib/device/support.rb
|
107
|
+
- lib/device/system.rb
|
108
|
+
- lib/device/transaction/download.rb
|
109
|
+
- lib/device/transaction/emv.rb
|
110
|
+
- lib/device/transaction/iso.rb
|
111
|
+
- lib/device/version.rb
|
112
|
+
- lib/device/walk.rb
|
113
|
+
- lib/ext/kernel.rb
|
114
|
+
- lib/file_db.rb
|
115
|
+
- lib/iso8583/bitmap.rb
|
116
|
+
- lib/iso8583/codec.rb
|
117
|
+
- lib/iso8583/exception.rb
|
118
|
+
- lib/iso8583/field.rb
|
119
|
+
- lib/iso8583/fields.rb
|
120
|
+
- lib/iso8583/message.rb
|
121
|
+
- lib/iso8583/util.rb
|
122
|
+
- lib/iso8583/version.rb
|
123
|
+
- lib/serfx.rb
|
124
|
+
- lib/serfx/commands.rb
|
125
|
+
- lib/serfx/connection.rb
|
126
|
+
- lib/serfx/exceptions.rb
|
127
|
+
- lib/serfx/response.rb
|
128
|
+
- lib/version.rb
|
129
|
+
- lib/zip.rb
|
130
|
+
- test/integration/getc_test.rb
|
131
|
+
- test/integration/mrb_eval_test.rb
|
132
|
+
- test/integration/notification_test.rb
|
133
|
+
- test/integration/params_dat_test.rb
|
134
|
+
- test/test_helper.rb
|
135
|
+
- test/unit/device/display_test.rb
|
136
|
+
- test/unit/device/helper_test.rb
|
137
|
+
- test/unit/device/notification_callback_test.rb
|
138
|
+
- test/unit/device/notification_event_test.rb
|
139
|
+
- test/unit/device/notification_test.rb
|
140
|
+
- utils/command_line_platform.rb
|
141
|
+
- utils/test_run.rb
|
142
|
+
homepage: http://github.com/cloudwalkio/da_funk
|
143
|
+
licenses:
|
144
|
+
- MIT
|
145
|
+
metadata: {}
|
146
|
+
post_install_message:
|
147
|
+
rdoc_options: []
|
148
|
+
require_paths:
|
149
|
+
- lib
|
150
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: 1.9.3
|
155
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
requirements: []
|
161
|
+
rubyforge_project:
|
162
|
+
rubygems_version: 2.2.2
|
163
|
+
signing_key:
|
164
|
+
specification_version: 4
|
165
|
+
summary: MRuby Embedded System Framework
|
166
|
+
test_files:
|
167
|
+
- test/integration/getc_test.rb
|
168
|
+
- test/integration/mrb_eval_test.rb
|
169
|
+
- test/integration/notification_test.rb
|
170
|
+
- test/integration/params_dat_test.rb
|
171
|
+
- test/test_helper.rb
|
172
|
+
- test/unit/device/display_test.rb
|
173
|
+
- test/unit/device/helper_test.rb
|
174
|
+
- test/unit/device/notification_callback_test.rb
|
175
|
+
- test/unit/device/notification_event_test.rb
|
176
|
+
- test/unit/device/notification_test.rb
|
177
|
+
has_rdoc:
|