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

Suzannah Kirk-Daligcon #49

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e9b9615
Here is an initial commit working on my markets_spec baseline. I've c…
sckirk Sep 6, 2016
8026520
completed my baseline code to pass the two marekts_spec tests; create…
sckirk Sep 6, 2016
53c75b5
Rename markets.rb to market.rb
sckirk Sep 6, 2016
6ea8aa5
Rename vendors.rb to vendor.rb
sckirk Sep 6, 2016
399afb8
Rename markets_spec.rb to market_spec.rb
sckirk Sep 6, 2016
7d7294f
Rename products_spec.rb to product_spec.rb
sckirk Sep 6, 2016
18e22e9
Rename sales_spec.rb to sale_spec.rb
sckirk Sep 6, 2016
082e6e2
Rename vendors_spec.rb to vendor_spec.rb
sckirk Sep 6, 2016
335f944
baseline TDD tests created and code written to pass the tests for the…
sckirk Sep 6, 2016
6d06419
wrote TDD tests and then the code for my FarMar::Market.all method. C…
sckirk Sep 7, 2016
0738d0e
work in progress notes to resume on Wednesday
sckirk Sep 7, 2016
16211af
added TDD test for FarMar::Market.find(id) and then wrote the code to…
sckirk Sep 7, 2016
24c2d05
vendor_spec, cleaned up using let... then wrote TDD tests for self.al…
sckirk Sep 7, 2016
f8e458a
product_spec, cleaned up using let... then wrote TDD tests for self.a…
sckirk Sep 7, 2016
2122f23
sale_spec, cleaned up using let... then wrote TDD tests for self.all …
sckirk Sep 7, 2016
2f2e336
work in progress FarMar::Market.vendors method... fresh eyes, what is…
sckirk Sep 7, 2016
5f37dfb
FarMar::Vendor.by_market(market_id) wrote TDD and subsequent code to …
sckirk Sep 8, 2016
853cf97
FarMar::Market.vendors further exploring how to do this--and commente…
sckirk Sep 8, 2016
9af9549
FarMar::Product.by_vendor(vendor_id) wrote TDD and subsequent code to…
sckirk Sep 8, 2016
e7ad541
FarMar::Market.vendors - wrote TDD and subsequent code to pass TDD,…
sckirk Sep 8, 2016
30b1a43
Added a TDD test into the self.by_market method (in Vendor class) as …
sckirk Sep 8, 2016
4d96bcd
FarMar::Vendor.market - wrote TDD and subsequent code to pass TDD, …
sckirk Sep 8, 2016
8e85d24
FarMar::Vendor.products - wrote TDD and subsequent code to pass TDD…
sckirk Sep 8, 2016
78f7c67
FarMar::Vendor.sales - wrote TDD and subsequent code to pass TDD, t…
sckirk Sep 8, 2016
8e90fb7
FarMar::Vendor.revenue - wrote TDD and subsequent code to pass TDD,…
sckirk Sep 8, 2016
c355fe4
FarMar::Product.vendor - wrote TDD and subsequent code to pass TDD,…
sckirk Sep 8, 2016
ecec4be
FarMar::Product.sales - wrote TDD and subsequent code to pass TDD, …
sckirk Sep 8, 2016
3d93e85
FarMar::Product.number_of_sales - wrote TDD and subsequent code to …
sckirk Sep 9, 2016
fb7fbf4
FarMar::Sale.vendor - wrote TDD and subsequent code to pass TDD, th…
sckirk Sep 9, 2016
c9eb4f3
updated the market method in this file to call upon the Market.find c…
sckirk Sep 9, 2016
674098e
updated the vendor method in this file to call upon the Vendor.find c…
sckirk Sep 9, 2016
3f0255b
FarMar::Sale.product - wrote TDD and subsequent code to pass TDD, t…
sckirk Sep 9, 2016
1b795a9
FarMar::Sale.between(beginning_time, end_time) - wrote TDD and subs…
sckirk Sep 9, 2016
9fa4b31
modified 3 TDD files to move a repeated let statement one level up in…
sckirk Sep 9, 2016
50dd35f
Complete for this week. Updated all of my methods that expected argum…
sckirk Sep 9, 2016
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
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/test/tmp/
/test/version_tmp/
/tmp/
coverage/

