0.0
No commit activity in last 3 years
No release in over 3 years
Provides and easy to use model wrapping Yelp Business
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Gem Version Build Status Maintainability Test Coverage

Yelp::Business

This is the simple data model encapsulating Yelp Business data received over Fusion V3 API.

Usage

Configure

First we need to configure the access token:

You can set the token either prorammatiacally (in ruby), or usin an external environment variable YELP_ACCESS_TOKEN.

export YELP_ACCESS_TOKEN='5eUZNOPOlWw9oQHowSKaYcWQK......'

Or, in ruby:

# Set the token either directly on +Yelp+ module:
Yelp.access_token = '5eUZNOPOlWw9oQHowSKaYcWQK....'

# or using #configure method on Yelp::Business
Yelp::Business.configure do |config|
  config.access_token = token
end

Fetch Business Info

Next, we'll fetch and cache business info. In your code, when you have business id or URL:

require 'yelp/business'

url  = 'https://www.yelp.com/biz/gary-danko-san-francisco'
name = Yelp::Business.business_id_from(url) # => 'gary-danko-san-francisco'

# initialize the object, and also fetch the data from Yelp
business  = Yelp::Business.new(name).get

# You can now call methods on the instance to access it's attributes:
business.name   # => 'Gary Danko'
business.rating #=> 4.5

You can also cache the results of the call:

cache_key  = "yelp.business.#{business_id}"
business   = Rails.cache.fetch(cache_key) do 
  Yelp::Business.new(business_id).get
end
business.name #=> 'Gary Danko'

Installation

Add this line to your application's Gemfile:

gem 'yelp-business'

And then execute:

$ bundle

Or install it yourself as:

$ gem install yelp-business

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/pioneerworks/yelp-business.

License

The gem is available as open source under the terms of the MIT License.