Find the perfect song for your codebase with CodeSongs!
CodeSongs allows a user to select a GitHub repository and a musical artist and then "Songify" their code to find that artists best matching songs for the code. To do so CodeSongs uses IBM's Watson Tone Analyzer to identify the occurring sentiments in the code as well as in the selected artists top songs. CodeSongs then uses a proprietary algorithm to match the repo with the best suited songs.
This repository is for the CodeSongs Microservice. For the other part of CodeSongs see the repository page on GitHub.
The purpose of this project was to practice OAuth, Database Design, Background Workers / Cron Tasks, and API calls, and to build a postgresql database with Sinatra.
- Consuming a number of various APIs
- Authenticated API calls
- Building features on Greenfield Code
- Building a Microservice
- Building a postgresql database in Sinatra
- Writing a cron task to automatically make API calls to seed and update database
- Test driven development
- Project planning
- Work with a deadline
- Prioritizing code functionality vs best practices
The CodeSongs Microservice is written in Ruby with Sinatra, uses a postgresql database, and is hosted on Heroku with the Travis CI integration tool.
The following Ruby Gems are used in this project:
- faraday
- figaro
- activerecord
- dotenv
- vcr
- webmock
- shotgun
- tux
- shoulda-matchers
- database_cleaner
- skylight
bundle exec rake db:create
bundle exec rake db:migrate
bundle exec rake db:seed
bundle exec rackup config.ru
RACK_ENV=test bundle exec rake db:{migrate,seed}
-
You can run the full testing suite with the command
bundle exec rspec
-
You can run an individual test using
bundle exec rspec <path-to-file>
Keep environment variables secure by using Figaro to generate an appliation.yml
file or by saving a .env
file in the root directory. See more information about using the figaro gem at or https://github.com/laserlemon/figaro the dotenv gem at https://github.com/bkeepers/.
Environment variables and required API keys/tokens (in Figaro format) :
- YouTube API key defined as
ENV['YOUTUBE_API_TOKEN']
- GitHub Token defined as
ENV['GITHUB_TEST_TOKEN']
- MusixMatch Token defined as
ENV['MUSIX_MATCH_TOKEN']
- Watson Token defined as
ENV['WATSON_TOKEN']
- Watson Instance defined as
ENV['WATSON_INSTANCE']
From time to time you may receive an error when testing with the VCR. You can delete the cassettes directory from your spec
folder and run bundle exec rspec
to refresh the cassettes used. More information on VCR cassettes can be found in the VCR documentation.
- Ruby 2.4.1
- Rails 5.2.4