yelpster 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,52 +4,52 @@ require 'zlib'
4
4
 
5
5
  class Yelp
6
6
  module V1
7
- class Request < Yelp::Record
8
- # specifies whether the response content should be transmitted
9
- # over the wire compressed, defaulting to true.
10
- attr_reader :compress_response
11
-
12
- # one of the Yelp::ResponseFormat format specifiers detailing the
13
- # desired format of the search results, defaulting to
14
- # Yelp::ResponseFormat::JSON_TO_RUBY.
15
- attr_reader :response_format
16
-
17
- # the Yelp Web Services ID to be passed with the request for
18
- # authentication purposes. See http://www.yelp.com/developers/getting_started/api_access
19
- # to get your own.
20
- attr_reader :yws_id
21
-
22
- alias :compress_response? :compress_response
23
-
24
- def initialize (params)
25
- default_params = {
26
- :compress_response => true,
27
- :response_format => Yelp::ResponseFormat::JSON_TO_RUBY
28
- }
29
- super(default_params.merge(params))
30
- end
31
-
32
- def to_yelp_params
33
- params = {
34
- :ywsid => yws_id
35
- }
36
-
37
- # if they specified anything other than a json variant, we
38
- # need to tell yelp what we're looking for
39
- case @response_format
40
- when Yelp::ResponseFormat::PICKLE
41
- params[:output] = 'pickle'
42
- when Yelp::ResponseFormat::PHP
43
- params[:output] = 'php'
44
- end
45
-
46
- params
47
- end
48
-
49
- def pull_results (url, http_params)
50
- source = open(url, http_params)
51
- content = (compress_response?) ? Zlib::GzipReader.new(source).read : source.read
52
- end
53
- end
54
- end
7
+ class Request < Yelp::Record
8
+ # specifies whether the response content should be transmitted
9
+ # over the wire compressed, defaulting to true.
10
+ attr_reader :compress_response
11
+
12
+ # one of the Yelp::ResponseFormat format specifiers detailing the
13
+ # desired format of the search results, defaulting to
14
+ # Yelp::ResponseFormat::JSON_TO_RUBY.
15
+ attr_reader :response_format
16
+
17
+ # the Yelp Web Services ID to be passed with the request for
18
+ # authentication purposes. See http://www.yelp.com/developers/getting_started/api_access
19
+ # to get your own.
20
+ attr_reader :yws_id
21
+
22
+ alias :compress_response? :compress_response
23
+
24
+ def initialize (params)
25
+ default_params = {
26
+ :compress_response => true,
27
+ :response_format => Yelp::ResponseFormat::JSON_TO_RUBY
28
+ }
29
+ super(default_params.merge(params))
30
+ end
31
+
32
+ def to_yelp_params
33
+ params = {
34
+ :ywsid => yws_id
35
+ }
36
+
37
+ # if they specified anything other than a json variant, we
38
+ # need to tell yelp what we're looking for
39
+ case @response_format
40
+ when Yelp::ResponseFormat::PICKLE
41
+ params[:output] = 'pickle'
42
+ when Yelp::ResponseFormat::PHP
43
+ params[:output] = 'php'
44
+ end
45
+
46
+ params
47
+ end
48
+
49
+ def pull_results (url, http_params)
50
+ source = open(url, http_params)
51
+ content = (compress_response?) ? Zlib::GzipReader.new(source).read : source.read
52
+ end
53
+ end
54
+ end
55
55
  end
@@ -2,31 +2,31 @@ require 'yelpster/v1/request'
2
2
 
3
3
  class Yelp
4
4
  module V1
5
- module Review
6
- module Request
7
- class Base < Yelp::V1::Request
8
- # specifies the number of businesses to return in the result set.
9
- # default is 10. minimum value is 1 and maximum value is 20.
10
- attr_reader :business_count
5
+ module Review
6
+ module Request
7
+ class Base < Yelp::V1::Request
8
+ # specifies the number of businesses to return in the result set.
9
+ # default is 10. minimum value is 1 and maximum value is 20.
10
+ attr_reader :business_count
11
11
 
12
- # string representing the name of business or search term being
13
- # requested.
14
- attr_reader :term
12
+ # string representing the name of business or search term being
13
+ # requested.
14
+ attr_reader :term
15
15
 
16
- # optionally narrow the results by one or more categories.
17
- # may be a single string value, or an Array of multiple values.
18
- attr_reader :category
16
+ # optionally narrow the results by one or more categories.
17
+ # may be a single string value, or an Array of multiple values.
18
+ attr_reader :category
19
19
 
