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

Updates to FarMar #70

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
3fd0654
SETUP files
jm-rives Sep 6, 2016
4294c5a
UPDATE files to meet baseline requirements
jm-rives Sep 6, 2016
579fdee
DELETE extraneous file, UPDATE lib files
jm-rives Sep 8, 2016
9b3b709
MIN working code
jm-rives Sep 8, 2016
0a395df
ADD start up logging
jm-rives Sep 8, 2016
7718fd6
Waypoint - set instance variables in constructor
jm-rives Sep 8, 2016
b67fd63
STOPPED Here. Was working on how to construct instance variables with…
jm-rives Sep 8, 2016
c15dd89
ADD self.all method! Thanks Maya
jm-rives Sep 9, 2016
27af45a
ADD find(id) method. Thanks Maya
jm-rives Sep 9, 2016
1b87fdb
ADD Vendor .all method
jm-rives Sep 9, 2016
a9ae5ee
ADD Vendor self.find method, updated local initial test files
jm-rives Sep 9, 2016
f779f55
ADD Product self.all & self.find methods
jm-rives Sep 9, 2016
b6c593e
ADD tests for the Market.all methods
jm-rives Sep 11, 2016
8c3ebe2
ADD tests for Market .find method
jm-rives Sep 11, 2016
ea37c3e
ADD Vendor tests
jm-rives Sep 11, 2016
8def31d
ADD Additional FarMar::Market methods
jm-rives Sep 11, 2016
d9b3ff6
ADD bug fix, tests, comment
jm-rives Sep 20, 2016
da39cde
ADD method
jm-rives Sep 20, 2016
5039d88
ADD test check new instance of sale created
jm-rives Sep 20, 2016
ef8f316
Add test that sale is kind of array
jm-rives Sep 20, 2016
8500499
ADD test to check that one object is created for each line of csv
jm-rives Sep 20, 2016
d570c7a
ADD final test for Sale.rb
jm-rives Sep 20, 2016
d16ba20
ADD test for product self.all method
jm-rives Sep 20, 2016
874a34c
ADD tests that the self.all method returns all expected objects
jm-rives Sep 20, 2016
169ceb1
ADD Additional vendor method testing
jm-rives Sep 20, 2016
32fb7fc
ADD tests that market method returns associated market
jm-rives Sep 20, 2016
01b3705
ADD Vendor method market
jm-rives Sep 20, 2016
69c5cc3
ADD get_market testing and method to Vendor class
jm-rives Sep 20, 2016
6b4fed4
ADD testing for get_product instance method
jm-rives Sep 20, 2016
fd67c52
ADD additional get_products test
jm-rives Sep 20, 2016
d3e4f37
ADD vendor get_sales method & test
jm-rives Sep 20, 2016
74fbd3f
ADD get_revunue testing and method
jm-rives Sep 20, 2016
cea8233
ADD self.by_market tests and method
jm-rives Sep 20, 2016
f6e3e2d
ADD get_vendor method
jm-rives Sep 20, 2016
0f73a72
ADD get_vendor method and tests
jm-rives Sep 20, 2016
0d0e1f6
ADD product get_sales tests and method
jm-rives Sep 20, 2016
c7cbda2
ADD sales_count test
jm-rives Sep 20, 2016
2fd2778
ADD sale_count method and tests
jm-rives Sep 20, 2016
5c368c9
ADD .by_vendor tests and method
jm-rives Sep 21, 2016
6302d81
Add get_vendor Sale method test
jm-rives Sep 21, 2016
690b918
ADD get_vendor passing tests and method
jm-rives Sep 21, 2016
b500ab5
ADD Dr. Who test and method
jm-rives Sep 21, 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
51 changes: 51 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/spec/examples.txt
/test/tmp/
/test/version_tmp/
/tmp/

# Used by dotenv library to load environment variables.
# .env

## Specific to RubyMotion:
.dat*
.repl_history
build/
*.bridgesupport
build-iPhoneOS/
build-iPhoneSimulator/

