diff --git a/rails_root/.gitignore b/rails_root/.gitignore index 44ec7cd..061e4ad 100644 --- a/rails_root/.gitignore +++ b/rails_root/.gitignore @@ -36,3 +36,6 @@ # Ignore simplecov code coverage results coverage/* + +# Ignore the temps from the static analyzer +sorbet \ No newline at end of file diff --git a/rails_root/Gemfile b/rails_root/Gemfile index 79bdf44..2818871 100644 --- a/rails_root/Gemfile +++ b/rails_root/Gemfile @@ -74,3 +74,8 @@ end group :production do gem 'pg' # for heroku deployment end + +# Use static analyzer and type checker +gem 'sorbet', :group => :development +gem 'sorbet-runtime' +gem 'tapioca', :group => :development, require: false diff --git a/rails_root/Gemfile.lock b/rails_root/Gemfile.lock index 3481c49..a044f53 100644 --- a/rails_root/Gemfile.lock +++ b/rails_root/Gemfile.lock @@ -178,6 +178,7 @@ GEM timeout net-smtp (0.4.0.1) net-protocol + netrc (0.11.0) nio4r (2.7.0) nokogiri (1.16.2-aarch64-linux) racc (~> 1.4) @@ -191,7 +192,10 @@ GEM racc (~> 1.4) nokogiri (1.16.2-x86_64-linux) racc (~> 1.4) + parallel (1.24.0) pg (1.5.4) + prettier_print (1.2.1) + prism (0.21.0) psych (5.1.2) stringio public_suffix (5.0.4) @@ -236,6 +240,9 @@ GEM thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) rake (13.1.0) + rbi (0.1.8) + prism (>= 0.18.0, < 0.22) + sorbet-runtime (>= 0.5.9204) rdoc (6.6.2) psych (>= 4.0.0) regexp_parser (2.9.0) @@ -272,6 +279,19 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) + sorbet (0.5.11255) + sorbet-static (= 0.5.11255) + sorbet-runtime (0.5.11255) + sorbet-static (0.5.11255-universal-darwin) + sorbet-static (0.5.11255-x86_64-linux) + sorbet-static-and-runtime (0.5.11255) + sorbet (= 0.5.11255) + sorbet-runtime (= 0.5.11255) + spoom (1.2.4) + erubi (>= 1.10.0) + sorbet-static-and-runtime (>= 0.5.10187) + syntax_tree (>= 6.1.1) + thor (>= 0.19.2) sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -288,8 +308,19 @@ GEM stimulus-rails (1.3.3) railties (>= 6.0.0) stringio (3.1.0) + syntax_tree (6.2.0) + prettier_print (>= 1.2.0) sys-uname (1.2.3) ffi (~> 1.1) + tapioca (0.12.0) + bundler (>= 2.2.25) + netrc (>= 0.11.0) + parallel (>= 1.21.0) + rbi (>= 0.1.4, < 0.2) + sorbet-static-and-runtime (>= 0.5.10820) + spoom (~> 1.2.0, >= 1.2.0) + thor (>= 1.2.0) + yard-sorbet thor (1.3.0) timeout (0.4.1) turbo-rails (2.0.2) @@ -310,6 +341,10 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) + yard (0.9.34) + yard-sorbet (0.8.1) + sorbet-runtime (>= 0.5) + yard (>= 0.9) zeitwerk (2.6.13) PLATFORMS @@ -335,9 +370,12 @@ DEPENDENCIES selenium-webdriver simplecov simplecov_json_formatter + sorbet + sorbet-runtime sprockets-rails sqlite3 (~> 1.4) stimulus-rails + tapioca turbo-rails tzinfo-data web-console diff --git a/rails_root/app/assets/stylesheets/common.css b/rails_root/app/assets/stylesheets/common.css new file mode 100644 index 0000000..1380f87 --- /dev/null +++ b/rails_root/app/assets/stylesheets/common.css @@ -0,0 +1,136 @@ +:root { + /* Primary Color */ + --color-aggie-maroon: #500001; + + /* Secondary Colors */ + --color-secondary-maroon: #3C0000; + --color-secondary-maroon-invert: #998543; + --color-secondary-blue: #003C71; + --color-secondary-blue-invert: #D6D3C4; + --color-secondary-green: #5B6236; + --color-secondary-green-invert: #F6F6F6; + --color-secondary-coffee: #744F28; + --color-secondary-coffee-invert: #EAEAEA; + + /* Links Colors */ + --color-link: #006483; + --color-link-hover: #004362; + + /* Main Palettes */ + --color-white: #FFFFFF; + --color-black: #000000; + --color-slate: #64748B; + --color-gray: #6B7280; + --color-zinc: #71717A; + --color-neutral: #737373; + --color-stone: #78716C; + --color-red: #EF4444; + --color-orange: #F97316; + --color-amber: #F59E0B; + --color-yellow: #EAB308; + --color-lime: #84CC16; + --color-green: #22C55E; + --color-emerald: #10B981; + --color-teal: #14B8A6; + --color-cyan: #06B6D4; + --color-sky: #0EA5E9; + --color-blue: #3B82F6; + --color-indigo: #6366F1; + --color-violet: #8B5CF6; + --color-purple: #A855F7; + --color-fuchsia: #D946EF; + --color-pink: #EC4899; + --color-rose: #F43F5E; +} + +/* Text Color Classes */ +.text-aggie-maroon { color: var(--color-aggie-maroon); } +.text-secondary-maroon { color: var(--color-secondary-maroon); } +.text-secondary-maroon-invert { color: var(--color-secondary-maroon-invert); } +.text-secondary-blue { color: var(--color-secondary-blue); } +.text-secondary-blue-invert { color: var(--color-secondary-blue-invert); } +.text-secondary-green { color: var(--color-secondary-green); } +.text-secondary-green-invert { color: var(--color-secondary-green-invert); } +.text-secondary-coffee { color: var(--color-secondary-coffee); } +.text-secondary-coffee-invert { color: var(--color-secondary-coffee-invert); } +.text-link { color: var(--color-link); } +.text-link:hover { color: var(--color-link-hover); } + +/* Background Color Classes */ +.bg-aggie-maroon { background-color: var(--color-aggie-maroon); } +.bg-secondary-maroon { background-color: var(--color-secondary-maroon); } +.bg-secondary-maroon-invert { background-color: var(--color-secondary-maroon-invert); } +.bg-secondary-blue { background-color: var(--color-secondary-blue); } +.bg-secondary-blue-invert { background-color: var(--color-secondary-blue-invert); } +.bg-secondary-green { background-color: var(--color-secondary-green); } +.bg-secondary-green-invert { background-color: var(--color-secondary-green-invert); } +.bg-secondary-coffee { background-color: var(--color-secondary-coffee); } +.bg-secondary-coffee-invert { background-color: var(--color-secondary-coffee-invert); } + +/* Text color classes */ +.text-gray-100 { color: #f7fafc; } +.text-gray-200 { color: #edf2f7; } +.text-gray-300 { color: #e2e8f0; } +.text-gray-400 { color: #cbd5e0; } +.text-gray-500 { color: #a0aec0; } +.text-gray-600 { color: #718096; } +.text-gray-700 { color: #4a5568; } +.text-gray-800 { color: #2d3748; } +.text-gray-900 { color: #1a202c; } + +.text-blue-100 { color: #dbeafe; } +.text-blue-200 { color: #bfdbfe; } +.text-blue-300 { color: #93c5fd; } +.text-blue-400 { color: #60a5fa; } +.text-blue-500 { color: #3b82f6; } +.text-blue-600 { color: #2563eb; } +.text-blue-700 { color: #1d4ed8; } +.text-blue-800 { color: #1e40af; } +.text-blue-900 { color: #1e3a8a; } + +.text-slate-100 { color: #f1f5f9; } +.text-slate-200 { color: #e2e8f0; } +.text-slate-300 { color: #cbd5e1; } +.text-slate-400 { color: #94a3b8; } +.text-slate-500 { color: #64748b; } +.text-slate-600 { color: #475569; } +.text-slate-700 { color: #334155; } +.text-slate-800 { color: #1e293b; } +.text-slate-900 { color: #0f172a; } + +.text-white { color: #fff; } +.text-black { color: #000; } + +/* Background color classes */ +.bg-gray-100 { background-color: #f7fafc; } +.bg-gray-200 { background-color: #edf2f7; } +.bg-gray-300 { background-color: #e2e8f0; } +.bg-gray-400 { background-color: #cbd5e0; } +.bg-gray-500 { background-color: #a0aec0; } +.bg-gray-600 { background-color: #718096; } +.bg-gray-700 { background-color: #4a5568; } +.bg-gray-800 { background-color: #2d3748; } +.bg-gray-900 { background-color: #1a202c; } + +.bg-blue-100 { background-color: #dbeafe; } +.bg-blue-200 { background-color: #bfdbfe; } +.bg-blue-300 { background-color: #93c5fd; } +.bg-blue-400 { background-color: #60a5fa; } +.bg-blue-500 { background-color: #3b82f6; } +.bg-blue-600 { background-color: #2563eb; } +.bg-blue-700 { background-color: #1d4ed8; } +.bg-blue-800 { background-color: #1e40af; } +.bg-blue-900 { background-color: #1e3a8a; } + +.bg-slate-100 { background-color: #f1f5f9; } +.bg-slate-200 { background-color: #e2e8f0; } +.bg-slate-300 { background-color: #cbd5e1; } +.bg-slate-400 { background-color: #94a3b8; } +.bg-slate-500 { background-color: #64748b; } +.bg-slate-600 { background-color: #475569; } +.bg-slate-700 { background-color: #334155; } +.bg-slate-800 { background-color: #1e293b; } +.bg-slate-900 { background-color: #0f172a; } + +.bg-white { background-color: #fff; } +.bg-black { background-color: #000; } diff --git a/rails_root/app/controllers/home_controller.rb b/rails_root/app/controllers/home_controller.rb new file mode 100644 index 0000000..95f2992 --- /dev/null +++ b/rails_root/app/controllers/home_controller.rb @@ -0,0 +1,4 @@ +class HomeController < ApplicationController + def index + end +end diff --git a/rails_root/app/helpers/home_helper.rb b/rails_root/app/helpers/home_helper.rb new file mode 100644 index 0000000..da58210 --- /dev/null +++ b/rails_root/app/helpers/home_helper.rb @@ -0,0 +1,15 @@ +module HomeHelper + def greeting_message + current_hour = Time.zone.now.hour + case current_hour + when 5..11 + "Good morning!" + when 12..17 + "Good afternoon!" + when 18..23, 0..4 + "Good evening!" + else + "Hello!" + end + end +end diff --git a/rails_root/app/views/home/index.html.erb b/rails_root/app/views/home/index.html.erb new file mode 100644 index 0000000..92933e2 --- /dev/null +++ b/rails_root/app/views/home/index.html.erb @@ -0,0 +1,10 @@ + + +

