BYRD - Administrator’s and Developer’s Guide

BYRD SDK

Developing a data model can be a time consuming task if you have to deploy after every change. In order to accelerate the development of a data model, BYRD provides an SDK that allows to test and debug data model code locally.

Installing Ruby on Windows

We recommend to use the following installation recipe for Ruby on Windows:

  1. Download the file ruby-2.2.4-i386-mingw32.7z from http://rubyinstaller.org/ and install it, e.g. into the directory C:\ruby-2.2.4\.
  2. Download the file DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe from http://rubyinstaller.org/ and install it into C:\ruby-devkit-4.7.2\.
  3. Set the PATH variable accordingly, e.g. set PATH=C:\ruby-2.2.4\bin\;C:\ruby-devkit-4.7.2\bin\.
  4. In the Windows command prompt (CMD), please run the following command: gem install bundler

Installing Ruby on OS/X or Linux

For the Mac and for Linux, we recommend that you use the Ruby Version Manager (RVM) to install Ruby:

  \curl -sSL https://get.rvm.io | bash -s stable

With RVM, installing Ruby is as easy as:

  rvm install ruby-2.2.4 && rvm use --default ruby-2.2.4

Using the SDK

The BYRD SDK requires Ruby being installed at least in version 1.9. The easiest way to start using the SDK is by downloading the Sandpit Data Dodel from BYRD. It usually makes as a good starting point for a new data model.

You can download the Sandpit Model from the Data Model Exchange. Downloading the Sandpit Model

Inflate the data model into an empty directory. Contents of the Sandpit Model

Then open a command shell and change to the top-level directory of the Sandpit Data Model.

Open a Shell

Make sure that you have the bundler gem already installed in Ruby.

The command gem install bundler should yield an output like

  Successfully installed bundler-1.11.2
  Parsing documentation for bundler-1.11.2
  Done installing documentation for bundler after 3 seconds
  1 gem installed

If the bundler gem is installed correctly, you can install the other gems:

  bundle install

The output of this command should look like

  Fetching source index from http://app.syncmanager.com/rubygems/
  Fetching gem metadata from http://rubygems.org/
  Fetching version metadata from http://rubygems.org/
  Resolving dependencies...
  Installing mini_portile2 2.1.0
  Installing minitest 5.8.4
  Installing pkg-config 1.1.7
  Installing tdiff 0.3.3
  Installing rubyzip 1.2.0
  Using bundler 1.11.2
  Installing nokogiri 1.6.8
  Installing nokogiri-diff 0.2.0
  Installing syncmanager-sdk 0.9.0
  Bundle complete! 4 Gemfile dependencies, 9 gems now installed.
  Use `bundle show [gemname]` to see where a bundled gem is installed.
  Post-install message from nokogiri:
  Nokogiri is built with the packaged libraries: libxml2-2.9.4, libxslt-1.1.29, zlib-1.2.8, libiconv-1.14.

Now you can run the rake command

Open a Shell

The rake command runs the unit tests and creates a file demomodel.zip which you can use to upload your changed data model to BYRD again.

You can also run these steps separately with rake test and rake zip.

Adding own unit tests

As you add more attributes and validation rules to your data model, you probably want to add unit tests as well. To add more validation tests, open the file test-demomodel.rb, copy the method test_validate_string_mandatory and change the name of the copied method to something that fits what you want to test, e.g.

  def test_validate_other_attribute_mandatory
    validation_result = validate(@item, :other_attribute_mandatory)
    assert_equal [ 'Value must not be empty' ], validation_result
  end

The test method test_validate_gross_vs_net_weight provides a more sophisticated example.

The file test-demomodel-trafo-outbound.rb provides a framework to test XML transformations. Here the idea is that you have an XML file you feed into to the transformation script, in this example fixture-demomodel-01.xml. Furthermore, you have an expected outcome expectation-demomodel-01.xml you want to be produced by the transformation script. The test method test_outbound_01 ensures that the expectation is exactly matched.