Awesome App Dev Elite Mega Pro Hackers
To run the application there are no external dependencies, however, to run the tests you will need to have busted installed.
First, make sure you have luarocks
installed, there are instructions here on getting started.
After luarocks is installed open a terminal and run the command luarocks install busted
All of the unit tests in this project live in the ./corona-app/spec/
directory and must have a name ending in _spec.lua
(e.g. data-import_spec.lua
).
To run the tests, first make sure that you have the busted library installed, instructions here, then:
cd ./corona-app
busted
This project uses the Travis CI service to automatically run unit tests on commits and pull requests. The configuration for this service can be found in the .travis.yml
file in the project root. After submitting a pull request or pushing a commit the progress of the build can be seen at the projects Travis CI page.
To load country data in the application use the following code.
In a unit test
local countryImport = require("utils.country-import")
local countries = countryImport("data/country.json")
--[[
Countries is a table of country tables, each contains the following
country.name (eg 'Afghanistan')
country.score (eg 34)
country.flag (eg 'Afghanistan-01.png')
]]--
In Corona
local countryImport = require("utils.country-import")
local countries = countryImport(system.pathForFile("data/country.json"))
-- Same data as above example
There is a utility function provided in the ./corona-app/utils
directory that can be used to print the contents of a table.
Example Usage
local printTable = require("utils.print-table")
printTable({
foo = "bar",
hello = "world"
})
--[[
Would print to the console
{
hello: "world",
foo: "bar",
}
]]--
An .editorconfig
file is provided with the formatting standards for this repository. To use these standards in the Atom text editor install the editorconfig package.
To assist with consistent formatting across the whole codebase a JS script is provided that will parse the whole lua codebase and apply the formatting rules. This script is in the ./formatter
directory.
To use the script you must first install Node.js (a JavaScript runtime) which can be downloaded from this link. After installing Node.js open a terminal in the formatter directory and run the following command to install the package dependencies.
npm install
Once the dependencies are installed you can run the formatter with this command.
npm run format
If you wish to run the formatter in watch mode (will re-run the formatter on file change) then run the watch
command.
npm run watch