Skip to content

Commit

Permalink
automated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cycomachead authored and actions-user committed Nov 30, 2024
0 parents commit d9a00bd
Show file tree
Hide file tree
Showing 36 changed files with 1,598 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage
.bundle/
TAGS
*.swp
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--format documentation --color
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.6.6
3 changes: 3 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SimpleCov.start do
add_filter '/features/'
end
25 changes: 25 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
source 'https://rubygems.org'
ruby '2.6.6'

gem 'sinatra', '>= 2.0.2'
gem 'sinatra-flash', '0.3.0'

group :development, :test do
gem 'cucumber', '2.0.0'
gem 'cucumber-sinatra', '0.5.0'
gem 'capybara', '3.1'

gem 'rspec', '3.3.0'
gem 'rspec-autotest', '1.0.0'

gem 'rack-test', '0.6.3'
gem 'rack_session_access', '0.1.1'

gem 'byebug', '5.0.0'
gem 'launchy', '2.4.3'
gem 'rerun', '0.10.0'

gem 'simplecov', '0.16.1'
gem 'webmock', '3.3.0'
gem 'ZenTest', '4.11.2'
end
136 changes: 136 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
GEM
remote: https://rubygems.org/
specs:
ZenTest (4.11.2)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
builder (3.2.3)
byebug (5.0.0)
columnize (= 0.9.0)
capybara (3.1.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
xpath (~> 3.0)
celluloid (0.16.0)
timers (~> 4.0.0)
columnize (0.9.0)
crack (0.4.3)
safe_yaml (~> 1.0.0)
cucumber (2.0.0)
builder (>= 2.1.2)
cucumber-core (~> 1.1.3)
diff-lcs (>= 1.1.3)
gherkin (~> 2.12)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.1.2)
cucumber-core (1.1.3)
gherkin (~> 2.12.0)
cucumber-sinatra (0.5.0)
templater (>= 1.0.0)
diff-lcs (1.3)
docile (1.3.1)
extlib (0.9.16)
ffi (1.9.25)
gherkin (2.12.2)
multi_json (~> 1.3)
hashdiff (0.3.7)
highline (2.0.0)
hitimes (1.3.0)
json (2.1.0)
launchy (2.4.3)
addressable (~> 2.3)
listen (2.10.1)
celluloid (~> 0.16.0)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
mini_mime (1.0.1)
mini_portile2 (2.3.0)
multi_json (1.13.1)
multi_test (0.1.2)
mustermann (1.0.3)
nokogiri (1.8.4)
mini_portile2 (~> 2.3.0)
public_suffix (3.0.3)
rack (2.0.5)
rack-protection (2.0.3)
rack
rack-test (0.6.3)
rack (>= 1.0)
rack_session_access (0.1.1)
builder (>= 2.0.0)
rack (>= 1.0.0)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rerun (0.10.0)
listen (~> 2.7, >= 2.7.3)
rspec (3.3.0)
rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0)
rspec-mocks (~> 3.3.0)
rspec-autotest (1.0.0)
rspec-core (>= 2.99.0.beta1, < 4.0.0)
rspec-core (3.3.2)
rspec-support (~> 3.3.0)
rspec-expectations (3.3.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-mocks (3.3.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-support (3.3.0)
safe_yaml (1.0.4)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
sinatra (2.0.3)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.3)
tilt (~> 2.0)
sinatra-flash (0.3.0)
sinatra (>= 1.0.0)
templater (1.0.0)
diff-lcs (>= 1.1.2)
extlib (>= 0.9.5)
highline (>= 1.4.0)
tilt (2.0.8)
timers (4.0.4)
hitimes
webmock (3.3.0)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
xpath (3.1.0)
nokogiri (~> 1.8)

PLATFORMS
ruby

DEPENDENCIES
ZenTest (= 4.11.2)
byebug (= 5.0.0)
capybara (= 3.1)
cucumber (= 2.0.0)
cucumber-sinatra (= 0.5.0)
launchy (= 2.4.3)
rack-test (= 0.6.3)
rack_session_access (= 0.1.1)
rerun (= 0.10.0)
rspec (= 3.3.0)
rspec-autotest (= 1.0.0)
simplecov (= 0.16.1)
sinatra (>= 2.0.2)
sinatra-flash (= 0.3.0)
webmock (= 3.3.0)

RUBY VERSION
ruby 2.6.6p146

BUNDLED WITH
1.17.3
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: bundle exec rackup config.ru -p $PORT
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Wordguesser: a scaffolded (!) ESaaS getting-started assignment
=============================================================

(v1.1, September 2015. Written by Armando Fox and Nick Herson)
(some edits by mverdicchio 21 September 2015)
(refinements by Armando Fox September 2017)

In this assignment you'll be introduced to part of the basic cycle of creating SaaS in a disciplined way.

**NOTE: Do not clone this repo to your workspace. Fork it first, then clone your fork.**



Learning Goals
--------------
After completing this assignment, you will be able to:

* Create and deploy simple SaaS apps in your development environment, and deploy them to the public cloud
* Practice the basic workflow of test-driven development (TDD), in which tests are written before the code (so they fail when first run) and code is then added to make them pass
* Understand how SaaS frameworks such as Sinatra support the conceptual components of a three-tier SaaS application architecture
* Understand the challenges of adapting a non-SaaS application to a SaaS environment, including how to identify and manage application state
* Understand one use case of service-oriented architecture, in which your SaaS app relies on an external service's API (application programming interface) to provide part of the SaaS app's functionality.

Prerequisites
-------------
* You should be familiar with Ruby basics, for example by completing the Ruby Intro or Ruby Calisthenics assignment.
* You should have read [ESaaS](http://www.saasbook.info) Chapter 2, "The Architecture of SaaS Applications", and watched the accompanying videos in the [MOOC](http://www.saas-class.org).
* You should be comfortable with basic Git usage and how to push your code to GitHub, as described in Appendix A of [ESaaS](http://www.saasbook.info).
* You will need "survival level" Unix command-line skills and facility with an editor to edit code files.

**NOTE: You may find the [Sinatra documentation](https://sinatrarb.com) helpful to have on hand.**

Introduction
------------
The full Agile/XP cycle we follow in ESaaS includes talking to the customer, using BDD to develop scenarios, turning those scenarios into runnable integration/acceptance tests with Cucumber, using those scenarios plus TDD to drive the creation of actual code, and deploying the result of each iteration's work to the cloud.

In this introductory assignment, we've provided RSpec unit tests to let you use TDD to develop game logic for a word-guessing game. In the full Agile/XP cycle, you'd develop these tests yourself as you code.

You'll then use the Sinatra framework to make the Wordguesser game available as SaaS. Adapting the game logic for SaaS will introduce you to thinking about RESTful routes and service-oriented architecture. As you develop the "SaaS-ified" Wordguessing game, you'll use Cucumber to describe how gameplay will work from the player's point of view and as "full stack" integration tests that will drive SaaS development. In the full Agile/XP cycle, you'd develop Cucumber scenarios yourself based on consultation with the customer, and create the necessary *step definitions* (Cucumber code that turns plain-English scenarios into runnable tests). In this assignment we provide both the scenarios and step definitions for you.

You'll deploy your game to the cloud using Heroku, giving you experience in automating SaaS deployment.

**Why Sinatra?**

This assignment uses the simple [Sinatra](https://github.com/sinatra/sinatra) framework rather than Rails, so that you can focus on tools, mechanics, and SaaS concepts, all of which will readily map to Rails later. Since our app doesn't have a database and has very few functions, Sinatra is an easy way to get started.

Contents
---------

* Part 0: [Demystifying SaaS app creation](docs/part_0_create_saas_app.md)
* Part 1: [Wordguesser](docs/part_1_wordguesser.md)
* Part 2: [RESTful thinking for Wordguesser](docs/part_2_restful_thinking.md)
* Part 3: [Connecting WordGuesserGame to Sinatra](docs/part_3_connecting_wordguesser_to_sinatra.md)
* Part 4: [Introducing Cucumber](docs/part_4_cucumber.md)
* Part 5: [Corner Cases](docs/part_5_corner_cases.md)
* Part 6: [Conclusion](docs/part_6_conclusion.md)
* Part 7: [Optional Challenge Assignment](docs/part_7_optional_challenge.md)
64 changes: 64 additions & 0 deletions app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
require 'sinatra/base'
require 'sinatra/flash'
require_relative 'lib/wordguesser_game'

class WordGuesserApp < Sinatra::Base
enable :sessions
register Sinatra::Flash

before do
@game = session[:game] || WordGuesserGame.new('')
end

after do
session[:game] = @game
end

# These two routes are good examples of Sinatra syntax
# to help you with the rest of the assignment
get '/' do
redirect '/new'
end

get '/new' do
erb :new
end

post '/create' do
# NOTE: don't change next line - it's needed by autograder!
word = params[:word] || WordGuesserGame.get_random_word
# NOTE: don't change previous line - it's needed by autograder!

@game = WordGuesserGame.new(word)
redirect '/show'
end

# Use existing methods in WordGuesserGame to process a guess.
# If a guess is repeated, set flash[:message] to "You have already used that letter."
# If a guess is invalid, set flash[:message] to "Invalid guess."
post '/guess' do
params[:guess].to_s[0]
### YOUR CODE HERE ###
redirect '/show'
end

# Everytime a guess is made, we should eventually end up at this route.
# Use existing methods in WordGuesserGame to check if player has
# won, lost, or neither, and take the appropriate action.
# Notice that the show.erb template expects to use the instance variables
# wrong_guesses and word_with_guesses from @game.
get '/show' do
### YOUR CODE HERE ###
erb :show # You may change/remove this line
end

get '/win' do
### YOUR CODE HERE ###
erb :win # You may change/remove this line
end

get '/lose' do
### YOUR CODE HERE ###
erb :lose # You may change/remove this line
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 './app'
run WordGuesserApp
Loading

0 comments on commit d9a00bd

Please sign in to comment.