This repo is an example on how to create a Ruby on Rails app to consume a forecast API.
Taking the assumption that we only want to call an API to show the forecast data, I am creating a rails app with the below command to skip database, mailer, and default test framework (I will bw using RSpec instead of MiniTest).
-
Create a new rails app, skipping database, mailer, and default test framework.
$ rails new forecast-rails -O -M -T
-
Setup your project gems/libraries environment installing RVM.
$ rvm install 2.7.1 $ rvm use 2.7.1@forecast-rails --create
-
Install libraries.
$ bundle install $ yarn install
-
Run the server
$ rails s
-
Yarn: instructions on yarnpkg.com/en/docs/install.
-
Stylelint: check the website.
$ yarn add --dev stylelint stylelint-config-standard stylelint-scss
-
Nokogiri: for issues see more in this link.
$ brew update $ xcode-select --install $ brew install libiconv $ brew link libiconv $ gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14
OR
$ gem install nokogiri -- \ --use-system-libraries \ --with-xml2-config=/usr/bin/xml2-config \ --with-xslt-config=/usr/bin/xslt-config
-
Credentials/Secrets
You can use this example of
./config/credentials.yml.enc
runningbin/rails credentials:show
. Be sure to get thesecret_key_base
running$ rake secret
:See more details in rails/rails#30067 and https://medium.com/cedarcode/rails-5-2-credentials-9b3324851336.
Tests are based in RSpec tool.
The scripts with desired contexts are at ./spec/models
and ./spec/features
folder.
Please, use git-flow branch model workflow to new features, hot-fixes, and releases:
- http://danielkummer.github.io/git-flow-cheatsheet
- http://nvie.com/posts/a-successful-git-branching-model
- https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow
This project is using some external APIs and to read and test them,
we can use the files in /doc/api
or in
Postman.
Things we have covered:
- Ruby version 2.7.1;
- Basic customized Rails app;
- System dependencies;
- Environment Configuration;
- How to run the test suite;
- Deployment instructions.
This is a personal project example, so we must not have a long list of contributors. Check it out here:
https://github.com/leompeters/forecast-rails/graphs/contributors
Forecast Rails is released under the MIT License.