sepomex 0.2.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60a528b01402e995f58a69698b2a7bcf668186a7
4
- data.tar.gz: fbfaf235a30f421fc0d61597ca253c18f9e2764b
3
+ metadata.gz: f49d28224231e5d1a38418c359c939afd8ea8e54
4
+ data.tar.gz: 18cf327868cb37a5b64d08aa8a695b408d1d199d
5
5
  SHA512:
6
- metadata.gz: 966dc72e1fbf1daad4fd2bd85eb2e6eb8449a63ed8c32e041511d3544598ca603731b6c6cf739798f8b5e37f0172dd1d074a32e196327fb24b679448c789cb02
7
- data.tar.gz: a93a57c27ad52455a9e253c6584b7617409df823ebb3baa872b6e55016cd77488c01d6296fe43da9e9798cfcd168d87b97b971efff6f8417581388cdfb2a149a
6
+ metadata.gz: b5cbadcb8c2c4c0578087f29bf5c40b5aedf0327c6a1842f6d36aaf6728dad04eb09e97909d7a1e1ab87bf9e4179edf0f6ba2204b49d56b51b8032968f017283
7
+ data.tar.gz: 8e023c8cc054bfbba9f984a6d65e3a0ac98fbd89cafb17df2f2beeda728d7c356f695834546e0853667383d6c810c6bcf0d0dfdde4e9a2d32d9229a8f67bfc4b
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ [![Code Climate](https://codeclimate.com/github/IcaliaLabs/sepomex-rb/badges/gpa.svg)](https://codeclimate.com/github/IcaliaLabs/sepomex-rb)
2
+ [![Test Coverage](https://codeclimate.com/github/IcaliaLabs/sepomex-rb/badges/coverage.svg)](https://codeclimate.com/github/IcaliaLabs/sepomex-rb/coverage)
3
+ [![Issue Count](https://codeclimate.com/github/IcaliaLabs/sepomex-rb/badges/issue_count.svg)](https://codeclimate.com/github/IcaliaLabs/sepomex-rb)
4
+
1
5
  # Sepomex-rb
2
6
 
3
7
  A super simple Ruby wrapper to consume the Sepomex API at [http://sepomex-api.herokuapp.com/api/v1/zip_codes](http://sepomex-api.herokuapp.com/api/v1/zip_codes)
@@ -34,19 +38,51 @@ Or install it yourself as:
34
38
  ## Usage
35
39
 
36
40
  ```ruby
37
- zip_codes = Sepomex::ZipCode.all
41
+ zip_codes = Sepomex::ZipCode.where
38
42
 
39
- => [ #<Sepomex::ZipCode id=1, d_codigo="01000", d_asenta="San Ángel", d_tipo_asenta="Colonia", d_mnpio="Álvaro Obregón", d_estado="Distrito Federal", d_ciudad="Ciudad de México", d_cp="01001", c_estado="09", c_oficina="01001", c_cp="", c_tipo_asenta="09", c_mnpio="010", id_asenta_cpcons="0001", d_zona="Urbano", c_cve_ciudad="01">,
40
- #<Sepomex::ZipCode id=2...]
43
+ => #<Sepomex::ZipCode id=53, d_codigo="01184", d_asenta="Nelli Campo Bello", d_tipo_asenta="Unidad habi...
41
44
  ```
42
45
 
43
46
  You can specify the page to request as an option on the method.
44
47
 
45
48
  ```ruby
46
- zip_codes = Sepomex::ZipCode.all(page: 2)
49
+ zip_codes = Sepomex::ZipCode.where(page: 2)
50
+
51
+ => #<Sepomex::ZipCode id=53, d_codigo="01184", d_asenta="Nelli Campo Bello", d_tipo_asenta="Unidad habi...
52
+ ```
53
+
54
+ You can also filter by code:
55
+
56
+ ```ruby
57
+ zip_codes = Sepomex::ZipCode.where(page: 2, cp: "67173")
58
+
59
+ => #<Sepomex::Collection:0x007fcb9bab50e0 @total_pages=1, @total_objects=8, @per_page=50, @collection=[#<Sepomex::ZipCode id=89510, d_codigo="67173", d_asenta="Contry los Nogales", d_tipo_asenta="Colonia", d_mnpio="Guadalupe", d_estado="Nuevo León", d_ciudad="Guadalupe", d_cp="67171", c_estado="19", c_oficina="67171", c_cp="", c_tipo_asenta="09", c_mnpio="026", id_asenta_cpcons="1725", d_zona="Urbano", c_cve_ciudad="04">...
60
+ ```
61
+
62
+ Filtering by State
63
+
64
+ ```ruby
65
+ nuevo_leon_zipcodes = Sepomex::ZipCode.where(state: "Nuevo León")
66
+
67
+ => #<Sepomex::ZipCode id=85801, d_codigo="64000", d_asenta="La Finca", d_tipo_asenta="Colonia", d_mnpio="Monterrey", d_estado="Nuevo León", d_ciudad="Monterrey", d_cp="64008", c_estado="19", c_oficina="64008", c_cp="", c_tipo_asenta="09", c_mnpio="039", id_asenta_cpcons="3429", d_zona="Urbano", c_cve_ciudad="07">, #<Sepomex::ZipCode id=85802, d_codigo="64000", d_asenta="Monterrey Centro", d_tipo_asenta="Colonia", d_mnpio="Monterrey", d_estado="Nuevo León", d_ciudad="Monterrey", d_cp="64008", c_estado="19", c_oficina="64008", c_cp="", c_tipo_asenta="09", c_mnpio="039", id_asenta_cpcons="0001", d_zona="Urbano", c_cve_ciudad="07">...
68
+ ```
69
+
70
+ Filtering by Colony
71
+
72
+ ```ruby
73
+
74
+ colony_zip_codes = Sepomex::ZipCode.where(colony: "Prados de la Sierra")
75
+
76
+ =>#<Sepomex::ZipCode id=87890, d_codigo="66230", d_asenta="Prados de La Sierra", d_tipo_asenta="Colonia", d_mnpio="San Pedro Garza García", d_estado="Nuevo León", d_ciudad="San Pedro Garza García", d_cp="66231", c_estado="19", c_oficina="66231", c_cp="", c_tipo_asenta="09", c_mnpio="019", id_asenta_cpcons="0887", d_zona="Urbano", c_cve_ciudad="02">
77
+ ```
78
+
79
+ Filtering by City
80
+
81
+ ``ruby
82
+
83
+ city_zip_codes = Sepomex::Zipcode.where(city: "Monterrey")
47
84
 
48
- => [ #<Sepomex::ZipCode id=51, d_codigo="01000", d_asenta="San Ángel", d_tipo_asenta="Colonia", d_mnpio="Álvaro Obregón", d_estado="Distrito Federal", d_ciudad="Ciudad de México", d_cp="01001", c_estado="09", c_oficina="01001", c_cp="", c_tipo_asenta="09", c_mnpio="010", id_asenta_cpcons="0001", d_zona="Urbano", c_cve_ciudad="01">,
49
- #<Sepomex::ZipCode id=52...]
85
+ => #<Sepomex::ZipCode id=85801, d_codigo="64000", d_asenta="La Finca", d_tipo_asenta="Colonia", d_mnpio="Monterrey", d_estado="Nuevo León", d_ciudad="Monterrey", d_cp="64008", c_estado="19", c_oficina="64008", c_cp="", c_tipo_asenta="09", c_mnpio="039", id_asenta_cpcons="3429", d_zona="Urbano", c_cve_ciudad="07">...
50
86
  ```
51
87
 
52
88
  ## Bug tracker & feature request
@@ -1,7 +1,3 @@
1
1
  require "httparty"
2
-
3
- module Sepomex
4
- end
5
-
6
2
  require "sepomex/version"
7
3
  require "sepomex/zip_code"
@@ -1,3 +1,3 @@
1
1
  module Sepomex
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -5,9 +5,9 @@ module Sepomex
5
5
  class ZipCode < OpenStruct
6
6
  include HTTParty
7
7
 
8
- base_uri "sepomex-api.herokuapp.com/api/v1"
8
+ base_uri "sepomex.icalialabs.com/api/v1"
9
9
 
10
- def self.all(options = {})
10
+ def self.where(options = {})
11
11
 
12
12
  response = get("/zip_codes", { query: options })
13
13
 
@@ -22,6 +22,11 @@ module Sepomex
22
22
  else
23
23
  raise_exception(response.code, response.body)
24
24
  end
25
+
26
+ end
27
+
28
+ class << self
29
+ alias_method :all, :where
25
30
  end
26
31
 
27
32
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sepomex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abraham Kuri
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2015-07-31 00:00:00.000000000 Z
12
+ date: 2016-05-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  requirements: []
113
113
  rubyforge_project:
114
- rubygems_version: 2.4.5
114
+ rubygems_version: 2.4.5.1
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: A Ruby wrapper for Sepomex API