google-api-customization 0.0.2 → 0.1.0

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.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NGE4NmNiMzU1NjM4MmM3OWFhOWFjNjhhNWQ2NzczNTY2NWQxZGI5Ng==
5
- data.tar.gz: !binary |-
6
- NjUxZWY3NTEwYTcyNzQyODhiZGUyZDQyNjNmOTFjOTU0Yjg5NDJiYw==
2
+ SHA256:
3
+ metadata.gz: 34f9dc16c596a95d5de9a8c8e86f6adebe4c470d8d95b456a7899ce5b5b7d98a
4
+ data.tar.gz: 1c405598d9a2bf97fdb07b018da782535c9e4db9f30737acd1c14d430e1c353b
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- YTdhNTBhY2Q2ZDFjMjZiZGUxOTQxODJiOTEwMGY4MDJhN2MwNWU4NTA1NmZk
10
- YTQxY2FiOTVkMjkyNTI2NzdjZTcxMGMyZWVmZjJkMjllYjI3NzQyYmQ4MmM2
11
- ZTYwMWE4Y2NjNTE3YzhmNWQ2ZmQxNmVjMzc1ZDc3Y2M4OGFhNmM=
12
- data.tar.gz: !binary |-
13
- NzlmOWI0YTVjNjk4MjQ3NjY5YzU3NDgxOGQ1OWMxMGVkNGIxYmRiZTJkMGFl
14
- NmI3N2VjMmM4ODNlNGMyYjY5ZmMxMThlZDBjM2UzNDk4YjM2ZWEwNmExZDM4
15
- YmI3YzNhOTRiOTRhNDhjNWRjOWM3OGNmMjZmNTk0MDhiZjVmOWE=
6
+ metadata.gz: a4ef9e3b920f3fcd2f2b02439dc43430ecf536cf27735296603366c860c0959c0d046ab6f4ecd2fea238ae1bcf346fc9a5742a6d9e2d6e49b91d73c369749ab8
7
+ data.tar.gz: 69b9656c700b3522c91906c0bc55af896d54f65bb3960cba47465e149ce2ba1b56ba3abfeed04c17510f49f797501efca8815ad9f4d5685118cbb5741c393d4c
data/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # google-api-customization
2
+
3
+ A Ruby gem that wraps the Google Places API for use in Rails applications. Supports place details, text search, nearby search, radar search, photos, reviews, and autocomplete.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem 'google-api-customization'
11
+ ```
12
+
13
+ Then run:
14
+
15
+ ```bash
16
+ bundle install
17
+ ```
18
+
19
+ ## Configuration
20
+
21
+ ```ruby
22
+ GoogleApiCustomization.configuration do |config|
23
+ config.api_key = "YOUR_GOOGLE_API_KEY"
24
+ end
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ### Look up a place by ID
30
+
31
+ ```ruby
32
+ place = GoogleApiCustomization::Place.find(place_id, api_key, sensor)
33
+
34
+ place.name # => "Eiffel Tower"
35
+ place.formatted_address # => "Champ de Mars, Paris, France"
36
+ place.lat # => 48.8584
37
+ place.lng # => 2.2945
38
+ place.rating # => 4.7
39
+ place.website # => "https://www.toureiffel.paris"
40
+ place.opening_hours # => { ... }
41
+ ```
42
+
43
+ ### Text search
44
+
45
+ ```ruby
46
+ places = GoogleApiCustomization::Place.list_by_query(
47
+ "coffee shops",
48
+ api_key,
49
+ sensor,
50
+ lat: 48.8584,
51
+ lng: 2.2945,
52
+ radius: 1000
53
+ )
54
+ ```
55
+
56
+ ### Photos
57
+
58
+ ```ruby
59
+ place.photos.each do |photo|
60
+ url = photo.fetch_url(400) # maxwidth in pixels
61
+ end
62
+ ```
63
+
64
+ ### Reviews
65
+
66
+ ```ruby
67
+ place.reviews.each do |review|
68
+ puts "#{review.author_name}: #{review.text} (#{review.rating}/5)"
69
+ end
70
+ ```
71
+
72
+ ## Available Place Attributes
73
+
74
+ `name`, `place_id`, `lat`, `lng`, `formatted_address`, `formatted_phone_number`, `international_phone_number`, `website`, `rating`, `price_level`, `opening_hours`, `types`, `photos`, `reviews`, `url`, `vicinity`, `address_components`, `utc_offset`
75
+
76
+ ## Dependencies
77
+
78
+ - [httparty](https://github.com/jnunemaker/httparty)
@@ -0,0 +1,21 @@
1
+ require_relative "lib/google_api_customization/version"
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "google-api-customization"
5
+ spec.version = GoogleApiCustomization::VERSION
6
+ spec.authors = ["Abhishek Sharma"]
7
+ spec.email = ["abhsss96@gmail.com"]
8
+ spec.summary = "Ruby gem to expand usage of Google API with Rails"
9
+ spec.description = "A wrapper around the Google Places API supporting place lookup, text search, nearby search, photos, reviews, and autocomplete."
10
+ spec.homepage = "https://github.com/abhsss96/google-api-customization"
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = ">= 2.7"
13
+
14
+ spec.files = Dir["lib/**/*", "README.md", "*.gemspec"]
15
+ spec.require_paths = ["lib"]
16
+
17
+ spec.add_dependency "httparty", ">= 0.14"
18
+
19
+ spec.add_development_dependency "rspec", "~> 3.12"
20
+ spec.add_development_dependency "webmock", "~> 3.0"
21
+ end
@@ -0,0 +1,17 @@
1
+ module GoogleApiCustomization
2
+ class Error < StandardError
3
+ attr_reader :response
4
+ def initialize(response)
5
+ @response = response
6
+ super(response.parsed_response.to_s)
7
+ end
8
+ end
9
+
10
+ class OverQueryLimitError < Error; end
11
+ class RequestDeniedError < Error; end
12
+ class InvalidRequestError < Error; end
13
+ class UnknownError < Error; end
14
+ class NotFoundError < Error; end
15
+ class RetryError < Error; end
16
+ class RetryTimeoutError < Error; end
17
+ end
@@ -93,6 +93,35 @@ module GoogleApiCustomization
93
93
  request(:spots_by_query, multipage_request, exclude, options)
94
94
  end
95
95
 
96
+ def self.list_by_nearby(lat, lng, radius, api_key, sensor, options = {})
97
+ multipage_request = !!options.delete(:multipage)
98
+ location = Location.new(lat, lng)
99
+ rankby = options.delete(:rankby)
100
+ language = options.delete(:language)
101
+ types = options.delete(:types)
102
+ exclude = options.delete(:exclude) || []
103
+ retry_options = options.delete(:retry_options) || {}
104
+
105
+ exclude = [exclude] unless exclude.is_a?(Array)
106
+
107
+ options = {
108
+ :location => location.format,
109
+ :radius => radius,
110
+ :sensor => sensor,
111
+ :key => api_key,
112
+ :rankby => rankby,
113
+ :language => language,
114
+ :retry_options => retry_options
115
+ }
116
+
117
+ if types
118
+ types = (types.is_a?(Array) ? types.join('|') : types)
119
+ options.merge!(:types => types)
120
+ end
121
+
122
+ request(:spots_by_nearby, multipage_request, exclude, options)
123
+ end
124
+
96
125
  def self.request(method, multipage_request, exclude, options)
97
126
  results = []
98
127
 
@@ -19,14 +19,27 @@ module GoogleApiCustomization
19
19
 
20
20
  PAGETOKEN_URL = "https://maps.googleapis.com/maps/api/place/search/json"
21
21
 
22
- RADAR_SEARCH_URL = "https://maps.googleapis.com/maps/api/place/radarsearch/json"
23
-
24
22
  AUTOCOMPLETE_URL = "https://maps.googleapis.com/maps/api/place/autocomplete/json"
25
-
23
+
26
24
  def self.place(options = {})
27
25
  request = new(PLACES_URL, options)
28
26
  request.parsed_response
29
27
  end
28
+
29
+ def self.nearby_search(options = {})
30
+ request = new(NEARBY_SEARCH_URL, options)
31
+ request.parsed_response
32
+ end
33
+
34
+ def self.text_search(options = {})
35
+ request = new(TEXT_SEARCH_URL, options)
36
+ request.parsed_response
37
+ end
38
+
39
+ def self.autocomplete(options = {})
40
+ request = new(AUTOCOMPLETE_URL, options)
41
+ request.parsed_response
42
+ end
30
43
 
31
44
  def initialize(url, options, follow_redirects = true)
32
45
  retry_options = options.delete(:retry_options) || {}
@@ -0,0 +1,3 @@
1
+ module GoogleApiCustomization
2
+ VERSION = "0.1.0"
3
+ end
@@ -1,24 +1,19 @@
1
- require 'debugger'
2
- require 'rubygems'
3
- require 'httparty'
4
-
5
- %w(request place api_key photo review).each do |file|
6
- require File.join(File.dirname(__FILE__), 'google_api_customization', file)
7
- end
8
-
1
+ require "httparty"
2
+ require_relative "google_api_customization/version"
3
+ require_relative "google_api_customization/errors"
4
+ require_relative "google_api_customization/request"
5
+ require_relative "google_api_customization/place"
6
+ require_relative "google_api_customization/api_key"
7
+ require_relative "google_api_customization/photo"
8
+ require_relative "google_api_customization/review"
9
9
 
10
10
  module GoogleApiCustomization
11
-
12
11
  class << self
13
-
14
12
  attr_accessor :api_key
15
13
 
16
14
  def configuration
17
-
18
15
  yield self
19
-
20
16
  end
21
-
22
17
  end
18
+ end
23
19
 
24
- end
metadata CHANGED
@@ -1,49 +1,96 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-api-customization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abhishek Sharma
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-01 00:00:00.000000000 Z
12
- dependencies: []
13
- description: Gem to expand usage of google api with rails
14
- email: abhishek.sharma@medma.in
11
+ date: 2026-05-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0.14'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: webmock
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: A wrapper around the Google Places API supporting place lookup, text
56
+ search, nearby search, photos, reviews, and autocomplete.
57
+ email:
58
+ - abhsss96@gmail.com
15
59
  executables: []
16
60
  extensions: []
17
61
  extra_rdoc_files: []
18
62
  files:
63
+ - README.md
64
+ - google-api-customization.gemspec
19
65
  - lib/google_api_customization.rb
20
66
  - lib/google_api_customization/api_key.rb
67
+ - lib/google_api_customization/errors.rb
21
68
  - lib/google_api_customization/photo.rb
22
69
  - lib/google_api_customization/place.rb
23
70
  - lib/google_api_customization/request.rb
24
71
  - lib/google_api_customization/review.rb
25
- homepage: http://rubygems.org/gems/google_api_customization
72
+ - lib/google_api_customization/version.rb
73
+ homepage: https://github.com/abhsss96/google-api-customization
26
74
  licenses:
27
- - NONE
75
+ - MIT
28
76
  metadata: {}
29
- post_install_message:
77
+ post_install_message:
30
78
  rdoc_options: []
31
79
  require_paths:
32
80
  - lib
33
81
  required_ruby_version: !ruby/object:Gem::Requirement
34
82
  requirements:
35
- - - ! '>='
83
+ - - ">="
36
84
  - !ruby/object:Gem::Version
37
- version: '0'
85
+ version: '2.7'
38
86
  required_rubygems_version: !ruby/object:Gem::Requirement
39
87
  requirements:
40
- - - ! '>='
88
+ - - ">="
41
89
  - !ruby/object:Gem::Version
42
90
  version: '0'
43
91
  requirements: []
44
- rubyforge_project:
45
- rubygems_version: 2.2.2
46
- signing_key:
92
+ rubygems_version: 3.5.22
93
+ signing_key:
47
94
  specification_version: 4
48
- summary: Hello! This is start up for google API customization for Rails
95
+ summary: Ruby gem to expand usage of Google API with Rails
49
96
  test_files: []