google-place-text-search 0.0.2 → 1.0.1
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 +5 -5
- data/README.md +51 -0
- data/google-place-text-search.gemspec +21 -0
- data/lib/google_place_text_search/version.rb +3 -0
- data/lib/google_place_text_search.rb +9 -14
- metadata +62 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 01c90ba9adbb7bab98812257ddbc6575c4224634bc9251005dcf0d943f1f5bd3
|
|
4
|
+
data.tar.gz: 5ab7a7560428c98de45e9bb20a42fc84a684ea49c0846999f89d1441bc174fb6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e1f2060c21c8bd0ade280a3c71d4bc9dd4b02fd070d8d9563ab5707b0f8e0bfa9992e1351a61459c4c5fd09ea542aab9a39a1b17e920da0a265f57d7204d9bc1
|
|
7
|
+
data.tar.gz: 47f055d8f4f7ec0fc48780c9300a4a00a8144b012d89c0c7e31e6ac89bde88c8cbcb7ad20d845aa5119901206cb334fa1f9dea24f20dac1b9b5d7597cab1907c
|
data/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# google-place-text-search
|
|
2
|
+
|
|
3
|
+
A simple Ruby gem to search for places using the [Google Places Text Search API](https://developers.google.com/maps/documentation/places/web-service/search-text). Search by query string, optionally biased by location and radius.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your `Gemfile`:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'google-place-text-search'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Then run:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bundle install
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
searcher = GooglePlaceTextSearch.new
|
|
23
|
+
|
|
24
|
+
results = searcher.get_response(
|
|
25
|
+
"YOUR_GOOGLE_API_KEY",
|
|
26
|
+
5000, # radius in meters
|
|
27
|
+
"48.8584,2.2945", # location as "lat,lng"
|
|
28
|
+
"restaurants near Eiffel Tower"
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
results["results"].each do |place|
|
|
32
|
+
puts place["name"]
|
|
33
|
+
puts place["formatted_address"]
|
|
34
|
+
puts place["rating"]
|
|
35
|
+
end
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Parameters
|
|
39
|
+
|
|
40
|
+
| Parameter | Type | Description |
|
|
41
|
+
|-----------|------|-------------|
|
|
42
|
+
| `api_key` | String | Your Google Places API key |
|
|
43
|
+
| `radius` | Integer | Search radius in meters |
|
|
44
|
+
| `location` | String | Center point as `"lat,lng"` |
|
|
45
|
+
| `query` | String | Text query to search for |
|
|
46
|
+
|
|
47
|
+
Returns the parsed JSON response from the Google Places API, including a `results` array with place details.
|
|
48
|
+
|
|
49
|
+
## Dependencies
|
|
50
|
+
|
|
51
|
+
- [httparty](https://github.com/jnunemaker/httparty)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require_relative "lib/google_place_text_search/version"
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = "google-place-text-search"
|
|
5
|
+
spec.version = GooglePlaceTextSearch::VERSION
|
|
6
|
+
spec.authors = ["Abhishek Sharma"]
|
|
7
|
+
spec.email = ["abhsss96@gmail.com"]
|
|
8
|
+
spec.summary = "Search places using the Google Places Text Search API"
|
|
9
|
+
spec.description = "A simple wrapper around the Google Places Text Search API — search by query string, location, and radius."
|
|
10
|
+
spec.homepage = "https://github.com/abhsss96/google-place-text-search"
|
|
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
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
+
require "httparty"
|
|
2
|
+
require "json"
|
|
3
|
+
require_relative "google_place_text_search/version"
|
|
4
|
+
|
|
1
5
|
class GooglePlaceTextSearch
|
|
2
|
-
|
|
3
|
-
require 'httparty'
|
|
4
|
-
require 'json'
|
|
5
|
-
|
|
6
|
-
def get_response(api_key,radius,location,query)
|
|
7
|
-
url = "https://maps.googleapis.com/maps/api/place/textsearch/json"
|
|
8
|
-
#location="#{lat},#{lng}"
|
|
9
|
-
|
|
10
|
-
query_data = {:key=>api_key,:query=>query, :location=>location,:radius=>radius}
|
|
11
|
-
response = HTTParty.get("#{url}", :query=>query_data)
|
|
6
|
+
TEXT_SEARCH_URL = "https://maps.googleapis.com/maps/api/place/textsearch/json"
|
|
12
7
|
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
def get_response(api_key, radius, location, query)
|
|
9
|
+
query_data = { key: api_key, query: query, location: location, radius: radius }
|
|
10
|
+
response = HTTParty.get(TEXT_SEARCH_URL, query: query_data)
|
|
11
|
+
JSON.parse(response.body)
|
|
15
12
|
end
|
|
16
|
-
|
|
17
|
-
|
|
18
13
|
end
|
metadata
CHANGED
|
@@ -1,44 +1,90 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: google-place-text-search
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.0.1
|
|
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:
|
|
12
|
-
dependencies:
|
|
13
|
-
|
|
14
|
-
|
|
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 simple wrapper around the Google Places Text Search API — search by
|
|
56
|
+
query string, location, and radius.
|
|
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-place-text-search.gemspec
|
|
19
65
|
- lib/google_place_text_search.rb
|
|
20
|
-
|
|
66
|
+
- lib/google_place_text_search/version.rb
|
|
67
|
+
homepage: https://github.com/abhsss96/google-place-text-search
|
|
21
68
|
licenses:
|
|
22
|
-
-
|
|
69
|
+
- MIT
|
|
23
70
|
metadata: {}
|
|
24
|
-
post_install_message:
|
|
71
|
+
post_install_message:
|
|
25
72
|
rdoc_options: []
|
|
26
73
|
require_paths:
|
|
27
74
|
- lib
|
|
28
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
76
|
requirements:
|
|
30
|
-
- -
|
|
77
|
+
- - ">="
|
|
31
78
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
79
|
+
version: '2.7'
|
|
33
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
34
81
|
requirements:
|
|
35
|
-
- -
|
|
82
|
+
- - ">="
|
|
36
83
|
- !ruby/object:Gem::Version
|
|
37
84
|
version: '0'
|
|
38
85
|
requirements: []
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
signing_key:
|
|
86
|
+
rubygems_version: 3.5.22
|
|
87
|
+
signing_key:
|
|
42
88
|
specification_version: 4
|
|
43
|
-
summary:
|
|
89
|
+
summary: Search places using the Google Places Text Search API
|
|
44
90
|
test_files: []
|