diff --git a/Gemfile b/Gemfile index 356e44a..d6144d2 100644 --- a/Gemfile +++ b/Gemfile @@ -11,3 +11,4 @@ gem "sinatra-activerecord", "~> 2.0" gem "rake", "~> 13.0" gem "sqlite3", "~> 1.4" gem "require_all", "~> 3.0" +gem 'tty-prompt', "~> 0.22.0" diff --git a/Gemfile.lock b/Gemfile.lock index 2f1380f..4c8cb6e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,46 +1,61 @@ GEM remote: https://rubygems.org/ specs: - activemodel (6.0.1) - activesupport (= 6.0.1) - activerecord (6.0.1) - activemodel (= 6.0.1) - activesupport (= 6.0.1) - activesupport (6.0.1) + activemodel (6.0.3.3) + activesupport (= 6.0.3.3) + activerecord (6.0.3.3) + activemodel (= 6.0.3.3) + activesupport (= 6.0.3.3) + activesupport (6.0.3.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - zeitwerk (~> 2.2) - coderay (1.1.2) - concurrent-ruby (1.1.5) - i18n (1.7.0) + zeitwerk (~> 2.2, >= 2.2.2) + coderay (1.1.3) + concurrent-ruby (1.1.7) + i18n (1.8.5) concurrent-ruby (~> 1.0) method_source (0.9.2) - minitest (5.13.0) - mustermann (1.0.3) + minitest (5.14.2) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + pastel (0.8.0) + tty-color (~> 0.5) pry (0.12.2) coderay (~> 1.1.0) method_source (~> 0.9.0) - rack (2.0.7) - rack-protection (2.0.7) + rack (2.2.3) + rack-protection (2.1.0) rack rake (13.0.1) require_all (3.0.0) - sinatra (2.0.7) + ruby2_keywords (0.0.2) + sinatra (2.1.0) mustermann (~> 1.0) - rack (~> 2.0) - rack-protection (= 2.0.7) + rack (~> 2.2) + rack-protection (= 2.1.0) tilt (~> 2.0) - sinatra-activerecord (2.0.14) - activerecord (>= 3.2) + sinatra-activerecord (2.0.18) + activerecord (>= 4.1) sinatra (>= 1.0) - sqlite3 (1.4.1) + sqlite3 (1.4.2) thread_safe (0.3.6) tilt (2.0.10) - tzinfo (1.2.5) + tty-color (0.5.2) + tty-cursor (0.7.1) + tty-prompt (0.22.0) + pastel (~> 0.8) + tty-reader (~> 0.8) + tty-reader (0.8.0) + tty-cursor (~> 0.7) + tty-screen (~> 0.8) + wisper (~> 2.0) + tty-screen (0.8.1) + tzinfo (1.2.7) thread_safe (~> 0.1) - zeitwerk (2.2.2) + wisper (2.0.1) + zeitwerk (2.4.0) PLATFORMS ruby @@ -52,6 +67,7 @@ DEPENDENCIES require_all (~> 3.0) sinatra-activerecord (~> 2.0) sqlite3 (~> 1.4) + tty-prompt (~> 0.22.0) BUNDLED WITH - 2.0.2 + 2.1.4 diff --git a/config/database.yml b/config/database.yml index 7d4c3a6..6dc71df 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,3 +1,3 @@ development: adapter: sqlite3 - database: db/cats.sqlite3 \ No newline at end of file + database: db/music.sqlite3 \ No newline at end of file diff --git a/config/environment.rb b/config/environment.rb index 23718ce..16e9555 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,4 +1,7 @@ require 'bundler/setup' Bundler.require + +require 'tty-prompt' + require_all 'lib' \ No newline at end of file diff --git a/db/migrate/20201001134020_create_user_table.rb b/db/migrate/20201001134020_create_user_table.rb new file mode 100644 index 0000000..4f30ac6 --- /dev/null +++ b/db/migrate/20201001134020_create_user_table.rb @@ -0,0 +1,9 @@ +class CreateUserTable < ActiveRecord::Migration[6.0] + def change + create_table :users do |table| + table.string :name + table.integer :age + table.string :mood + end + end +end diff --git a/db/migrate/20201001134211_create_song_table.rb b/db/migrate/20201001134211_create_song_table.rb new file mode 100644 index 0000000..33e2e41 --- /dev/null +++ b/db/migrate/20201001134211_create_song_table.rb @@ -0,0 +1,9 @@ +class CreateSongTable < ActiveRecord::Migration[6.0] + def change + create_table :songs do |table| + table.string :title + table.string :artist + table.string :lyrics + end + end +end diff --git a/db/migrate/20201001141928_create_keyword_table.rb b/db/migrate/20201001141928_create_keyword_table.rb new file mode 100644 index 0000000..9140f08 --- /dev/null +++ b/db/migrate/20201001141928_create_keyword_table.rb @@ -0,0 +1,7 @@ +class CreateKeywordTable < ActiveRecord::Migration[6.0] + def change + create_table :keywords do |table| + table.string :mood + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..9e2ec70 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,31 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `rails +# db:schema:load`. When creating a new database, `rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2020_10_01_141928) do + + create_table "keywords", force: :cascade do |t| + t.string "mood" + end + + create_table "songs", force: :cascade do |t| + t.string "title" + t.string "artist" + t.string "lyrics" + end + + create_table "users", force: :cascade do |t| + t.string "name" + t.integer "age" + t.string "mood" + end + +end diff --git a/db/seeds.rb b/db/seeds.rb index e69de29..8a61b3a 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -0,0 +1,12 @@ +User.destroy_all +user1 = User.create(name: "Eric Christine", age: 22, mood: "happy") +user2 = User.create(name: "Marcos Lipic", age: 24, mood: "happy") + +Song.destroy_all +song1 = Song.create(title: "What's My Age Again?", artist: "Blink-182", lyrics: "carefree") +song2 = Song.create(title: "Electric Feel", artist: "MGMT", lyrics: "love") +song3 = Song.create(title: "Be Above It", artist: "Tame Impala", lyrics: "motivated") +song4 = Song.create(title: "Going Native", artist: "Summer Salt", lyrics: "happy") +song5 = Song.create(title: "Yer Blues", artist: "The Beatles", lyrics: "sad") + +# Keyword.create(user: user1, song: song4, mood: "happy") diff --git a/lib/cli.rb b/lib/cli.rb new file mode 100644 index 0000000..cb404f4 --- /dev/null +++ b/lib/cli.rb @@ -0,0 +1,22 @@ +class Cli + def welcome + system 'clear' + puts "Hello" + end + + def prompt + prompt = TTY::Prompt.new + prompt.select("Enter your mood", %w(Happy Sad Motivated Carefree Love)) + end + + def recommend_songs + if prompt + + end + + + + + + +end \ No newline at end of file diff --git a/lib/models/keyword.rb b/lib/models/keyword.rb new file mode 100644 index 0000000..6d19730 --- /dev/null +++ b/lib/models/keyword.rb @@ -0,0 +1,4 @@ +class Keyword < ActiveRecord::Base + belongs_to :user + belongs_to :song +end diff --git a/lib/models/song.rb b/lib/models/song.rb new file mode 100644 index 0000000..6f06d32 --- /dev/null +++ b/lib/models/song.rb @@ -0,0 +1,4 @@ +class Song < ActiveRecord::Base + has_many :keywords + has_many :users, through: :keywords +end \ No newline at end of file diff --git a/lib/models/user.rb b/lib/models/user.rb new file mode 100644 index 0000000..b32bc19 --- /dev/null +++ b/lib/models/user.rb @@ -0,0 +1,4 @@ +class User < ActiveRecord::Base + has_many :keywords + has_many :songs, through: :keywords +end \ No newline at end of file diff --git a/runner.rb b/runner.rb index fa3c59b..b7d511f 100644 --- a/runner.rb +++ b/runner.rb @@ -1,6 +1,12 @@ require_relative 'config/environment' -Cli.new.start_game +# Cli.new.start_game +# binding.pry +app = Cli.new +app.welcome +app.prompt + +app.mood \ No newline at end of file