## Specific to RubyMotion (use of CocoaPods):
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# vendor/Pods/

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

## Environment normalization:
/.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
.DS_Store
1 change: 1 addition & 0 deletions .ruby-gemset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
farmar
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.3.0
15 changes: 15 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# copied from Scrabble project

require 'rake/testtask'

Rake::TestTask.new do |t|
t.libs = ["lib", "specs"]
t.warning = false
t.verbose = false
t.test_files = FileList['specs/*_spec.rb']
puts "Running TestTask"
end

task default: :test do
puts "Running my Rakefile"
end
52 changes: 52 additions & 0 deletions far_mar.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# [x] gems your project needs
require 'csv'
require 'simplecov'
require 'minitest/reporters'

# [x] our namespace module
module FarMar; end

# all of our data classes that live in the module
#require 'lib/far_mar_market'

# [x] ...require all needed classes
puts "Loading the project library."

require './lib/Market'
require './lib/Product'
require './lib/Sale'
require './lib/Vendor'

puts "Done Loading library!"
































103 changes: 103 additions & 0 deletions lib/Market.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
class FarMar::Market

attr_reader :id, :name, :address, :city, :county, :state, :zip_code

def initialize(id, name, address, city, county, state, zip_code) # could take an array
#initialize is NOT a constructor see the iterwebs
@id = id
@name = name
@address = address
@city = city
@county = county
@state = state
@zip_code = zip_code

end

# returns an array of market objects e.g [#<FarMar::Market:0x007ff14981dac0>]
def self.all # works as desired [] repeat for each class

market_array = []

CSV.foreach('./support/markets.csv') do |line|
# maybe I do need to build an hash (dict)
# instance variables would be the key/ import csv data would be the value
id = line[0]
name = line[1]
address = line[2]
city = line[3]
county = line[4]
state = line[5]
zip_code = line[6]

market_array << FarMar::Market.new(id, name, address, city, county, state, zip_code)
# market_array is an array of market objects e.g [#<FarMar::Market:0x007ff14981dac0>]
end
return market_array
end

# returns the market object or nil associated with the Market id

def self.find(id) # this parameter takes string
# find the market object with the id
found_market = nil # because there is no string

all.each do |market|
if market.id == id
found_market = market
break
end
end
return found_market
end

# returns an array of vendors whose market_id matches this markets id
# instance method running inside an instance of market
# because it is running *inside* of market it can refer to @id
def get_vendors #111 for the test case

found_vendors = []

FarMar::Vendor.all.each do |vendor|
if vendor.market_id == @id
found_vendors.push(vendor)
end
end
return found_vendors
end
end

# testing content moved to far_mar.rb
# instance method must call on the INSTANCE
# class methods call directly on the class

# initialize during the instantiation of the instance variables
# a market is a line
# a row is column



























88 changes: 88 additions & 0 deletions lib/Product.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
class FarMar::Product

attr_reader :id, :product_name, :vendor_id

def initialize(id, product_name, vendor_id)

@id = id
@product_name = product_name
@vendor_id = vendor_id

end

def self.all

product_array = []

CSV.foreach('./support/products.csv') do |line|

id = line[0]
product_name = line[1]
vendor_id = line[2]

product_array << FarMar::Product.new(id, product_name, vendor_id)

end
return product_array
end

def self.find(id)

found_product = nil

all.each do |product|
if product.id == id
found_product = product
break
end
end
return found_product
end

def get_vendor
found_vendor = FarMar::Vendor.find(@vendor_id)
return found_vendor
end

def get_sales

found_sales = []
FarMar::Sale.all.each do |sale|
if sale.product_id == @id
found_sales.push(sale)
end
end
return found_sales
end

def sale_count
return get_sales.length
end

def self.by_vendor(vendor_id)
found_products = []

all.each do |product|
if product.vendor_id == vendor_id
found_products.push(product)
end
end
return found_products
end


end














Loading