Prerequisites

Settings and Cwfile.json

The CloudWalk Manager provides an interface for customizing an app's settings on the web, and the Cwfile.json completes it with an easy way to edit those settings from the terminal. By running bundle exec rake cloudwalk:deploy every information in the file will update the application attributes at CloudWalk Manager, for Ruby and POSXML applications.

Understanding Cwfile.json and Cwfile.json.lock

Cwfile.json.lock (DO NOT MODIFY THIS FILE, IT'S AUTOMATICALLY GENERATED) Contain the id's for all versions managed by Cwfile.json. Must be generated using the command bundle exec rake cloudwalk:update in every changed performed at Cwfile.json.

Cwfile.json is different between Ruby and POSXML applications, because a repository of a POSXML application supports any number of POSXML applications and modules.

Source code and DaFunk Framework API

Files and Directories

lib/ Contain .rb/.xml files that will be compiled.

test/ Contain all test ruby files.

Gemfile/Gemfile.lock Manage CloudWalk CLI version and any other Ruby gem

Cwfile.json/Cwfile.json.lock Manage CloudWalk Application attributes.

Rakefile Ruby task files.

Application and DaFunk API

In order to let you build amazing Ruby applications, we have made an API client available within Ruby, that gives you all the methods you will need to start developing, making it easy to interact with the POS terminal's screen, printer, keyboard, network and to process different types of payments without the overhead of starting from scratch or using a low level language. This tool is called DaFunk and it's open source. Please check the entire DaFunk API documentation.

A new application comes with the following source code in the lib/main.rb file:

It describes some of the main steps of building an application. Let's look at it in detail:

require 'simplehttp'

It is how gems are required. It is Ruby so there must be gems!

The simplehttp gem was required in the Gemfile at the root of the project, and it is also open source. If you are an experienced Ruby developer, this information could be enough for you to build your custom gems for your application!

class Main < Device

It is where the Main class is defined. This is a requirement, all your applications must have a Main class.

Note that it doesn't necessarily have to inherit from the Device class. If you don't inherit, you might write Device specific methods including the name of the class, for example instead of writing puts, you would write Device.puts.

def self.call

Function that is executed each time the application runs. This function is a requirement and must be defined. Note that this function is executed inside a loop, so plan ahead.

puts "Card..."

Displays the string Card... on the terminal screen.

getc

Holds the execution by asking for a key to be pressed.

true

At the end of the Main.call method states wether the loop must continue or not.

Hello world

As a simple example, we can change this application to welcome whoever runs it, ask for a name and then say greetings to the given name.