20
- def base_url
21
- 'http://api.yelp.com/business_review_search'
22
- end
20
+ def base_url
21
+ 'http://api.yelp.com/business_review_search'
22
+ end
23
23
 
24
- def to_yelp_params
25
- super.merge(:term => term,
26
- :num_biz_requested => business_count,
27
- :category => category)
28
- end
29
- end
24
+ def to_yelp_params
25
+ super.merge(:term => term,
26
+ :num_biz_requested => business_count,
27
+ :category => category)
28
+ end
29
+ end
30
30
  end
31
31
  end
32
32
  end
@@ -2,37 +2,37 @@ require 'yelpster/v1/review/request/base'
2
2
 
3
3
  class Yelp
4
4
  module V1
5
- module Review
6
- module Request
7
- # Describes a request to search for business reviews for businesses
8
- # within a geo-point-specific bounding box and radius around
9
- # that box.
10
- #
11
- class BoundingBox < Yelp::V1::Review::Request::Base
12
- # bottom right latitude of bounding box
13
- attr_reader :bottom_right_latitude
14
-
15
- # bottom right longitude of bounding box
16
- attr_reader :bottom_right_longitude
17
-
18
- # radius to use while searching around specified geo-point.
19
- # default value is 1, maximum value is 25.
20
- attr_reader :radius
21
-
22
- # top left latitude of bounding box
23
- attr_reader :top_left_latitude
24
-
25
- # top left longitude of bounding box
26
- attr_reader :top_left_longitude
5
+ module Review
6
+ module Request
7
+ # Describes a request to search for business reviews for businesses
8
+ # within a geo-point-specific bounding box and radius around
9
+ # that box.
10
+ #
11
+ class BoundingBox < Yelp::V1::Review::Request::Base
12
+ # bottom right latitude of bounding box
13
+ attr_reader :bottom_right_latitude
27
14
 
28
- def to_yelp_params
29
- super.merge(:tl_lat => top_left_latitude,
30
- :tl_long => top_left_longitude,
31
- :br_lat => bottom_right_latitude,
32
- :br_long => bottom_right_longitude,
33
- :radius => radius)
34
- end
35
- end
15
+ # bottom right longitude of bounding box
16
+ attr_reader :bottom_right_longitude
17
+
18
+ # radius to use while searching around specified geo-point.
19
+ # default value is 1, maximum value is 25.
20
+ attr_reader :radius
21
+
22
+ # top left latitude of bounding box
23
+ attr_reader :top_left_latitude
24
+
25
+ # top left longitude of bounding box
26
+ attr_reader :top_left_longitude
27
+
28
+ def to_yelp_params
29
+ super.merge(:tl_lat => top_left_latitude,
30
+ :tl_long => top_left_longitude,
31
+ :br_lat => bottom_right_latitude,
32
+ :br_long => bottom_right_longitude,
33
+ :radius => radius)
34
+ end
35
+ end
36
36
  end
37
37
  end
38
38
  end
@@ -2,28 +2,28 @@ require 'yelpster/v1/review/request/base'
2
2
 
3
3
  class Yelp
4
4
  module V1
5
- module Review
6
- module Request
7
- # Describes a request to search for business reviews for businesses near
8
- # a specific geo-point and radius around that point.
9
- #
10
- class GeoPoint < Yelp::V1::Review::Request::Base
11
- # latitude of geo-point to search near
12
- attr_reader :latitude
5
+ module Review
6
+ module Request
7
+ # Describes a request to search for business reviews for businesses near
8
+ # a specific geo-point and radius around that point.
9
+ #
10
+ class GeoPoint < Yelp::V1::Review::Request::Base
11
+ # latitude of geo-point to search near
12
+ attr_reader :latitude
13
13
 
14
- # longitude of geo-point to search near
15
- attr_reader :longitude
14
+ # longitude of geo-point to search near
15
+ attr_reader :longitude
16
16
 
17
- # radius to use while searching around specified geo-point.
18
- # default value is 1, maximum value is 25.
19
- attr_reader :radius
17
+ # radius to use while searching around specified geo-point.
18
+ # default value is 1, maximum value is 25.
19
+ attr_reader :radius
20
20
 
21
- def to_yelp_params
22
- super.merge(:lat => latitude,
23
- :long => longitude,
24
- :radius => radius)
25
- end
26
- end
21
+ def to_yelp_params
22
+ super.merge(:lat => latitude,
23
+ :long => longitude,
24
+ :radius => radius)
25
+ end
26
+ end
27
27
  end
