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.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/README.md +159 -81
- data/RELEASE_NOTES.md +19 -0
- data/Rakefile +6 -0
- data/lib/da_funk/callback_flow.rb +50 -0
- data/lib/da_funk/file_parameter.rb +70 -0
- data/lib/da_funk/helper.rb +100 -35
- data/lib/da_funk/i18n.rb +77 -0
- data/lib/da_funk/i18n_error.rb +3 -0
- data/lib/da_funk/iso8583.rb +1 -0
- data/lib/da_funk/rake_task.rb +7 -1
- data/lib/da_funk/screen_flow.rb +30 -0
- data/lib/device.rb +1 -1
- data/lib/device/application.rb +75 -17
- data/lib/device/crypto.rb +2 -1
- data/lib/device/io.rb +5 -2
- data/lib/device/network.rb +12 -3
- data/lib/device/notification.rb +3 -3
- data/lib/device/params_dat.rb +102 -34
- data/lib/device/printer.rb +1 -1
- data/lib/device/setting.rb +6 -1
- data/lib/device/transaction/download.rb +11 -5
- data/lib/device/version.rb +1 -1
- data/lib/ext/string.rb +6 -0
- data/lib/file_db.rb +7 -3
- data/lib/iso8583/bitmap.rb +3 -6
- data/lib/iso8583/file_parser.rb +8 -10
- data/lib/iso8583/message.rb +9 -9
- data/lib/zip.rb +3 -3
- data/test/resources/shared/bitmap.dat +128 -0
- data/test/unit/iso8583_build_klass.rb +44 -0
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0126b30dd3adddbd22dafdc3a478ecba668298c5
|
4
|
+
data.tar.gz: b8b4ed57370dde40c82323491769c29ba6ad36fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04a5c2935a6a4a9c39cb31a45e088afec3625f18b1cb1a317e4c237db3b7e141b7152ee5c61a42b2bf6841c8eeb3103864a283f65152281eee97a030c06820eb
|
7
|
+
data.tar.gz: a4cfcd1395e0dade008fbf37326edaae6d738a2785cae0677d060446da0589c8bdd929f28474f61b708ff7f09d625c254f466b87daf7faad8ef8c1fad6342bbf
|
data/Gemfile.lock
CHANGED
@@ -7,7 +7,7 @@ GIT
|
|
7
7
|
PATH
|
8
8
|
remote: .
|
9
9
|
specs:
|
10
|
-
da_funk (0.
|
10
|
+
da_funk (0.6.0)
|
11
11
|
bundler (~> 1.7)
|
12
12
|
cloudwalk_handshake (~> 0.5)
|
13
13
|
posxml_parser (~> 0.6)
|
@@ -17,9 +17,9 @@ PATH
|
|
17
17
|
GEM
|
18
18
|
remote: https://rubygems.org/
|
19
19
|
specs:
|
20
|
-
cloudwalk_handshake (0.5.
|
21
|
-
posxml_parser (0.
|
22
|
-
rake (10.
|
20
|
+
cloudwalk_handshake (0.5.1)
|
21
|
+
posxml_parser (0.7.1)
|
22
|
+
rake (10.5.0)
|
23
23
|
yard (0.8.7.6)
|
24
24
|
|
25
25
|
PLATFORMS
|
data/README.md
CHANGED
@@ -1,102 +1,180 @@
|
|
1
|
-
# DaFunk
|
1
|
+
# DaFunk, a.k.a. CloudWalk Framework API
|
2
2
|
|
3
|
-
|
3
|
+
Our goal at [CloudWalk][1] is to provide you with the
|
4
|
+
necessary tools to build Point Of Sales (POS) applications
|
5
|
+
in an easy and innovative way. To do so, we've developed
|
6
|
+
a setup for MRuby programs that allows you to build and
|
7
|
+
ship modern day applications to all of your terminals
|
8
|
+
instantaneously. For that purpose, you will need to start
|
9
|
+
using the API that is provided by this repository.
|
4
10
|
|
5
|
-
##
|
11
|
+
## Index
|
12
|
+
|
13
|
+
- [Index](#index)
|
14
|
+
- [What do I have here?](#what-do-i-have-here)
|
15
|
+
- [How do I use this?](#how-do-i-use-this)
|
16
|
+
- [Adding support to other platforms](#adding-support-to-other-platforms)
|
17
|
+
- [I would like to contribute](#i-would-like-to-contribute)
|
18
|
+
|
19
|
+
## What do I have here?
|
20
|
+
|
21
|
+
This repository contains a set of files and folder that compose the
|
22
|
+
**CloudWalk Framework API**. The structure goes as follows:
|
23
|
+
|
24
|
+
- The `guides` directory, which contains a group of files that are intended to instruct how to use our framework.
|
25
|
+
- An `imgs` directory, containing a picture that references the creative origins of this project.
|
26
|
+
- A `lib` directory, which holds the main source code of our Framework API.
|
27
|
+
- An `out`directory, which has a previous generated binary of this project. All builds target this directory.
|
28
|
+
- A `test` directory with example test cases. Tests are divided by _integration_ tests and _unit_ tests.
|
29
|
+
- A `utils` folder that contains some scripts which are useful for us to perform tests or interact with the command line environment.
|
30
|
+
|
31
|
+
## How do I use this?
|
32
|
+
|
33
|
+
We strongly recommend using our framework API from our [application skeleton][3],
|
34
|
+
it has all the minimal files and the structure needed to build your first application.
|
6
35
|
|
7
|
-
|
36
|
+
Essentially add to your `Gemfile`:
|
8
37
|
|
9
|
-
|
38
|
+
```ruby
|
39
|
+
gem 'da_funk', :git => 'https://github.com/cloudwalkio/da_funk.git'
|
40
|
+
```
|
10
41
|
|
11
|
-
|
42
|
+
Then require `da_funk` in your application file!
|
12
43
|
|
13
|
-
|
14
|
-
|
44
|
+
```ruby
|
45
|
+
require 'da_funk'
|
46
|
+
```
|
15
47
|
|
16
|
-
|
48
|
+
For more advanced users only wanting to use the `iso8583` module, here's how you require it:
|
17
49
|
|
18
|
-
|
50
|
+
```ruby
|
51
|
+
require 'da_funk/iso8583'
|
52
|
+
```
|
19
53
|
|
20
|
-
|
21
|
-
|
54
|
+
A full tutorial on how to develop your first CloudWalk app
|
55
|
+
can be found here: <https://docs.cloudwalk.io/en/cli>,
|
56
|
+
or checkout this project's source code!
|
22
57
|
|
23
|
-
|
24
|
-
2. Open: `open docs/index.html`
|
58
|
+
## Adding support to other platforms
|
25
59
|
|
26
|
-
|
60
|
+
At CloudWalk we develop our framework targeting several POS terminal brands,
|
61
|
+
physical devices and even virtual devices (such as our web emulator).
|
62
|
+
To deal with the platform differences, we've created an abstraction layer
|
63
|
+
in da_funk that helps us modify our framework's behavior for our targets,
|
64
|
+
but ensuring the changes needed are minimal and separated from the
|
65
|
+
framework's source code. As an example, we offer our project:
|
66
|
+
[around_the_world][4], it is the recipe to have MRuby working on
|
67
|
+
non embedded platforms and with full compliance with DaFunk API.
|
27
68
|
|
28
|
-
|
69
|
+
The first step is to add `da_funk` as a submodule in your project, let's say you'll be hosting it on a git server,
|
70
|
+
proceed with:
|
29
71
|
|
30
|
-
|
72
|
+
git submodule add git@github.com:cloudwalkio/da_funk.git path/to/lib/da_funk
|
31
73
|
|
32
|
-
|
74
|
+
Then, in your application, before starting anything, define your
|
75
|
+
platform interface. The most important feature it needs to have is
|
76
|
+
a `setup` method, which will be called to configure and initialize
|
77
|
+
everything before the actual execution.
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
class PlatformInterface
|
81
|
+
def self.setup
|
82
|
+
# Configuration and initialization before apps execution
|
83
|
+
end
|
84
|
+
end
|
85
|
+
```
|
86
|
+
|
87
|
+
Then you'll need to define your custom classes, but following the structure
|
88
|
+
present in our [device][5] source code. These classes can be in the same file
|
89
|
+
as the one that has the setup method, here is an example:
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
class PlatformInterface
|
93
|
+
Network = ::Network # Implemented on C
|
94
|
+
IO = ::IO # Implemeted on C
|
95
|
+
|
96
|
+
class Display
|
97
|
+
def self.clear
|
98
|
+
::IO.display_clear
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.print_line(buf, row, column)
|
102
|
+
# <class created on C or PlatformInterface>._print_line(buf, row, column)
|
103
|
+
PlatformInterface._print_line(buf, row, column)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
```
|
33
108
|
|
34
|
-
|
109
|
+
Some important notes regarding your platform interface:
|
35
110
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
3. Develop interface required by DaFunk on PlatformInterface, could be the same file you have setup method.
|
111
|
+
- Be careful with the instance object variable, leave that for DaFunk.
|
112
|
+
- Put preference into using class methods instead of making calls as the interface.
|
113
|
+
- We might revise this in the future, but for now: any method defined for
|
114
|
+
platform-specific usages has to be defined with a name that starts with `_`,
|
115
|
+
for example: `_myMethod`.
|
43
116
|
|
44
|
-
|
45
|
-
|
46
|
-
IO = ::IO # Implemeted on C
|
117
|
+
Once you're comfortable with your platform class,
|
118
|
+
we need to set it up as the adapter to use by altering DaFunk's device class:
|
47
119
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
120
|
+
```ruby
|
121
|
+
class Device # Class from DaFunk
|
122
|
+
self.adapter = PlatformInterface
|
123
|
+
end
|
124
|
+
```
|
125
|
+
|
126
|
+
The adapter pattern is based is a well studied software design pattern,
|
127
|
+
we recommend you to read the [Wiki article][7], it's an interesting bit
|
128
|
+
of information that is rooted deep in our solutions.
|
59
129
|
|
60
|
-
|
130
|
+
Finally build it with `rake` or in a more specific manner, with: `mrbc -o platform.mrb </path/to/mrblib/**/*/.rb>`
|
61
131
|
|
62
|
-
|
63
|
-
|
64
|
-
|
132
|
+
In [this link][6] there is an example of the whole process. Enjoy the reading! :bowtie:
|
133
|
+
|
134
|
+
## I would like to contribute
|
65
135
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
136
|
+
So, you want to propose changes to our skeleton??!! Thank you sir! We appreciate it :bowtie:
|
137
|
+
|
138
|
+
Please follow the instructions:
|
139
|
+
|
140
|
+
1. Fork it under your github account!
|
141
|
+
2. Create your feature branch `git checkout -b my-new-feature`
|
142
|
+
3. Commit your changes `git commit -am 'Added some feature'`
|
143
|
+
4. Push to the branch `git push origin my-new-feature`
|
144
|
+
5. Create a new Pull Request!
|
145
|
+
|
146
|
+
## License
|
147
|
+
|
148
|
+
```
|
149
|
+
The MIT License (MIT)
|
150
|
+
|
151
|
+
Copyright (c) 2015 CloudWalk, Inc.
|
152
|
+
|
153
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
154
|
+
of this software and associated documentation files (the "Software"), to deal
|
155
|
+
in the Software without restriction, including without limitation the rights
|
156
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
157
|
+
copies of the Software, and to permit persons to whom the Software is
|
158
|
+
furnished to do so, subject to the following conditions:
|
159
|
+
|
160
|
+
The above copyright notice and this permission notice shall be included in all
|
161
|
+
copies or substantial portions of the Software.
|
162
|
+
|
163
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
164
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
165
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
166
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
167
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
168
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
169
|
+
SOFTWARE.
|
170
|
+
```
|
171
|
+
|
172
|
+
[1]: https://www.cloudwalk.io
|
173
|
+
[2]: https://www.cloudwalk.io/cli/
|
174
|
+
[3]: https://github.com/cloudwalkio/cloudwalk-skeleton
|
175
|
+
[4]: https://github.com/cloudwalkio/around_the_world
|
176
|
+
[5]: https://github.com/cloudwalkio/da_funk/tree/master/lib/device
|
177
|
+
[6]: https://github.com/cloudwalkio/mruby-cloudwalk-platform
|
178
|
+
[7]: https://en.wikipedia.org/wiki/Adapter_pattern
|
179
|
+
|
180
|
+

|
data/RELEASE_NOTES.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
# DaFunk
|
2
2
|
|
3
|
+
### 0.6.0 - 2016-02-02 - Support to i18n.
|
4
|
+
- Add support to i18n.
|
5
|
+
- Add I18n messages to ParamsDat/Files/Apps downloading.
|
6
|
+
- Add support to ISO8583 file parser.
|
7
|
+
- Implemented DaFunk::Helper#try_keys to abstract a helper responsible to wait for range of key only in a period.
|
8
|
+
- Implement classes CallbackFlow and ScreenFlow to abstract the development of complex screen flows.
|
9
|
+
- Refactoring Device::IO.get_format.
|
10
|
+
- Rjust Device::Crypto.crc16_hex return, 4 chars with “0”.
|
11
|
+
- Add support to current value on Device::IO.get_format.
|
12
|
+
- Send file CRC on file download.
|
13
|
+
- Implement String#integer?.
|
14
|
+
- Fix number_to_currency to not include label after conversion.
|
15
|
+
- Add pagination on Helper.menu.
|
16
|
+
- FileDb always work with key and values as string.
|
17
|
+
- Fix System Error during Notification Fiber catching all communication exceptions.
|
18
|
+
- Update cloudwalk_handshake version to 0.5.1.
|
19
|
+
- Update posxml_parser version to 0.7.1.
|
20
|
+
- Update readme file.
|
21
|
+
|
3
22
|
### 0.5.4 - 2016-01-08 - Update posxml_parser
|
4
23
|
- Update posxml_parser to version 0.6.1.
|
5
24
|
|
data/Rakefile
CHANGED
@@ -14,6 +14,11 @@ FILES = FileList[
|
|
14
14
|
"lib/da_funk.rb",
|
15
15
|
"lib/da_funk/test.rb",
|
16
16
|
"lib/da_funk/screen.rb",
|
17
|
+
"lib/da_funk/callback_flow.rb",
|
18
|
+
"lib/da_funk/screen_flow.rb",
|
19
|
+
"lib/da_funk/i18n_error.rb",
|
20
|
+
"lib/da_funk/i18n.rb",
|
21
|
+
"lib/da_funk/file_parameter.rb",
|
17
22
|
"lib/device.rb",
|
18
23
|
"lib/device/audio.rb",
|
19
24
|
"lib/device/crypto.rb",
|
@@ -38,6 +43,7 @@ FILES = FileList[
|
|
38
43
|
"lib/iso8583/message.rb",
|
39
44
|
"lib/iso8583/util.rb",
|
40
45
|
"lib/iso8583/version.rb",
|
46
|
+
"lib/iso8583/file_parser.rb",
|
41
47
|
"lib/device/transaction/iso.rb",
|
42
48
|
"lib/serfx.rb",
|
43
49
|
"lib/serfx/commands.rb",
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module DaFunk
|
2
|
+
class CallbackFlow
|
3
|
+
attr_accessor :next
|
4
|
+
attr_reader :block, :before, :bind
|
5
|
+
|
6
|
+
def initialize(bind, callback, &block)
|
7
|
+
@bind = bind
|
8
|
+
@block = block
|
9
|
+
@before = callback
|
10
|
+
callback.next = self if callback
|
11
|
+
end
|
12
|
+
|
13
|
+
def dispatch(result)
|
14
|
+
return if result.nil?
|
15
|
+
Device::Display.clear
|
16
|
+
route(check(bind.instance_exec(result, &block)))
|
17
|
+
end
|
18
|
+
|
19
|
+
def check(value)
|
20
|
+
unless [true, nil, false].include?(value)
|
21
|
+
value = check_keyboard(value)
|
22
|
+
end
|
23
|
+
value
|
24
|
+
end
|
25
|
+
|
26
|
+
def route(result)
|
27
|
+
if result
|
28
|
+
if @next
|
29
|
+
@next.dispatch(result)
|
30
|
+
else
|
31
|
+
true
|
32
|
+
end
|
33
|
+
elsif result.nil?
|
34
|
+
else
|
35
|
+
@before.dispatch(true)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def check_keyboard(value)
|
41
|
+
case value
|
42
|
+
when Device::IO::CANCEL; return nil
|
43
|
+
when Device::IO::BACK; return false
|
44
|
+
when Device::IO::ENTER; return true
|
45
|
+
end
|
46
|
+
true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module DaFunk
|
2
|
+
class FileParameter
|
3
|
+
FILEPATH = "./shared"
|
4
|
+
attr_accessor :crc
|
5
|
+
attr_reader :name, :file, :crc_local, :original, :remote
|
6
|
+
|
7
|
+
def self.delete(collection)
|
8
|
+
collection.each do |file_|
|
9
|
+
begin
|
10
|
+
file_.delete
|
11
|
+
rescue RuntimeError
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(name, crc)
|
17
|
+
@crc = crc
|
18
|
+
@original = name
|
19
|
+
@remote = @original.sub("#{Device::Setting.company_name}_", "")
|
20
|
+
@name = @original.sub("#{Device::Setting.company_name}_", "").split(".").first
|
21
|
+
@file = "#{FILEPATH}/#{@remote}"
|
22
|
+
@crc_local = @crc if File.exists?(@file)
|
23
|
+
end
|
24
|
+
|
25
|
+
def zip?
|
26
|
+
@original.to_s[-4..-1] == ".zip"
|
27
|
+
end
|
28
|
+
|
29
|
+
def exists?
|
30
|
+
File.exists? @file
|
31
|
+
end
|
32
|
+
|
33
|
+
def unzip
|
34
|
+
if zip? && exists?
|
35
|
+
Zip.uncompress(file, FILEPATH, false, false)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def download(force = false)
|
40
|
+
if force || outdated?
|
41
|
+
ret = Device::Transaction::Download.request_file(remote, file, crc_local)
|
42
|
+
else
|
43
|
+
ret = Device::Transaction::Download::FILE_NOT_CHANGE
|
44
|
+
end
|
45
|
+
@crc_local = @crc if ret == Device::Transaction::Download::SUCCESS
|
46
|
+
ret
|
47
|
+
end
|
48
|
+
|
49
|
+
def delete
|
50
|
+
File.delete(self.file) if exists?
|
51
|
+
end
|
52
|
+
|
53
|
+
def outdated?
|
54
|
+
return true unless exists?
|
55
|
+
unless @crc_local
|
56
|
+
handle = File.open(file)
|
57
|
+
@crc_local = Device::Crypto.crc16_hex(handle.read)
|
58
|
+
end
|
59
|
+
@crc_local != @crc
|
60
|
+
ensure
|
61
|
+
handle.close if handle
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
def remove_company(name)
|
66
|
+
name.split("_")[1..-1].join("_")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|