Setup and dependency installations
(Windows)
In order to work with this ruby sample; you must make sure you have ruby1.9.0 and above. And also have bundler installed. We use bundler for dependency management.
STEP 1: For Windows, there is a great project to help you install Ruby:RubyInstaller. It gives you everything you need to set up a full Ruby development environment on Windows.
We use sinatra for any web-specific samples; we picked sinatra because it’s very simple and allows for a quick start. It’s very un-opinionated and we love it!
Sinatra is a minimalist ruby framework that allows you to create web applications quickly.
STEP 2: Create a project folder:
>
md projectName
>
cd projectName
STEP 3: While in the folder, install the 'gemrat' gem which allows you to both install your dependencies and update the dependencies file Gemfile.
projectName> gem install gemrat
When moving to a new environment you can then quickly install all dependencies like so:
projectName> bundle install
Install sinatra as follows:
projectName> gemrat sinatra
To configure your application keys, it is advisable to use a .env to store the variables at in root of your project. You should also install the 'dotenv' gem.
projectName> gemrat dotenv
STEP 4: Using your favourite editor, for example sublime, atom, vim, create a .env file at the root of your project folder. In the .env file, include the configuration as follows:
AT_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
AT_API_USERNAME=YYYYYY
Access these variables when your application loads as follows:
gateway = AfricasTalkingGateway.new(ENV['AT_API_USERNAME'], ENV['AT_API_KEY'])
With your environment set up, you are now ready to start writing your application.
(Linux - *unix variants / mac)
In order to work with this ruby sample; you must make sure you have ruby1.9.0 and above. And also have bundler installed. We use bundler for dependency management.
You can find various great projects to help you install Ruby here - giving you everything you need to set up a full Ruby development environment.
We use sinatra for any web-specific samples; we picked sinatra because it’s very simple and allows for a quick start. It’s very un-opinionated and we love it!
Sinatra is a minimalist ruby framework that allows you to create web applications quickly.
STEP 1: Install Ruby globally.
$ sudo apt update && sudo apt install ruby-full
STEP 2: Create a project folder:
$
mkdir projectName
$
cd projectName
STEP 3: While in the folder, install the 'gemrat' gem which allows you to both install your dependencies and update the dependencies file Gemfile.
projectName$ sudo gem install gemrat
When moving to a new environment you can then quickly install all dependencies like so:
projectName$ sudo bundle install
Install sinatra as follows:
projectName$ sudo gemrat sinatra
STEP 4: To configure your application keys, it is advisable to use a .env to store the variables at in root of your project. You should also install the 'dotenv' gem.
projectName$ sudo gemrat dotenv
Using your favourite editor, for example sublime, atom, vim, create a .env file at the root of your project folder. In the .env file, include the configuration as follows:
AT_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
AT_API_USERNAME=YYYYYY
Access these variables when your application loads as follows:
gateway = AfricasTalkingGateway.new(ENV['AT_API_USERNAME'], ENV['AT_API_KEY'])
With your environment set up, you are now ready to start writing your application.