- Use HAML, SCSS, coffeescript (when required), Rspec & guard (for testing)
- haml > erb
- SASS > CSS
- Use partials in Views to keep code clean : https://github.com/gadzooks/weather/blob/master/app/views/weather/index.html.haml
- Helpers : https://github.com/gadzooks/weather/blob/master/app/helpers/weather_helper.rb
- Skinny controller fat model : https://github.com/gadzooks/weather/blob/master/app/controllers/weather_controller.rb
- Use singleton pattern to keep track of latitude / longitudes : https://github.com/gadzooks/weather/blob/master/app/models/latitude_longitude.rb
- Strong cohesion, loose coupling : Use separate parser class to keep API specific details decoupled from rest of code and make it easier to plug in a different weather API : https://github.com/gadzooks/weather/blob/master/app/models/forecast/parser.rb
- Use ENUMs for forecast types : https://github.com/gadzooks/weather/blob/master/app/models/forecast/type.rb
- Make parallel service calls using Hydra :
weather/app/models/dark_sky/client.rb
Line 43 in 2e00d8e
- Store API secret key securely : https://github.com/gadzooks/weather/blob/master/app/models/dark_sky/client.rb
- Create class methods on the fly : https://github.com/gadzooks/weather/blob/master/app/models/forecast/time_series_summary.rb
- Create instant variables dynamically (DRY) : https://github.com/gadzooks/weather/blob/master/app/models/forecast/data.rb
- Dynamically set instance variable values and keep code DRY : https://github.com/gadzooks/weather/blob/master/app/models/forecast/data.rb
- RSpec for critical parsing code https://github.com/gadzooks/weather/blob/master/spec/models/forecast/parser_spec.rb
- Added acceptance tests using turnip (cucumber alernative)
- Rake task to run rails server in production locally
weather/lib/tasks/runlocally.rake
Line 1 in 3e37ff2
Where should I go hiking in the next week based on weather forecasts ?
I decided to build this simple website to answer that question for me. The Pacific NorthWest has a lot of micro-climates which means different parts of WA may have different weather even though they are not that far apart (from a geographic standpoint). I was tired of googling my favorite destinations one by one each time I wanted to decide where I should go to next. Enter this project.
- Sign up for a new dev account (only to run in prod mode) https://darksky.net/dev/account
- Upgrade Rails credetials as per https://www.engineyard.com/blog/rails-encrypted-credentials-on-rails-5.2
- Profit ??
- Typheus is setup to use Rails default cache
- To enable caching/disable in development : rails dev:cache
- Download this code.
- on command line, run : rails server
- localhost:3000/test for test data, localhost:3000 for real weather information.
bundle exec rspec bundle exec guard
- Stack - Rails 6.0, SCSS, haml, bootstrap, Rspec
- Weather API provided by VisualCrossing.com, DarkSKY
- Weather icons : http://erikflowers.github.io/weather-icons
# Install rails 6.0.0 :
gem install rails -v 6.0.0
# Create credentials :
rails credentials:edit
# Install postgres :
brew install postgres
# Create postgres user :
~/homebrew/bin/createuser -s postgres
# Log in and create weather_dev db :
createdb weather_dev
postgres=# create database weather_dev;
CREATE DATABASE
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-------------+-----------+----------+---------+-------+-------------------------
postgres | akarwande | UTF8 | C | C |
template0 | akarwande | UTF8 | C | C | =c/akarwande +
| | | | | akarwande=CTc/akarwande
template1 | akarwande | UTF8 | C | C | =c/akarwande +
| | | | | akarwande=CTc/akarwande
weather_dev | postgres | UTF8 | C | C |
(4 rows)
http://railsapps.github.io/tutorial-rails-mongoid-devise.html
- Move ahoy to mongo : https://github.com/andrewculver/ahoy#mongodb
- move devise to mongo : http://railsapps.github.io/tutorial-rails-mongoid-devise.html
- setup website on AWS using Elastic Beanstalk
- set up CICD with CodePipeline
- update travelweather.co to new website.
Based on Procfile at root.