lolcation_client 0.1.2 → 0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c03fbe06e8d63b1171dfd7804670b0875f77110
4
- data.tar.gz: 6ea5a147b1b2883fb159c2fdd7989ce62741bb48
3
+ metadata.gz: 938949f3562b763246a19805c6ed0fa6c1438deb
4
+ data.tar.gz: 336f0aa0cdfc8a4a48b7aeb1d5c7add03529f352
5
5
  SHA512:
6
- metadata.gz: 9647caa95e2715a509a442d11db431c78a7bd9ea3b5d69adc8566d4a4cfb1cd163f3a5c98729e68d54a619dfa2dd1fbd05e23118ffcca8a571cdc52932945e64
7
- data.tar.gz: 8ec3a57f272b03ff29e1cc78f2da5fad22cdd9388baaf62402275041488b443e53369243876ebfe47292c5ca9051c1be87da4ecb3f22f8b5f8020fd11bf01731
6
+ metadata.gz: 20055428a9cbbe1bc0994a1ca17b97d298d3ed73816bff254734610e569bc47acf1e60fb1343628b2e84ff027833464de83427c616f7bcd574a4e174c6d69cfc
7
+ data.tar.gz: 07c5aea6a96a0862eff88f36e1b6755d5eb9e38b4cdd109a76ee5733b0109df41110954639b6955e2f49ebbd12e492d6bd5ecbc563f517ea89d57619501cfdae
data/README.md CHANGED
@@ -2,22 +2,27 @@
2
2
  [![Build Status][travis_badge]][travis]
3
3
  [![RubyGems][gem_version_badge]][ruby_gems]
4
4
  [![Code Climate][code_climate_badge]][code_climate]
5
- [![Gemnasium][gemnasium_badge]][gemnasium]
6
5
  [![RubyGems][gem_downloads_badge]][ruby_gems]
7
6
 
8
7
  A Rails GEM to use Lolcation Service.
9
8
 
10
9
  ## Getting started
11
- You can add it to your Gemfile with:
10
+ Add to your `Gemfile`:
12
11
 
12
+ ```
13
13
  gem 'lolcation_client'
14
+ ```
15
+
14
16
  Then run bundle install
15
17
 
16
- Next, you need to run the generator:
18
+ Run the generator:
19
+
20
+ ```
21
+ rails generate lolcation_client:install`
22
+ ```
17
23
 
18
- `$ rails generate lolcation_client:install`
24
+ In your model add follow code:
19
25
 
20
- and
21
26
 
22
27
  ```ruby
23
28
  class LolcalizationModel < ApplicationRecord
@@ -35,21 +40,47 @@ class LolcalizationModel < ApplicationRecord
35
40
  end
36
41
  ```
37
42
 
38
- `$ rails generate lolcation_client:migration MODEL`
43
+ Run the generator to create location fields:
39
44
 
40
- then run:
45
+ ```
46
+ rails generate lolcation_client:migration MODEL
47
+ ```
48
+
49
+ Run your migrate:
41
50
 
42
- `$ rails db:migrate`
51
+ ```
52
+ rails db:migrate
53
+ ```
43
54
 
44
- DO NOT FORGET TO SET UP YOUR LOLCATION TOKEN AT `config/lolcation.yml`
55
+ You must set your __token at :__ `config/lolcation.yml`
56
+
57
+ ```
58
+ development:
59
+ token: 'TOKEN'
60
+ sandbox: true
61
+ staging:
62
+ token: 'TOKEN'
63
+ sandbox: true
64
+ production:
65
+ token: 'TOKEN'
66
+
67
+ ```
68
+
69
+ ## Finding closest localizations with the method `near_me` method
45
70
 
46
- ## Find closest localizations with the method `near_me`
47
71
  ```ruby
48
72
  LocalizationModel.near_in(latitude: lat, longitude: lgt, distance: 10.0, filter: {foo: 'bar'})
49
73
  ```
50
74
 
51
75
  * Note that filter will look up for custom_fields!
52
76
 
77
+ If you want just return the lolcationId field, just add option __only_ids: true__ like:
78
+
79
+ ```ruby
80
+ LocalizationModel.near_in(latitude: lat, longitude: lgt, distance: 10.0, filter: {foo: 'bar'}, only_ids: true)
81
+
82
+ ```
83
+
53
84
  ## Versioning
54
85
 
55
86
  LOLCATION CLIENT follows the [Semantic Versioning](http://semver.org/) standard.
@@ -81,7 +112,7 @@ Follow this steps to release a new version of the gem.
81
112
 
82
113
  ## Made with love by LolDesign
83
114
 
84
- ![LolDesign](http://novo.loldesign.com.br/wp-content/uploads/2015/12/LolDesign.svg)
115
+ <img src="http://novo.loldesign.com.br/wp-content/uploads/2015/12/LolDesign.svg" width="150">
85
116
 
86
117
  This gem was created and is maintained by [LolDesign](https://github.com/loldesign).
87
118
 
@@ -92,7 +123,5 @@ This gem was created and is maintained by [LolDesign](https://github.com/loldesi
92
123
  [ruby_gems]: http://rubygems.org/gems/lolcation_client
93
124
  [code_climate]: https://codeclimate.com/github/loldesign/lolcation_client
94
125
  [code_climate_badge]: http://img.shields.io/codeclimate/github/loldesign/lolcation_client.svg?style=flat
95
- [gemnasium]: https://gemnasium.com/loldesign/lolcation_client
96
- [gemnasium_badge]: http://img.shields.io/gemnasium/loldesign/lolcation_client.svg?style=flat
97
126
  [travis]: https://travis-ci.org/loldesign/lolcation_client
98
127
  [travis_badge]: http://img.shields.io/travis/loldesign/lolcation_client/master.svg?style=flat
@@ -7,9 +7,18 @@ module LolcationClient
7
7
 
8
8
  def near_in(options = {})
9
9
  raise ArgumentError, 'You must pass latitude and longitude as params' unless options[:latitude] || options[:longitude]
10
- response = grab_objects(options)
11
- parse_response = JSON.parse(response.body)
12
- parse_response['localizations']
10
+
11
+ parse_response(grab_objects(options), options)
12
+ end
13
+
14
+ def parse_response(response, options)
15
+ json = JSON.parse(response.body, object_class: OpenStruct)
16
+
17
+ list = json['localizations']
18
+
19
+ return list.map(&:objectId) if options[:only_ids]
20
+
21
+ list
13
22
  end
14
23
 
15
24
  private
@@ -20,7 +29,7 @@ module LolcationClient
20
29
  conn.post do |r|
21
30
  r.headers["X-Token"] = token
22
31
  r.headers["Content-Type"] = "application/json"
23
- r.body = options.to_json
32
+ r.body = options
24
33
  end
25
34
  end
26
35
  end
@@ -1,3 +1,3 @@
1
1
  module LolcationClient
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lolcation_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Zaghi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-07-05 00:00:00.000000000 Z
12
+ date: 2017-07-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler