Repository is archived
No commit activity in last 3 years
No release in over 3 years
A Ruby gem for the NYC Farmers Markets API with a CLI
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.5
~> 0.47
~> 3.5

Runtime

~> 0.8
~> 2.0
 Project Readme

Code Climate Build Status

NYC Farmers Markets

A Ruby Gem with CLI for the NYC Farmers Markets API. Check out the RubyGems page for this gem.

Install Using RubyGems

gem install nyc-farmers-markets

Build and Install from Source

Clone this repository

git clone https://github.com/HarlemSquirrel/nyc-farmers-markets-cli-gem.git

Build the gem

cd nyc-garmers-markets-cli-gem
gem build nyc-farmers-markets.gemspec

Install the gem

gem install ./nyc-farmers-markets-*.gem

Incorporating in your own app

Require the library

require 'nyc_farmers_markets'

Fetch the markets.

markets = NYCFarmersMarkets::GetMarkets.new.make_markets

This will give you an array of Market objects. Each market has seven attributes: additional_info, borough, name, state, street_address, website, and zip_code. Some data may be incomplete from the API. You can access these like this:

markets[0].name # => "Riverdale Youthmarket"
markets[0].website # => "http://www.grownyc.org/youthmarket"

There are a few useful class methods as well.

NYCFarmersMarkets::Market.find_by_borough(b)
NYCFarmersMarkets::Market.find_by_zip_code(z)
NYCFarmersMarkets::Market.boroughs
NYCFarmersMarkets::Market.zip_codes
NYCFarmersMarkets::Market.num_markets_in_borough(b)

Command-Line Interface

This gem will give you the nyc-farmers-markets executable that you can run in your terminal.

$ nyc-farmers-markets

	 ⚶ Welcome to the Farmers Markets of NYC ⚶
	⚘  ⚘  ⚘  ⚘  ⚘  ⚘  ⚘  ⚘  ⚘  ⚘  ⚘  ⚘  ⚘  ⚘  ⚘

What would you like to do (type help for more info)? help

 ⌨ These are the available commands ⌨
☞list all	      -See a list of all Farmers Markets
☞list boroughs  -See a list of boroughs with Farmers Markets
☞[borough name] -See all markets in this borough
☞list zip codes -See a list of zip codes
☞[zip code]	    -See all markets in this zip code
☞help		        -See this helpful list of commands!
☞exit		        -Say good-bye

Tests

There is an RSpec test suite you can run.

rspec