28
28
  end
29
29
  end
@@ -2,63 +2,63 @@ require 'yelpster/v1/review/request/base'
2
2
 
3
3
  class Yelp
4
4
  module V1
5
- module Review
6
- module Request
7
- # Describes a request to search for business reviews near a specific
8
- # address/location. You do not need to specify all of the address
9
- # attributes -- some subset of the core +address+, +city+,
10
- # +neighborhood+, +state+ and +zipcode+ will suffice.
11
- #
12
- class Location < Yelp::V1::Review::Request::Base
13
- # the street address of the location sought
14
- attr_reader :address
5
+ module Review
6
+ module Request
7
+ # Describes a request to search for business reviews near a specific
8
+ # address/location. You do not need to specify all of the address
9
+ # attributes -- some subset of the core +address+, +city+,
10
+ # +neighborhood+, +state+ and +zipcode+ will suffice.
11
+ #
12
+ class Location < Yelp::V1::Review::Request::Base
13
+ # the street address of the location sought
14
+ attr_reader :address
15
15
 
16
- # the city of the location sought
17
- attr_reader :city
16
+ # the city of the location sought
17
+ attr_reader :city
18
18
 
19
- # the neighborhood of the location sought
20
- attr_reader :neighborhood
21
-
22
- # radius to use while searching around specified geo-point.
23
- # default value is 1, maximum value is 25.
24
- attr_reader :radius
19
+ # the neighborhood of the location sought
20
+ attr_reader :neighborhood
25
21
 
26
- # the state of the location sought
27
- attr_reader :state
22
+ # radius to use while searching around specified geo-point.
23
+ # default value is 1, maximum value is 25.
24
+ attr_reader :radius
28
25
 
29
- # the zipcode of the location sought
30
- attr_reader :zipcode
26
+ # the state of the location sought
27
+ attr_reader :state
31
28
 
32
- def initialize (params)
33
- # we explicitly initialize the location fields since we reference
34
- # them later when building a full location string and we want
35
- # to know they were initialized properly (and avoid warnings)
36
- super({
37
- :address => nil,
38
- :city => nil,
39
- :neighborhood => nil,
40
- :state => nil,
41
- :zipcode => nil
42
- }.merge(params))
43
- end
29
+ # the zipcode of the location sought
30
+ attr_reader :zipcode
44
31
 
45
- def to_yelp_params
46
- super.merge(:location => build_location_string,
47
- :radius => radius)
48
- end
49
-
50
- protected
51
-
52
- # Returns the Yelp-compatible concatenated string with the various
53
- # possible bits of an address-oriented location.
54
- #
55
- def build_location_string
56
- # per the Yelp documentation, the location string is to be built
57
- # as some combination of "address, neighborhood, city, state, or
58
- # zip".
59
- [ @address, @neighborhood, @city, @state, @zipcode ].compact.join(" ")
60
- end
61
- end
32
+ def initialize (params)
33
+ # we explicitly initialize the location fields since we reference
34
+ # them later when building a full location string and we want
35
+ # to know they were initialized properly (and avoid warnings)
36
+ super({
37
+ :address => nil,
38
+ :city => nil,
39
+ :neighborhood => nil,
40
+ :state => nil,
41
+ :zipcode => nil
42
+ }.merge(params))
43
+ end
44
+
45
+ def to_yelp_params
46
+ super.merge(:location => build_location_string,
47
+ :radius => radius)
48
+ end
49
+
50
+ protected
51
+
52
+ # Returns the Yelp-compatible concatenated string with the various
53
+ # possible bits of an address-oriented location.
54
+ #
55
+ def build_location_string
56
+ # per the Yelp documentation, the location string is to be built
57
+ # as some combination of "address, neighborhood, city, state, or
58
+ # zip".
59
+ [ @address, @neighborhood, @city, @state, @zipcode ].compact.join(',')
60
+ end
61
+ end
62
62
  end
63
63
  end
64
64
  end
