business-br 0.7.0 → 0.8.0

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: 44e5cca14e98b022b2b024ed606f1de71f33bf4f
4
- data.tar.gz: 1f9cbae3591bff5179d169d2461d9507887e10a6
3
+ metadata.gz: 568c119ede5784bdcc4d26d3ad9d214751ad7f13
4
+ data.tar.gz: 22ad8e004032f3309336cca28685656d65a54e1d
5
5
  SHA512:
6
- metadata.gz: cb248b9ce67b18d4c4c253d51bed101564c5440b0abf617b1029653cb54f38998adb7d7aa48d68796427120c0cf9b850f4ede0e7a446b850133305a4fe0a52c0
7
- data.tar.gz: e6550821a79b9e10e046227ebe76e72313879c50b7b916105e1bb5f0c0074f32da85ed38aee2476acf1bb98119bcc750f977c049603fa8b015752b4673cd7286
6
+ metadata.gz: cb70bbc0ee1e14a894a939769e6da85a86aa8c8a223491ed0e3276e76e58364dc335dcbe21dc8b2a470a11640344dc85c6c421bb79b21bb0349e89e85bdd0bd0
7
+ data.tar.gz: c409118a15e535b99964d287d49b38bfea03775d58c34844c19b89813dcd5a853ab7fec68d54a9ff2780ea2184f7b31c26bb2a105ecd482ebf7f35ae5919a1d7
@@ -1,3 +1,2 @@
1
- 5�rRK:�~9J�w(�
2
- ��꾁?�7P����kx�f^
3
- �<�`^2�z��o��j5>9s���p-�$TQA��1��Hd�
1
+ �ͩ �;��%ڠ���Dž>\�t�u>c- �c�9 �R�+��΃�=�5���W��:�bH\>�y9�!�d��UR����$�t;�gG7�G?h#�g>�w�������udN�rp#m]ޙ��WS#)��gʋ�Mp�l�%Ӗ��>���W�S$�c6��6=^G������FQ�Y���r;?�I�|��[�D����2�Im��~�N?��H�PT��L�;�Qgr��!�9ήD�N�(̭�b
2
+ ��� �9`c�NF�]���9
data.tar.gz.sig CHANGED
Binary file
@@ -7,15 +7,20 @@ rvm:
7
7
  - 2.2.3
8
8
  - 2.1.7
9
9
  - 2.0.0
10
- - rbx-2
11
10
  - jruby-9.0.5.0
12
- - jruby-head
11
+ - jruby-19mode
13
12
  - ruby-head
14
13
 
14
+ matrix:
15
+ allow_failures:
16
+ - rvm: jruby-19mode
17
+ - rvm: jruby-head
18
+
15
19
  before_install:
16
20
  - gem install bundler
17
21
 
18
- bundler_args: --without test --jobs 3 --retry 3
22
+ bundler_args:
23
+ --without test --jobs 3 --retry 3
19
24
 
20
25
  before_script:
21
26
  - bundle update
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- business-br (0.6.0)
4
+ business-br (0.7.1)
5
5
  rest-client (~> 2.0)
6
6
 
7
7
  GEM
@@ -12,10 +12,10 @@ GEM
12
12
  crack (0.4.3)
13
13
  safe_yaml (~> 1.0.0)
14
14
  diff-lcs (1.2.5)
15
- domain_name (0.5.20160615)
15
+ domain_name (0.5.20161129)
16
16
  unf (>= 0.0.5, < 1.0.0)
17
17
  hashdiff (0.3.0)
18
- http-cookie (1.0.2)
18
+ http-cookie (1.0.3)
19
19
  domain_name (~> 0.5)
20
20
  mime-types (3.1)
21
21
  mime-types-data (~> 3.2015)
data/README.md CHANGED
@@ -57,6 +57,14 @@ if validator.valid? '00000asd'
57
57
  else
