Skip to content
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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ You can find them in the `spec/features` directory.

## Development

NOTE: Whenever you change a ruby file, you need to stop the server, and restart it.
NOTE: Whenever you change a ruby file, you need to stop the server, and restart it.

## Staging
URL: http://floating-savannah-1875.herokuapp.com/
5 changes: 0 additions & 5 deletions Rakefile

This file was deleted.

8 changes: 4 additions & 4 deletions config/menu.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name,price,description,image
Channa Masala,5.95,Yummy goodness,food1.jpg
Chicken Tikka Masala,5.95,Yummy goodness,food2.jpg
Saag Paneer,5.95,Yummy goodness,food3.jpg
Alu Gobi,5.95,Yummy goodness,food4.jpg
Channa Masala,5.95,Yummy goodness,food1
Chicken Tikka Masala,5.95,Yummy goodness,food2
Saag Paneer,5.95,Yummy goodness,food3
Alu Gobi,5.95,Yummy goodness,food4
5 changes: 4 additions & 1 deletion lib/app.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require 'erb'
require 'item'
require 'menu'

class App
def call(env)
Expand All @@ -20,7 +22,8 @@ def body
if File.exist?(index_html)
File.open(index_html, File::RDONLY)
else
[ERB.new(File.open(index_erb, File::RDONLY).read).result]
file_contents = File.open(index_erb, File::RDONLY).read
[ERB.new(file_contents).result]
end
end
end
9 changes: 9 additions & 0 deletions lib/csv_reader.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Csv_reader
def run(file)
menu_items_array = []
IO.readlines(file).each do |line|
menu_items_array << line.strip.split(',')
end
menu_items_array
end
end
31 changes: 31 additions & 0 deletions lib/item.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class Item
def initialize(name, price, description, picture)
@name = name
@price = price
@description = description
@picture = picture
end

def name
@name
end

def price
@price
end

def description
@description
end

def picture
@picture
end

def == (other)
self.name == other.name
self.price == other.price
self.description == other.description
self.picture == other.picture
end
end
13 changes: 13 additions & 0 deletions lib/menu.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'csv_reader'

class Menu
def create_menu(import)
raw_array = Csv_reader.new.run(import)
menu_array = []
raw_array.shift
raw_array.each do |item|
menu_array << Item.new(item[0], item[1], item[2], item[3])
end
menu_array
end
end
52 changes: 0 additions & 52 deletions public/index.html

This file was deleted.

47 changes: 47 additions & 0 deletions public/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html>
<head>
<link href='//fonts.googleapis.com/css?family=Imprima' rel='stylesheet' type='text/css'>
<link href="/css/normalize.min.css" rel="stylesheet" type="text/css">
<link href="/css/default.css" rel="stylesheet" type="text/css">
<title>The Foods of Southern India</title>
</head>
<body>

<header>The Foods of Southern India</header>

<main>
<p>
Squid meggings chillwave, dreamcatcher 8-bit Pinterest mlkshk salvia Shoreditch vegan.
Forage paleo viral narwhal American Apparel tattooed. Mlkshk chillwave tofu Carles, banh
mi Odd Future put a bird on it. Lomo Carles beard Etsy, put a bird on it sartorial raw
denim ugh 8-bit artisan 90's stumptown.</p>

Try-hard street art hella Truffaut, freegan Godard bespoke trust fund biodiesel 8-bit
umami American Apparel tousled authentic XOXO. Selvage PBR skateboard art party, kogi
pork belly master cleanse asymmetrical chia craft beer gastropub drinking
vinegar. Brooklyn narwhal meh biodiesel cred, cardigan vinyl sustainable disrupt direct trade.

</p>
<img src="/images/food1.jpg">

<dl>
<% Menu.new.create_menu("config/menu.csv").each do |item| %>
<dt><%= item.name %> - <%= item.price%></dt>
<dd><img src="/images/<%= item.picture %>.jpg"><br>
<%= item.description %> </dd>
<% end %>
</dl>
</main>

<footer>
<address>
123 Main Street
Boulder, CO 80301
<a href="mailto:bob@example.com">Contact Us</a>
</address>
&copy; <%= Date.today.year %>
</footer>

</body>
</html>
8 changes: 7 additions & 1 deletion spec/features/homepage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@
expect(page).to have_content("Channa Masala")
expect(page).to have_content("Chicken Tikka Masala")
end

it "displays the current year within the footer" do
visit "/"
within("footer") do
expect(page).to have_content("2014")
end
end

end
25 changes: 25 additions & 0 deletions spec/models/item_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'spec_helper'

require 'item'

describe Item do
before do
@item = Item.new("Channa Masala", "5.95", "Yummy goodness", "food1")
end

it 'has an name' do
expect(@item.name).to eq "Channa Masala"
end

it 'has a price' do
expect(@item.price).to eq "5.95"
end

it 'has a description' do
expect(@item.description).to eq "Yummy goodness"
end

it 'has a picture' do
expect(@item.picture).to eq "food1"
end
end
13 changes: 13 additions & 0 deletions spec/models/menu_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'spec_helper'

describe Menu do
it 'knows about the items' do
menu = Menu.new

expect(menu.create_menu(("config/menu.csv"))).to match_array [
Item.new("Channa Masala", 5.95, "Yummy goodness", "food1"),
Item.new("Chicken Tikka Masala", 5.95, "Yummy goodness", "food2"),
Item.new("Saag Paneer",5.95,"Yummy goodness","food3"),
Item.new("Alu Gobi",5.95,"Yummy goodness","food4")]
end
end