business-br 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +3 -0
- data/business-br.gemspec +6 -0
- data/certs/dvinciguerra.pem +23 -0
- data/lib/business-br.rb +4 -8
- data/lib/business-br/cep.rb +12 -1
- data/lib/business-br/cep/providers.rb +24 -0
- data/lib/business-br/cep/providers/base.rb +33 -0
- data/lib/business-br/cep/providers/postmon.rb +33 -0
- data/lib/business-br/cep/providers/republicavirtual.rb +34 -0
- data/lib/business-br/version.rb +1 -1
- metadata +52 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92c3856d50510d16b14c0b01d671a09b5582433a
|
4
|
+
data.tar.gz: 88f36c2053684663537361f624d4f931ba995045
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63483120312032ef0838e65ff64c9b81be440f66031e876b4d5083aeea5450f1ea5245ef401da64b28904cfba0c57b433a695ba7c9d7c0f476853c58d3a5d205
|
7
|
+
data.tar.gz: d0118ea80c726c3134601001c0b482540fa743440c4a7056564a9b64f141ac919824e063b0922be65e7b481a71cbc1dc9e8a31cde981bcfe3dd13ec5b8964d6e
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
data/business-br.gemspec
CHANGED
@@ -20,7 +20,13 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
spec.required_ruby_version = '>= 2.0.0'
|
22
22
|
|
23
|
+
# secirity
|
24
|
+
spec.cert_chain = ['certs/dvinciguerra.pem']
|
25
|
+
spec.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
|
26
|
+
|
27
|
+
# dependency
|
23
28
|
spec.add_development_dependency "bundler", "~> 1.12"
|
24
29
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
30
|
spec.add_development_dependency "rspec", "~> 3.0"
|
31
|
+
spec.add_development_dependency 'webmock', '~> 2.1', '>= 2.1.0'
|
26
32
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDyDCCArCgAwIBAgIBATANBgkqhkiG9w0BAQUFADBdMRswGQYDVQQDDBJkYW5p
|
3
|
+
ZWwudmluY2lndWVycmExFTATBgoJkiaJk/IsZAEZFgViaXZlZTETMBEGCgmSJomT
|
4
|
+
8ixkARkWA2NvbTESMBAGCgmSJomT8ixkARkWAmJyMB4XDTE2MTEyMzE4MzM1NloX
|
5
|
+
DTE3MTEyMzE4MzM1NlowXTEbMBkGA1UEAwwSZGFuaWVsLnZpbmNpZ3VlcnJhMRUw
|
6
|
+
EwYKCZImiZPyLGQBGRYFYml2ZWUxEzARBgoJkiaJk/IsZAEZFgNjb20xEjAQBgoJ
|
7
|
+
kiaJk/IsZAEZFgJicjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOMt
|
8
|
+
U5fmAykQFjl3S7tqIzMUeHkFT5jACDbYRTmo5lTVFapjKelf7xOrAfmEuPyywXIi
|
9
|
+
uePaImcfWxUF6zz0VOjcBcmvIzEo1T+w9u8J2Mq7uNyIL5Cbg1cRoh4dxknklowv
|
10
|
+
mGY/NPm4GD+Sm+gwmhXw7nDFQNhxBF1LtsZjv79Tc3gTAGyayN6sfCwtvp3gAluy
|
11
|
+
1+GRj9EyO5moR5nhagDx7e1P2GO7wwXsKjSD+Azzlk908lwdeasKvw+d/JFzGmxh
|
12
|
+
S5lyGEzc99bFwsn07rTh+x2lKBZnlGwdOKEA0zcX+blhGULcO7Q4p7QvHUtPFh02
|
13
|
+
kseIkpKdAX/iK+HTl+8CAwEAAaOBkjCBjzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIE
|
14
|
+
sDAdBgNVHQ4EFgQUDK0j20TQf2JavxEol3uqYPJd0VMwKgYDVR0RBCMwIYEfZGFu
|
15
|
+
aWVsLnZpbmNpZ3VlcnJhQGJpdmVlLmNvbS5icjAqBgNVHRIEIzAhgR9kYW5pZWwu
|
16
|
+
dmluY2lndWVycmFAYml2ZWUuY29tLmJyMA0GCSqGSIb3DQEBBQUAA4IBAQC5w9TB
|
17
|
+
hYsuhssatjtNdiUzfVTvYqiVVLxeD5kCLDO4OhSRw4Ib2aR6qncETgVJOak0tJ2y
|
18
|
+
v93JMpJVF8qWeC30IqCuAIoyFPdPXZWZPI489WUBg62qZEiQrIx1n3id2Ax20Yp6
|
19
|
+
yRdKomE9XulDDvKSTNyahW5a8uW020EQdFwUvJRJDnKyZmRvOXNgz4OTkcJLklhj
|
20
|
+
CmHhTfuGALBs6mmvBr1D+l4mA48E9HDV5jl0vKDnB4ewBefj/GsxcQND8B+W2DDU
|
21
|
+
diaADa2ZCuoGQuZU33vnJTmu7oy7ZUGOgo7qmoUAYbsn1x5la4sWQ6WHlH/UHDKJ
|
22
|
+
2N5QQXzs6+3RwTLN
|
23
|
+
-----END CERTIFICATE-----
|
data/lib/business-br.rb
CHANGED
@@ -1,13 +1,9 @@
|
|
1
|
-
require "business-br/version"
|
2
|
-
|
3
1
|
# register our paths
|
4
2
|
lib_dir = File.expand_path(File.dirname(__FILE__))
|
5
3
|
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
|
6
4
|
|
7
|
-
require 'business-br/
|
5
|
+
require 'business-br/version'
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
7
|
+
require 'business-br/cep'
|
8
|
+
require 'business-br/cpf'
|
9
|
+
require 'business-br/cnpj'
|
data/lib/business-br/cep.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative './cep/providers'
|
2
|
+
|
1
3
|
module Business::BR
|
2
4
|
class CEP
|
3
5
|
|
@@ -59,6 +61,15 @@ module Business::BR
|
|
59
61
|
else 'CAIXAPOSTAL';
|
60
62
|
end
|
61
63
|
end
|
62
|
-
|
64
|
+
|
65
|
+
def search_by(cep, provider:'Postmon')
|
66
|
+
if cep_provider = Business::BR::CEP::Providers.get_provider(provider)
|
67
|
+
return cep_provider.search_by(cep)
|
68
|
+
end
|
69
|
+
nil
|
70
|
+
end
|
71
|
+
|
63
72
|
end
|
64
73
|
end
|
74
|
+
|
75
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative './providers/base'
|
2
|
+
require_relative './providers/postmon'
|
3
|
+
require_relative './providers/republicavirtual'
|
4
|
+
|
5
|
+
module Business
|
6
|
+
module BR
|
7
|
+
class CEP
|
8
|
+
class Providers
|
9
|
+
|
10
|
+
def self.get_provider(provider)
|
11
|
+
return nil unless provider
|
12
|
+
begin
|
13
|
+
if provider_class = eval("Business::BR::CEP::Providers::#{provider}")
|
14
|
+
return provider_class.new
|
15
|
+
end
|
16
|
+
rescue
|
17
|
+
return nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end # Providers
|
22
|
+
end # CEP
|
23
|
+
end # BR
|
24
|
+
end # Business
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
|
3
|
+
module Business
|
4
|
+
module BR
|
5
|
+
class CEP
|
6
|
+
class Providers
|
7
|
+
class Base
|
8
|
+
attr_accessor :zipcode
|
9
|
+
|
10
|
+
protected
|
11
|
+
# response entity
|
12
|
+
def create_entity(json, extract:{})
|
13
|
+
json = json.class == String ? decode_json(json) : json
|
14
|
+
|
15
|
+
# getting informations
|
16
|
+
extracted = Hash.new
|
17
|
+
extract.each do |key, value|
|
18
|
+
extracted[key] = (value.class == Symbol ? json[value] : value)
|
19
|
+
end
|
20
|
+
|
21
|
+
extracted
|
22
|
+
end
|
23
|
+
|
24
|
+
# decode json
|
25
|
+
def decode_json(str)
|
26
|
+
JSON.parse(str, symbolize_names: true)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end # Providers
|
31
|
+
end # CEP
|
32
|
+
end # BR
|
33
|
+
end # Business
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Business
|
2
|
+
module BR
|
3
|
+
class CEP
|
4
|
+
class Providers
|
5
|
+
class Postmon < Base
|
6
|
+
|
7
|
+
def search_by(cep)
|
8
|
+
@zipcode = cep
|
9
|
+
response = RestClient.get "http://api.postmon.com.br/v1/cep/#{@zipcode}"
|
10
|
+
parse_response(response)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def parse_response(response)
|
15
|
+
json = decode_json(response)
|
16
|
+
create_entity(
|
17
|
+
json, extract: {
|
18
|
+
zipcode: :cep,
|
19
|
+
street: :logradouro,
|
20
|
+
complement: :complemento,
|
21
|
+
neighborhood: :bairro,
|
22
|
+
city: :cidade,
|
23
|
+
state: "#{json[:estado_info][:nome]}",
|
24
|
+
uf: :estado
|
25
|
+
}
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end # Providers
|
31
|
+
end # CEP
|
32
|
+
end # BR
|
33
|
+
end # Business
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Business
|
2
|
+
module BR
|
3
|
+
class CEP
|
4
|
+
class Providers
|
5
|
+
class RepublicaVirtual < Base
|
6
|
+
|
7
|
+
|
8
|
+
def search_by(cep)
|
9
|
+
@zipcode = cep
|
10
|
+
response = RestClient.get "http://cep.republicavirtual.com.br/web_cep.php?cep=#{@zipcode}&formato=json"
|
11
|
+
parse_response(response)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def parse_response(response)
|
16
|
+
json = decode_json(response)
|
17
|
+
create_entity(
|
18
|
+
json, extract: {
|
19
|
+
zipcode: @zipcode,
|
20
|
+
street: "#{json[:tipo_logradouro]} #{json[:logradouro]}",
|
21
|
+
complement: "",
|
22
|
+
neighborhood: :bairro,
|
23
|
+
city: :cidade,
|
24
|
+
state: :uf,
|
25
|
+
uf: :uf
|
26
|
+
}
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end # Providers
|
32
|
+
end # CEP
|
33
|
+
end # BR
|
34
|
+
end # Business
|
data/lib/business-br/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,38 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: business-br
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Vinciguerra
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
|
-
cert_chain:
|
11
|
-
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDyDCCArCgAwIBAgIBATANBgkqhkiG9w0BAQUFADBdMRswGQYDVQQDDBJkYW5p
|
14
|
+
ZWwudmluY2lndWVycmExFTATBgoJkiaJk/IsZAEZFgViaXZlZTETMBEGCgmSJomT
|
15
|
+
8ixkARkWA2NvbTESMBAGCgmSJomT8ixkARkWAmJyMB4XDTE2MTEyMzE4MzM1NloX
|
16
|
+
DTE3MTEyMzE4MzM1NlowXTEbMBkGA1UEAwwSZGFuaWVsLnZpbmNpZ3VlcnJhMRUw
|
17
|
+
EwYKCZImiZPyLGQBGRYFYml2ZWUxEzARBgoJkiaJk/IsZAEZFgNjb20xEjAQBgoJ
|
18
|
+
kiaJk/IsZAEZFgJicjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOMt
|
19
|
+
U5fmAykQFjl3S7tqIzMUeHkFT5jACDbYRTmo5lTVFapjKelf7xOrAfmEuPyywXIi
|
20
|
+
uePaImcfWxUF6zz0VOjcBcmvIzEo1T+w9u8J2Mq7uNyIL5Cbg1cRoh4dxknklowv
|
21
|
+
mGY/NPm4GD+Sm+gwmhXw7nDFQNhxBF1LtsZjv79Tc3gTAGyayN6sfCwtvp3gAluy
|
22
|
+
1+GRj9EyO5moR5nhagDx7e1P2GO7wwXsKjSD+Azzlk908lwdeasKvw+d/JFzGmxh
|
23
|
+
S5lyGEzc99bFwsn07rTh+x2lKBZnlGwdOKEA0zcX+blhGULcO7Q4p7QvHUtPFh02
|
24
|
+
kseIkpKdAX/iK+HTl+8CAwEAAaOBkjCBjzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIE
|
25
|
+
sDAdBgNVHQ4EFgQUDK0j20TQf2JavxEol3uqYPJd0VMwKgYDVR0RBCMwIYEfZGFu
|
26
|
+
aWVsLnZpbmNpZ3VlcnJhQGJpdmVlLmNvbS5icjAqBgNVHRIEIzAhgR9kYW5pZWwu
|
27
|
+
dmluY2lndWVycmFAYml2ZWUuY29tLmJyMA0GCSqGSIb3DQEBBQUAA4IBAQC5w9TB
|
28
|
+
hYsuhssatjtNdiUzfVTvYqiVVLxeD5kCLDO4OhSRw4Ib2aR6qncETgVJOak0tJ2y
|
29
|
+
v93JMpJVF8qWeC30IqCuAIoyFPdPXZWZPI489WUBg62qZEiQrIx1n3id2Ax20Yp6
|
30
|
+
yRdKomE9XulDDvKSTNyahW5a8uW020EQdFwUvJRJDnKyZmRvOXNgz4OTkcJLklhj
|
31
|
+
CmHhTfuGALBs6mmvBr1D+l4mA48E9HDV5jl0vKDnB4ewBefj/GsxcQND8B+W2DDU
|
32
|
+
diaADa2ZCuoGQuZU33vnJTmu7oy7ZUGOgo7qmoUAYbsn1x5la4sWQ6WHlH/UHDKJ
|
33
|
+
2N5QQXzs6+3RwTLN
|
34
|
+
-----END CERTIFICATE-----
|
35
|
+
date: 2016-11-23 00:00:00.000000000 Z
|
12
36
|
dependencies:
|
13
37
|
- !ruby/object:Gem::Dependency
|
14
38
|
name: bundler
|
@@ -52,6 +76,26 @@ dependencies:
|
|
52
76
|
- - "~>"
|
53
77
|
- !ruby/object:Gem::Version
|
54
78
|
version: '3.0'
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: webmock
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - "~>"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '2.1'
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 2.1.0
|
89
|
+
type: :development
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '2.1'
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 2.1.0
|
55
99
|
description: Business::BR is a namespace to place all validations like CPF, CNPJ,
|
56
100
|
CEP and some other things to be used in a brazilian ruby project.
|
57
101
|
email:
|
@@ -67,8 +111,13 @@ files:
|
|
67
111
|
- README.md
|
68
112
|
- Rakefile
|
69
113
|
- business-br.gemspec
|
114
|
+
- certs/dvinciguerra.pem
|
70
115
|
- lib/business-br.rb
|
71
116
|
- lib/business-br/cep.rb
|
117
|
+
- lib/business-br/cep/providers.rb
|
118
|
+
- lib/business-br/cep/providers/base.rb
|
119
|
+
- lib/business-br/cep/providers/postmon.rb
|
120
|
+
- lib/business-br/cep/providers/republicavirtual.rb
|
72
121
|
- lib/business-br/cnpj.rb
|
73
122
|
- lib/business-br/cpf.rb
|
74
123
|
- lib/business-br/version.rb
|
metadata.gz.sig
ADDED
Binary file
|