58
58
  puts 'This CEP is not valid... please try again!'
59
59
  end
60
+
61
+ # getting cep information
62
+ cep = Business::BR::CEP.new
63
+ if infor = cep.search_by('12345678') # default provider is Postmon
64
+ puts "CEP: #{infor}"
65
+ else
66
+ puts "NOT FOUND"
67
+ end
60
68
  ```
61
69
 
62
70
 
File without changes
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'business-br'
4
+
5
+ cep = '13330-000'
6
+ validator = Business::BR::CEP.new
7
+
8
+ # turns from '13330-000' into '13330000'
9
+ cep = validator.normalize(cep)
10
+
11
+
12
+ # turns from '13330000' into '13330-000'
13
+ cep = validator.format(cep)
14
+
15
+ # getting cep region
16
+ cep_region = validator.region(cep) # => ['SP']
17
+
18
+ # getting cep type
19
+ cep_type = validator.type(cep) # => 'LOGRADOURO'
20
+
21
+
22
+ # check if cep is valid
23
+ if validator.valid? '00000asd'
24
+ puts 'This CEP is valid'
25
+ else
26
+ puts 'This CEP is not valid... please try again!'
27
+ end
28
+
29
+ # getting cep information
30
+ cep = Business::BR::CEP.new
31
+ if infor = cep.search_by('12345678')
32
+ puts "CEP: #{infor}"
33
+ else
34
+ puts "NOT FOUND"
35
+ end
@@ -1,3 +1,5 @@
1
+ require 'json'
2
+
1
3
  module Business
2
4
  module BR
3
5
  class CEP
@@ -6,13 +8,18 @@ module Business
6
8
 
7
9
  def search_by(cep)
8
10
  @zipcode = cep
9
- response = RestClient.get "http://api.postmon.com.br/v1/cep/#{@zipcode}"
10
- parse_response(response)
11
+ begin
12
+ response = RestClient.get "http://api.postmon.com.br/v1/cep/#{@zipcode}"
13
+ return parse_response(response.body)
14
+ rescue RestClient::ExceptionWithResponse => e
15
+ puts e.response if ENV['BUSINESS-BR_DEBUG']
16
+ return nil
17
+ end
11
18
  end
12
19
 
13
20
  private
14
21
  def parse_response(response)
15
- json = decode_json(response)
22
+ json = JSON.parse(response, symbolize_names: true)
16
23
  create_entity(
17
24
  json, extract: {
18
25
  zipcode: :cep,
@@ -1,5 +1,5 @@
1
1
  module Business
2
2
  module BR
3
- VERSION = "0.7.0"
3
+ VERSION = "0.8.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: business-br
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Vinciguerra
@@ -32,7 +32,7 @@ cert_chain:
32
32
  diaADa2ZCuoGQuZU33vnJTmu7oy7ZUGOgo7qmoUAYbsn1x5la4sWQ6WHlH/UHDKJ
33
33
  2N5QQXzs6+3RwTLN
34
34
  -----END CERTIFICATE-----
35
- date: 2016-11-24 00:00:00.000000000 Z
35
+ date: 2017-01-19 00:00:00.000000000 Z
36
36
  dependencies:
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bundler
@@ -126,6 +126,7 @@ files:
126
126
  - Rakefile
127
127
  - business-br.gemspec
128
128
  - certs/dvinciguerra.pem
129
+ - examples/cep.rb
129
130
  - lib/business-br.rb
130
131
  - lib/business-br/cep.rb
131
132
  - lib/business-br/cep/providers.rb
@@ -155,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
156
  version: '0'
156
157
  requirements: []
157
158
  rubyforge_project:
158
- rubygems_version: 2.2.0
159
+ rubygems_version: 2.5.1
159
160
  signing_key:
160
161
  specification_version: 4
161
162
  summary: This project provide classes for validations and conversions to use in brazilian
metadata.gz.sig CHANGED
Binary file