CloudWalk Ruby Runtime - Creating a new app

  1. Prerequisites
  2. Creating a new POSXML/Ruby app
  3. Compiling
  4. Testing
  5. Deploying

This guide will walk you through the process of creating and emulating a new Ruby application using the CloudWalk CLI. Be aware of the prerequisites and follow all the steps carefully.

Prerequisites

  1. The CloudWalk CLI is installed

Creating a new POSXML/Ruby app

Assuming that the CloudWalk CLI is installed and is properly configured, let's run cloudwalk new -xml appication_name, where -xml indicates that a POSXML application should be created:

$ cloudwalk new -xml posxmltest
  create  .gitignore
  create  Gemfile
  create  Cwfile.json
  create  Rakefile
  create  lib/
  create  lib/posxmltest.xml
  create  test/
  create  test/unit/
  skip    test
  create  test/integration/
  create  test/test_helper.rb
  create  test/unit/posxmltest_test.rb
  create  test/integration/posxmltest_test.rb

Assuming that the CloudWalk CLI is installed and is properly configured, let's run cloudwalk new appication_name:

$ cloudwalk new rb_test
  create  .gitignore
  create  Gemfile
  create  Cwfile.json
  create  Rakefile
  create  lib/
  create  lib/main.rb
  create  test/
  create  test/unit/
  skip    test
  create  test/integration/
  create  test/test_helper.rb
  create  test/unit/rb_test_test.rb
  create  test/integration/rb_test_test.rb

After creating the applicaction, let's install gems and Cwfile.json.lock

$ cd application_name 
$ bundle install # Gemfile
Fetching gem metadata from https://rubygems.org/.....
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.5.0
Using io-like 0.3.0
Using bundler 1.15.1
Using cloudwalk_handshake 0.10.0
Using funky-tlv 0.2.3
Using archive-zip 0.10.0
Using cloudwalk 0.8.0
Using funky-emv 0.9.1
Using posxml_parser 0.23.0
Using da_funk 0.16.0
Bundle complete! 3 Gemfile dependencies, 10 gems now installed.
$ bundle exec rake cloudwalk:update # Cwfile.json.lock

Compiling

Once your application is created, you can compile using the command bundle exec rake cloudwalk:build, which is the same for Ruby/POSXML applications, but generating different outputs, for POSXML a .posxml file and for Ruby a .mrb

POSXML Compilation:

$ bundle exec rake cloudwalk:build 
cloudwalk compile -xml -o ./out/shared/posxmltest.posxml lib/posxmltest.xml
=> 27

Ruby Compilation:

$ bundle exec rake cloudwalk:build 
env cloudwalk compile -g -o ./out/rb_test/main.mrb lib/main.rb

Deploying

Once your application is created, you can deploy using the command bundle exec rake cloudwalk:deploy, which is the same for Ruby/POSXML applications, but deploying different files, for POSXML a .posxml file and for Ruby a .zip package with all structure

POSXML Deployment:

$ bundle exec rake cloudwalk:deploy 
cloudwalk compile -xml -o ./out/shared/posxmltest.posxml lib/posxmltest.xml
=> 27
=> Success Deployed

One POSXML file Deployment:

$ bundle exec rake cloudwalk:deploy lib/posxmltest.xml
cloudwalk compile -xml -o ./out/shared/posxmltest.posxml lib/posxmltest.xml
=> 27
=> Success Deployed

Ruby Deployment:

$ bundle exec rake cloudwalk:deploy 
env cloudwalk compile -g -o ./out/rb_test/main.mrb lib/main.rb
=> Success Deployed

Testing

To execute test files you can run the follow command:

$ bundle exec rake test 
env cloudwalk compile -g -o ./out/main/command_line_platform.mrb .../.rvm/gems/ruby-2.3.1/gems/da_funk-0.16.0/lib/da_funk/../../utils/command_line_platform.rb
env cloudwalk compile -g -o ./out/rb_test/test.mrb test/test_helper.rb lib/main.rb test/integration/rb_test_test.rb test/unit/rb_test_test.rb .../.rvm/gems/ruby-2.3.1/gems/da_funk-0.16.0/lib/da_funk/.
cd ./out
cloudwalk run -b rb_test/test.mrb

# Running tests:

Hello World!

...

Finished tests in 17.310441s, 0.1733 tests/s, 0.1733 assertions/s.

3 tests, 3 assertions, 0 failures, 0 errors, 0 skips

For Ruby application only the suite implements a Test API that emulate the same environment found in a device, more details in the next session Customizing an app →.