Home#index

+

Find me in app/views/home/index.html.erb

+

Welcome to My Rails App

+

This is the custom home page of your application.

+ +

<%= greeting_message %>, welcome to My Rails App

+ +
My name is aggie bo2sxxx
diff --git a/rails_root/app/views/layouts/application.html.erb b/rails_root/app/views/layouts/application.html.erb index 412fad1..cda4919 100644 --- a/rails_root/app/views/layouts/application.html.erb +++ b/rails_root/app/views/layouts/application.html.erb @@ -5,11 +5,14 @@ <%= csrf_meta_tags %> <%= csp_meta_tag %> + <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> <%= javascript_importmap_tags %> <%= render "layouts/header" %> <%= yield %> + diff --git a/rails_root/bin/tapioca b/rails_root/bin/tapioca new file mode 100755 index 0000000..a6ae757 --- /dev/null +++ b/rails_root/bin/tapioca @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'tapioca' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("tapioca", "tapioca") diff --git a/rails_root/config/routes.rb b/rails_root/config/routes.rb index e47955f..cf7d2d0 100644 --- a/rails_root/config/routes.rb +++ b/rails_root/config/routes.rb @@ -1,14 +1,15 @@ # frozen_string_literal: true Rails.application.routes.draw do + # Defines the root path route ("/") + root 'home#index' + + get 'home/index' + resources :survey_responses resources :survey_profiles - # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. - get 'up' => 'rails/health#show', as: :rails_health_check - - # Defines the root path route ("/") - # root "posts#index" + get "up" => "rails/health#show", as: :rails_health_check end diff --git a/rails_root/spec/helpers/home_helper_spec.rb b/rails_root/spec/helpers/home_helper_spec.rb new file mode 100644 index 0000000..85a0b36 --- /dev/null +++ b/rails_root/spec/helpers/home_helper_spec.rb @@ -0,0 +1,26 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the HomeHelper. For example: +# +# describe HomeHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe HomeHelper, type: :helper do + describe "#greeting_message" do + it "returns the correct greeting based on the time of day" do + allow(Time.zone).to receive(:now).and_return(Time.zone.parse("2024-01-01 10:00:00")) + expect(helper.greeting_message).to eq("Good morning!") + + allow(Time.zone).to receive(:now).and_return(Time.zone.parse("2024-01-01 14:00:00")) + expect(helper.greeting_message).to eq("Good afternoon!") + + allow(Time.zone).to receive(:now).and_return(Time.zone.parse("2024-01-01 20:00:00")) + expect(helper.greeting_message).to eq("Good evening!") + end + end +end diff --git a/rails_root/spec/requests/home_spec.rb b/rails_root/spec/requests/home_spec.rb new file mode 100644 index 0000000..fdbd642 --- /dev/null +++ b/rails_root/spec/requests/home_spec.rb @@ -0,0 +1,11 @@ +require 'rails_helper' + +RSpec.describe "Homes", type: :request do + describe "GET /index" do + it "returns http success" do + get "/home/index" + expect(response).to have_http_status(:success) + end + end + +end diff --git a/rails_root/spec/views/home/index.html.erb_spec.rb b/rails_root/spec/views/home/index.html.erb_spec.rb new file mode 100644 index 0000000..d10c136 --- /dev/null +++ b/rails_root/spec/views/home/index.html.erb_spec.rb @@ -0,0 +1,10 @@ +require 'rails_helper' + +RSpec.describe "home/index.html.erb", type: :view do + it "displays the welcome message" do + + render + + expect(rendered).to have_text("welcome to My Rails App") + end +end