## Specific to RubyMotion:
.dat*
.repl_history
build/

## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/

## Environment normalisation:
/.bundle/
/vendor/bundle
/lib/bundler/man/

# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc
7 changes: 7 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'rake/testtask'

Rake::TestTask.new do |t|
t.test_files = FileList['specs/*_spec.rb']
end

task default: :test
299 changes: 299 additions & 0 deletions far_mar.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,299 @@
require 'csv'

module FarMar
end

require_relative './lib/market'
require_relative './lib/vendor'
require_relative './lib/product'
require_relative './lib/sale'


##TEST #21... FarMar::Sale.self.between(beginning_time, end_time)
sample_begin_time = "hello"
# sample_begin_time = FarMar::Sale.all.first.purchase_time
sample_end_time = "bye"
# sample_end_time = FarMar::Sale.all.last.purchase_time
print "sample begin time in TDD: "
puts sample_begin_time
puts ""
print "sample end time in TDD: "
puts sample_end_time
puts "\n"
test = FarMar::Sale.between(sample_begin_time, sample_end_time)
test.each do |item|
puts item.purchase_time
end
# I checked the first 50 objects and all of them are within the sample beginning and end times... great!

# tests to confirm the formatting for FarMar::Sale.purchase_time is now in DateTime format...
# s = FarMar::Sale.all.last
# puts s.purchase_time
# puts DateTime.parse("2013-11-12 12:00:35 -0800")




##TEST #20... FarMar::Sale.product
# s = FarMar::Sale.all.last
# puts s.product
# print "I expect the product id below to be:"
# puts s.product_id
# puts ""
# puts s.product.id
# puts "Awesome!"




##TEST #19... FarMar::Sale.vendor
# s = FarMar::Sale.all.last
# puts s.vendor
# print "I expect the vendor id below to be:"
# puts s.vendor_id
# puts ""
# puts s.vendor.id
# puts "Awesome!"




##TEST #18... FarMar::Product.number_of_sales
# p = FarMar::Product.all.last
# puts p.sales.to_s
# puts ""
# print "I expect this number to correspond to the number of elements in the above array:"
# puts p.number_of_sales
# puts ""
# puts "Awesome!"




##TEST #17... FarMar::Product.sales
# p = FarMar::Product.all.last
# puts p.sales.to_s
# print "I expect the two product id's below to be:"
# puts p.id
# puts ""
# puts p.sales.first.product_id
# puts p.sales.last.product_id
# puts "Awesome!"




##TEST #16... FarMar::Product.vendor
# p = FarMar::Product.all.last
# puts p.vendor
# print "I expect the vendor id below to be:"
# puts p.vendor_id
# puts ""
# puts p.vendor.id
#
# puts "Awesome!"




##TEST #15... FarMar::Vendor.revenue
# v = FarMar::Vendor.all.last
# puts v.sales.to_s
# print "Look at the above amounts and see if this sum looks accurate:"
# puts v.revenue
# puts ""
# puts "Exactly correct. Awesome!"




##TEST #14... FarMar::Vendor.sales
# v = FarMar::Vendor.all.last
# puts v.sales.to_s
# print "I expect the two vendor id's below to be:"
# puts v.id
# puts ""
# puts v.sales.first.vendor_id
# puts v.sales.last.vendor_id
# puts "Awesome!"




##TEST #13... FarMar::Vendor.products
# v = FarMar::Vendor.all.last
# puts v.products.to_s
# print "I expect the two vendor id's below to be:"
# puts v.id
# puts ""
# puts v.products.first.vendor_id
# puts v.products.last.vendor_id
# puts "Awesome!"




##TEST #12... FarMar::Vendor.market
# v = FarMar::Vendor.all.last
# print "I expect the market id below to be:"
# puts v.market_id
# puts ""
# puts v.market.id
#
# puts "Awesome!"




