google-api-customization 0.0.1 → 0.0.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.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ODkxM2MzMjkzMzBlODg1MTg0OTVkMjRlNDY3Yjg1ZWI1YmFhMDhkZg==
5
- data.tar.gz: !binary |-
6
- NGNmMjAxMWJjYzE0NzU4MTc0MmMyYzYxMDVjZmQzNDMwZTFhNjNjZA==
2
+ SHA256:
3
+ metadata.gz: 24f33be4fcc3ad7f0079e5222be998de22d7decc2f8c2f358622d709738e32e4
4
+ data.tar.gz: 2ac49d69075a9a3394f6ce49ee7fe3afa35c0e880ad8c7b87b27d6b2007fbbb5
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NjgwYjI0YTUzYjRmYTFjZTRlOTViYzk0OTgzNWUwN2RhMGUyYjkzY2Y1ZWRj
10
- OTRlM2NkMmY5MWFhZGJkYTE1OTM0N2U0MjRkMDc5ODM4ZWUxMjk2MTc1NjBj
11
- NjExODAxZmUzOTIzNjk5ZDMyODU2MTc2M2NlZTNmODg2MzI2MGQ=
12
- data.tar.gz: !binary |-
13
- ZjljOGYwODRlNDhkYzQzMTE5NGU5MWU5M2NiOWVlNGI1ZjYwOGVjYjUxOTQy
14
- MmI1YjQyMjI2Y2Q5OWIyOWVhY2M1MTU3ZDkwY2Q1NTRiNWM2NTI4ODZiZTIy
15
- YTBkYWMwODMzYmM3ZGEyMzk2NWM2YTM0YTM5OGJlN2ZiYWRhMDk=
6
+ metadata.gz: 459886cba07f4db6b1d019f23f4deeaaaa396f68d39fc828174b7e0bd1b760a270f7f1aaa566e9014176a9c7818dfa1c8852a07a1243f0d7c71ca8ca096d8400
7
+ data.tar.gz: 20d85b64028dcda04a0d55e13cc1375a14ec766b097ad0454266eb69835a65d462215b31d1e75920202df92a4f5267211ece7ba8c64ce86da5174cf7f34fb204
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,21 @@
1
+ module GoogleApiCustomization
2
+
3
+ class ApiKey
4
+
5
+ attr_reader :api_key
6
+
7
+ attr_reader :options
8
+ attr_reader :sensor
9
+
10
+ def initialize(api_key = @api_key, sensor = false, options = {})
11
+ api_key ? @api_key = api_key : @api_key = GoogleApiCustomization.api_key
12
+ @sensor = sensor
13
+ @options = options
14
+ end
15
+
16
+ def place_detail(place_id, options = {})
17
+ Place.find(place_id, @api_key, @sensor, @options.merge(options))
18
+ end
19
+ end
20
+
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
@@ -0,0 +1,44 @@
1
+ module GoogleApiCustomization
2
+ class Photo
3
+ attr_accessor :width, :height, :photo_reference, :html_attributions
4
+
5
+ def initialize(width, height, photo_reference, html_attributions, api_key, sensor)
6
+ @width = width
7
+ @height = height
8
+ @photo_reference = photo_reference
9
+ @html_attributions = html_attributions
10
+ @api_key = api_key
11
+ @sensor = sensor
12
+ end
13
+
14
+ # Search for a Photo's url with its reference key
15
+ #
16
+ # @return [URL]
17
+ # @param [String] api_key the provided api key
18
+ # @param [Boolean] sensor
19
+ # Indicates whether or not the Place request came from a device using a location sensor (e.g. a GPS)
20
+ # to determine the location sent in this request.
21
+ # <b>Note that this is a mandatory parameter</b>
22
+ # @param [Hash] options
23
+ # @option options [Hash] :retry_options ({})
24
+ # A Hash containing parameters for search retries
25
+ # @option options [Object] :retry_options[:status] ([])
26
+ # @option options [Integer] :retry_options[:max] (0) the maximum retries
27
+ # @option options [Integer] :retry_options[:delay] (5) the delay between each retry in seconds
28
+ def fetch_url(maxwidth, options = {})
29
+ language = options.delete(:language)
30
+ retry_options = options.delete(:retry_options) || {}
31
+
32
+ unless @fetched_url
33
+ @fetched_url = Request.photo_url(
34
+ :maxwidth => maxwidth,
35
+ :photoreference => @photo_reference,
36
+ :sensor => @sensor,
37
+ :key => @api_key,
38
+ :retry_options => retry_options
39
+ )
40
+ end
41
+ @fetched_url
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,14 @@
1
+ module GoogleApiCustomization
2
+ class Review
3
+ attr_accessor :rating, :type, :author_name, :author_url, :text, :time
4
+
5
+ def initialize(rating, type, author_name, author_url, text, time)
6
+ @rating = rating
7
+ @type = type
8
+ @author_name = author_name
9
+ @author_url = author_url
10
+ @text = text
11
+ @time = time
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module GoogleApiCustomization
2
+ VERSION = "0.0.3"
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,46 +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.1
4
+ version: 0.0.3
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
66
+ - lib/google_api_customization/api_key.rb
67
+ - lib/google_api_customization/errors.rb
68
+ - lib/google_api_customization/photo.rb
20
69
  - lib/google_api_customization/place.rb
21
70
  - lib/google_api_customization/request.rb
22
- homepage: http://rubygems.org/gems/google_api_customization
71
+ - lib/google_api_customization/review.rb
72
+ - lib/google_api_customization/version.rb
73
+ homepage: https://github.com/abhsss96/google-api-customization
23
74
  licenses:
24
- - NONE
75
+ - MIT
25
76
  metadata: {}
26
- post_install_message:
77
+ post_install_message:
27
78
  rdoc_options: []
28
79
  require_paths:
29
80
  - lib
30
81
  required_ruby_version: !ruby/object:Gem::Requirement
31
82
  requirements:
32
- - - ! '>='
83
+ - - ">="
33
84
  - !ruby/object:Gem::Version
34
- version: '0'
85
+ version: '2.7'
35
86
  required_rubygems_version: !ruby/object:Gem::Requirement
36
87
  requirements:
37
- - - ! '>='
88
+ - - ">="
38
89
  - !ruby/object:Gem::Version
39
90
  version: '0'
40
91
  requirements: []
41
- rubyforge_project:
42
- rubygems_version: 2.2.2
43
- signing_key:
92
+ rubygems_version: 3.5.22
93
+ signing_key:
44
94
  specification_version: 4
45
- summary: Hello! This is start up for google API customization for Rails
95
+ summary: Ruby gem to expand usage of Google API with Rails
46
96
  test_files: []