Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solmaz Purser's attempt at the chitter challenge #2179

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"sqltools.connections": [
{
"previewLimit": 50,
"server": "localhost",
"port": 5432,
"driver": "CockroachDB",
"database": "Chitter",
"username": "postgres",
"name": "localhost"
}
]
}
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ source 'https://rubygems.org'

ruby '3.0.2'

gem 'pg'

group :test do
gem 'rspec'
gem 'simplecov', require: false
Expand All @@ -11,3 +13,8 @@ end
group :development, :test do
gem 'rubocop', '1.20'
end

gem "sinatra", "~> 3.0"
gem "sinatra-contrib", "~> 3.0"
gem "webrick", "~> 1.8"
gem "rack-test", "~> 2.1"
32 changes: 31 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@ GEM
ast (2.4.2)
diff-lcs (1.4.4)
docile (1.4.0)
multi_json (1.15.0)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
parallel (1.20.1)
parser (3.0.2.0)
ast (~> 2.4.1)
pg (1.4.6)
pg (1.4.6-x64-mingw-ucrt)
rack (2.2.6.4)
rack-protection (3.0.6)
rack
rack-test (2.1.0)
rack (>= 1.3)
rainbow (3.0.0)
regexp_parser (2.1.1)
rexml (3.2.5)
Expand Down Expand Up @@ -36,6 +46,7 @@ GEM
rubocop-ast (1.11.0)
parser (>= 3.0.1.1)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand All @@ -46,21 +57,40 @@ GEM
terminal-table
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.3)
sinatra (3.0.6)
mustermann (~> 3.0)
rack (~> 2.2, >= 2.2.4)
rack-protection (= 3.0.6)
tilt (~> 2.0)
sinatra-contrib (3.0.6)
multi_json
mustermann (~> 3.0)
rack-protection (= 3.0.6)
sinatra (= 3.0.6)
tilt (~> 2.0)
terminal-table (3.0.1)
unicode-display_width (>= 1.1.1, < 3)
tilt (2.1.0)
unicode-display_width (2.0.0)
webrick (1.8.1)

PLATFORMS
ruby
x64-mingw-ucrt

DEPENDENCIES
pg
rack-test (~> 2.1)
rspec
rubocop (= 1.20)
simplecov
simplecov-console
sinatra (~> 3.0)
sinatra-contrib (~> 3.0)
webrick (~> 1.8)

RUBY VERSION
ruby 3.0.2p107

BUNDLED WITH
2.2.26
2.4.11
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,26 @@ As a Maker
So that I can let people know what I am doing
I want to post a message (peep) to chitter

POST message to chitter

As a maker
So that I can see what others are saying
I want to see all peeps in reverse chronological order

GET message in reverse chronological order (newest first)

As a Maker
So that I can better appreciate the context of a peep
I want to see the time at which it was made

GET the time that the message was posted

As a Maker
So that I can post messages on Chitter as me
I want to sign up for Chitter

POST and GET user input by creating a sign up form

HARDER

As a Maker
Expand Down
39 changes: 39 additions & 0 deletions app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# file: app.rb
require './lib/message'
require 'sinatra/base'
require 'sinatra/reloader'
require './lib/database_connection'
require './lib/message_repository'

DatabaseConnection.connect

class Application < Sinatra::Base
# This allows the app code to refresh
# without having to restart the server.
configure :development do
register Sinatra::Reloader
end
post '/message' do
new_message = Message.new
@message = new_message
new_message.time = params[:time]
new_message.date = params[:date]
new_message.content = params[:content]

return erb(:message)
end
# Confirm that new messages have been added to the database
get '/message' do
repo = MessageRepository.new
@message = repo.all[0]

return erb(:message)
end

get '/message/order' do
# It returns messages in reverse chronological order, newest first
repo = MessageRepository.new
@message = repo.all.sort_by(&:date)
return erb(:message)
end
end
2 changes: 2 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative 'app'
run Application
Loading