##TEST #11... FarMar::Market.vendors
# m = FarMar::Market.all.last
# print "I expect the two market id's below to be:"
# puts m.id
# puts ""
# puts m.vendors.first.market_id
# puts m.vendors.last.market_id
# puts "Awesome!"




##TEST #10... FarMar::Product.by_vendor(vendor_id)
# print "Here's the vendor I'm calling in the product method below:"
# puts vendor_id = FarMar::Vendor.all.last.id
#
# product_tests = FarMar::Product.by_vendor(vendor_id)
#
# puts "Here are the product objects"
# puts product_tests
#
# puts "Here's the confirmation that all of the vendor_id's in these objects (last line before the line break) match the vendor id noted above..."
# product_tests.each do |item|
# puts item.id
# puts item.name
# puts item.vendor_id
# puts ""
# end

# puts "Glorious!"




##TEST #9... FarMar::Vendor.by_market(market_id)
# print "Here's the market I'm calling in the vendor method below:"
# puts market_id = FarMar::Market.all.last.id
#
# vendor_tests = FarMar::Vendor.by_market(market_id)
#
# puts "Here are the vendor objects"
# puts vendor_tests
#
# puts "Here's the confirmation that all of the market_id's in these objects (last line before the line break) match the market id noted above..."
# vendor_tests.each do |item|
# puts item.id
# puts item.name
# puts item.market_id
# puts ""
# end
#
# puts "Glorious!"




##TEST #8... FarMar::Sale.find(id)
# test = FarMar::Sale.find(FarMar::Sale.all[0].id)
# puts test
#
# puts "Woo hoo!"




# #TEST #7... FarMar::Sale.all
# test = FarMar::Sale.all
#
# puts "Woo hoo!"
#
# test.each do |item|
# puts item.id
# puts item.purchase_time
# puts ""
# end
#
# puts "end of test"




##TEST #6... FarMar::Product.find(id)
# test = FarMar::Product.find(FarMar::Product.all[0].id)
# puts test
#
# puts "Woo hoo!"




# #TEST #5... FarMar::Product.all
# test = FarMar::Product.all
#
# puts "Woo hoo!"
#
# test.each do |item|
# puts item.id
# puts item.name
# puts ""
# end
#
# puts "end of test"




##TEST #4... FarMar::Vendor.find(id)
# test = FarMar::Vendor.find(FarMar::Vendor.all[0].id)
# puts test
#
# puts "Woo hoo!"




# #TEST #3... FarMar::Vendor.all
# test = FarMar::Vendor.all
#
# puts "Woo hoo!"
#
# test.each do |item|
# puts item.id
# puts item.name
# puts ""
# end
#
# puts "end of test"




##TEST #2... FarMar::Market.find(id)
# test = FarMar::Market.find(FarMar::Market.all[0].id)
# puts test
#
# puts "Woo hoo!"




##TEST #1... FarMar::Market.all
# test = FarMar::Market.all
#
# puts "Woo hoo!"
#
# test.each do |item|
# puts item.id
# puts item.name
# puts ""
# end
#
# puts "end of test"
50 changes: 50 additions & 0 deletions lib/market.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
class FarMar::Market
attr_reader :id, :name, :address, :city, :county, :state, :zip

def initialize(market_hash)
@id = market_hash[:id]
@name = market_hash[:name]
@address = market_hash[:address]
@city = market_hash[:city]
@county = market_hash[:county]
@state = market_hash[:state]
@zip = market_hash[:zip]
end

def self.all
markets_from_csv = []
CSV.read('./support/markets.csv').each do |line|
csv_market = {
id: line[0].to_i,
name: line[1],
address: line[2],
city: line[3],
county: line[4],
state: line[5],
zip: line[6]
}
markets_from_csv << self.new(csv_market)
end
markets_from_csv
end

def self.ids
market_ids = []
self.all.each do |m_object|
market_ids << m_object.id
end
return market_ids
end

def self.find(id)
if self.ids.include?(id)
self.all.find {|m_object| m_object.id == id}
else
raise ArgumentError.new("Oops, your number input is not a valid market id.")
end
end

def vendors
return FarMar::Vendor::by_market(@id)
end
end
Loading