Skip to content

Added HTTP gem #11

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

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
fe5c3b7
initial setup
lsampson1974 Jan 22, 2024
f82f644
UI Setup
lsampson1974 Jan 22, 2024
9c67032
More styling to the calculator face.
lsampson1974 Jan 22, 2024
2d80193
Began defining classes
lsampson1974 Jan 24, 2024
b1ec6b3
Finished Display class
lsampson1974 Jan 25, 2024
4b8c765
Finished Display class
lsampson1974 Jan 25, 2024
c8aec5c
Added All clear and equal functionality
lsampson1974 Jan 25, 2024
0f703fe
Finished basic calculator
lsampson1974 Jan 27, 2024
17e9dc1
Finished basic calculator
lsampson1974 Jan 27, 2024
b25a03b
Removed unnecessary newline
lsampson1974 Jan 27, 2024
1f95ab9
Corrections to display and begin work on scientific calculator
lsampson1974 Jan 28, 2024
fca2e7f
Finished scientific calculator starting GPT
lsampson1974 Jan 29, 2024
4b0b5c3
Finished GPT styling starting on response
lsampson1974 Jan 29, 2024
ff180d7
Added method to format the GPT response.
lsampson1974 Jan 29, 2024
c3d43a0
Added corrections to GPT mode
lsampson1974 Jan 29, 2024
d9ee114
Finished up GPT mode. Will start on Game mode.
lsampson1974 Jan 29, 2024
c40301f
Tic tac toe game coding started
lsampson1974 Jan 30, 2024
dda87b1
Finishing tic-tac-toe game
lsampson1974 Jan 30, 2024
74f1a47
Finishing tic tac toe
lsampson1974 Jan 31, 2024
4ef6c68
Finishing tic tac toe
lsampson1974 Jan 31, 2024
aea511e
Finishing tic tac toe
lsampson1974 Jan 31, 2024
449aa46
Finishing tic tac toe
lsampson1974 Jan 31, 2024
ab1ccbf
Creating hangman
lsampson1974 Jan 31, 2024
5b6f546
Began writing hangman
lsampson1974 Jan 31, 2024
75a723b
Finishing hangman
lsampson1974 Feb 1, 2024
0c2ba5e
Finishing hangman
lsampson1974 Feb 1, 2024
8414c7e
Finished hangman and app for now
lsampson1974 Feb 1, 2024
e378d9c
Finished with hangman and OMNICALC4 app for now
lsampson1974 Feb 1, 2024
b7a349d
Updated README.md
lsampson1974 Feb 2, 2024
ee2c725
Update README.md
lsampson1974 Feb 2, 2024
5a816a5
Update README.md
lsampson1974 Feb 2, 2024
d48613b
Update render.yaml
lsampson1974 Feb 2, 2024
d6e879b
Update README.md
lsampson1974 Feb 2, 2024
d86f380
Update README.md
lsampson1974 Feb 2, 2024
946ee28
Added HTTP gem
lsampson1974 Feb 2, 2024
db1e18b
Refactored and updated the games codes.
lsampson1974 Feb 5, 2024
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
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ruby "3.2.1"

gem "sinatra"
gem "sinatra-contrib"
gem "http"

# Use Puma as the app server
gem "puma", "~> 5.0"
Expand Down
17 changes: 17 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ GEM
rexml
debug_inspector (1.1.0)
diff-lcs (1.5.0)
domain_name (0.6.20240107)
draft_matchers (0.0.2)
capybara
color_namer
Expand All @@ -51,15 +52,30 @@ GEM
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
faraday-retry (1.0.3)
ffi (1.16.3)
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
rake
grade_runner (0.0.9)
activesupport (>= 2.3.5)
faraday-retry (~> 1.0.3)
octokit (~> 5.0)
oj (~> 3.13.12)
rake (~> 13)
hashdiff (1.0.1)
http (5.1.1)
addressable (~> 2.8)
http-cookie (~> 1.0)
http-form_data (~> 2.2)
llhttp-ffi (~> 0.4.0)
http-cookie (1.0.5)
domain_name (~> 0.5)
http-form_data (2.3.0)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
llhttp-ffi (0.4.0)
ffi-compiler (~> 1.0)
rake (~> 13.0)
matrix (0.4.2)
method_source (1.0.0)
mini_mime (1.1.5)
Expand Down Expand Up @@ -164,6 +180,7 @@ DEPENDENCIES
capybara
draft_matchers
grade_runner
http
i18n
pry
puma (~> 5.0)
Expand Down
74 changes: 61 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,66 @@
# sinatra-template
# OMNICALC 4

Use this repository to create new Sinatra apps.
This app is an extension of the OMNICALC lessons from previous modules.

Optionally, to use `ActiveRecord` for database operations, add to the `app.rb`:
It features:

```ruby
require "sinatra/activerecord"
```
* Basic and scientific calculators

* GPT Chat

* Hangman and Tic-tac-toe games

Note :
I wrote this app mostly to see the limitations and strengths of the Ruby language.
It still needs work in a couple of areas :

* Some of the code should be refactored.

* Maybe use a different font, so that the images in the games line up better.

I hope you have as much fun with this app as I had writing it.

# How to use the app :

Basic calculator :
------------------

You should be able to use this calculator like a normal calculator.

Scientific calculator :
-----------------------

This can also be used as a normal calculator with an exception:
The higher-math functions( exponent, factorial ) calls functions from mathjs api.

Here's the documentation :
https://mathjs.org/docs/reference/functions.html

Chat GPT :
----------

* Ask a question in the text box below the controls and click "SEND".

* Use the up and down arrows to scroll through the answer.

Games ( Hangman ) :
-------------------

* Click on the letter that you want to guess.

* If the guess is incorrect, a portion of the man will be drawn, if the man is completely drawn, then the game is over.

* If you correctly guess the word, then you win and the game is over.

* Click the "RESET" button for a new game.

Games ( Tic-tac-toe ) :
-----------------------

* Click any of the yellow buttons below the display, corresponding to the position on the board that you would like to draw your 'X'.

* The computer will automatically move.

* Clicking "RESET" will also reset this game.

And in the `config/environment.rb` file add this code block:

```ruby
configure do
# setup a database connection
set(:database, { adapter: "sqlite3", database: "db/development.sqlite3" })
end
```
Loading