@@ -1,19 +1,19 @@
1
- require 'yelpster/v2/request'
2
-
3
- class Yelp
4
- module V2
5
- module Business
6
- module Request
7
- class Id < Yelp::V2::Request
8
- # the alphanumeric id of the business to search for as provided by yelp,
9
- # eg: 'pjb2WMwa0AfK3L-dWimO8w'
10
- attr_reader :yelp_business_id
11
-
12
- def base_url
13
- 'http://api.yelp.com/v2/business/'+yelp_business_id
14
- end
15
- end
16
- end
17
- end
18
- end
19
- end
1
+ require 'yelpster/v2/request'
2
+
3
+ class Yelp
4
+ module V2
5
+ module Business
6
+ module Request
7
+ class Id < Yelp::V2::Request
8
+ # the alphanumeric id of the business to search for as provided by yelp,
9
+ # eg: 'pjb2WMwa0AfK3L-dWimO8w'
10
+ attr_reader :yelp_business_id
11
+
12
+ def base_url
13
+ 'http://api.yelp.com/v2/business/'+yelp_business_id
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -3,54 +3,54 @@ require 'oauth'
3
3
 
4
4
  class Yelp
5
5
  module V2
6
- class Request < Yelp::Record
7
- # specifies whether the response content should be transmitted
8
- # over the wire compressed, defaulting to true.
9
- attr_reader :compress_response
10
-
11
- # one of the Yelp::ResponseFormat format specifiers detailing the
12
- # desired format of the search results, defaulting to
13
- # Yelp::ResponseFormat::JSON_TO_RUBY.
14
- attr_reader :response_format
15
-
16
- # the Yelp consumer_key, consumer_secret, token, token_secret to be passed with the request for
17
- # authentication purposes. See http://www.yelp.com/developers/getting_started/api_access
18
- # to get your own.
19
- attr_reader :consumer_key
20
- attr_reader :consumer_secret
21
- attr_reader :token
22
- attr_reader :token_secret
23
-
24
- alias :compress_response? :compress_response
25
-
26
- def initialize (params)
27
- default_params = {
28
- :compress_response => true,
29
- :response_format => Yelp::ResponseFormat::JSON_TO_RUBY
30
- }
31
- super(default_params.merge(params))
32
- end
33
-
34
- def to_yelp_params
35
- params = {}
36
-
37
- # if they specified anything other than a json variant, we
38
- # need to tell yelp what we're looking for
39
- case @response_format
40
- when Yelp::ResponseFormat::PICKLE
41
- params[:output] = 'pickle'
42
- when Yelp::ResponseFormat::PHP
43
- params[:output] = 'php'
44
- end
45
-
46
- params
47
- end
48
-
49
- def pull_results (url, http_params)
50
- consumer = OAuth::Consumer.new(consumer_key, consumer_secret, {:site => "http://api.yelp.com"})
51
- access_token = OAuth::AccessToken.new(consumer, token, token_secret)
52
- access_token.get(url).body
53
- end
54
- end
55
- end
6
+ class Request < Yelp::Record
7
+ # specifies whether the response content should be transmitted
8
+ # over the wire compressed, defaulting to true.
9
+ attr_reader :compress_response
10
+
11
+ # one of the Yelp::ResponseFormat format specifiers detailing the
12
+ # desired format of the search results, defaulting to
13
+ # Yelp::ResponseFormat::JSON_TO_RUBY.
14
+ attr_reader :response_format
15
+
16
+ # the Yelp consumer_key, consumer_secret, token, token_secret to be passed with the request for
17
+ # authentication purposes. See http://www.yelp.com/developers/getting_started/api_access
18
+ # to get your own.
19
+ attr_reader :consumer_key
20
+ attr_reader :consumer_secret
21
+ attr_reader :token
22
+ attr_reader :token_secret
23
+
24
+ alias :compress_response? :compress_response
25
+
26
+ def initialize (params)
27
+ default_params = {
28
+ :compress_response => true,
29
+ :response_format => Yelp::ResponseFormat::JSON_TO_RUBY
30
+ }
31
+ super(default_params.merge(params))
32
+ end
33
+
34
+ def to_yelp_params
35
+ params = {}
36
+
37
+ # if they specified anything other than a json variant, we
38
+ # need to tell yelp what we're looking for
39
+ case @response_format
40
+ when Yelp::ResponseFormat::PICKLE
41
+ params[:output] = 'pickle'
42
+ when Yelp::ResponseFormat::PHP
43
+ params[:output] = 'php'
44
+ end
45
+
46
+ params
47
+ end
48
+
49
+ def pull_results (url, http_params)
50
+ consumer = OAuth::Consumer.new(consumer_key, consumer_secret, {:site => "http://api.yelp.com"})
51
+ access_token = OAuth::AccessToken.new(consumer, token, token_secret)
52
+ access_token.get(url).body
53
+ end
54
+ end
55
+ end
56
56
  end