ceplivre 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +15 -0
- data/Rakefile +6 -0
- data/ceplivre.gemspec +22 -0
- data/lib/ceplivre/configuration.rb +13 -0
- data/lib/ceplivre/version.rb +3 -0
- data/lib/ceplivre.rb +14 -0
- data/spec/ceplivre/configuration_spec.rb +19 -0
- data/spec/ceplivre_spec.rb +14 -0
- data/spec/spec_helper.rb +1 -0
- metadata +70 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# ceplivre gem
|
2
|
+
|
3
|
+
## Como configurar
|
4
|
+
|
5
|
+
Crie um arquivo de configuração na sua aplicação rails.
|
6
|
+
|
7
|
+
/config/initializers/ceplivre.rb
|
8
|
+
|
9
|
+
CepLivre::Configuration.key = "Key recebida do cep livre"
|
10
|
+
|
11
|
+
## Como utiliza
|
12
|
+
|
13
|
+
Basta chamar utilizar o seguinte comando:
|
14
|
+
|
15
|
+
CepLivre::Cep.find("22030-030", :json)
|
data/Rakefile
ADDED
data/ceplivre.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "ceplivre/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "ceplivre"
|
7
|
+
s.version = Ceplivre::VERSION
|
8
|
+
s.authors = ["Eduardo Fiorezi"]
|
9
|
+
s.email = ["eduardofiorezi@gmail.com"]
|
10
|
+
s.homepage = "http://hooppe.com"
|
11
|
+
s.summary = %q{Gem para utilizar a api ceplivre}
|
12
|
+
s.description = %q{Utilize a API ceplivre na sua aplicação}
|
13
|
+
|
14
|
+
s.rubyforge_project = "ceplivre"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_development_dependency "rspec"
|
22
|
+
end
|
data/lib/ceplivre.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "ceplivre/version"
|
2
|
+
require "ceplivre/configuration"
|
3
|
+
|
4
|
+
require "httparty"
|
5
|
+
|
6
|
+
module CepLivre
|
7
|
+
class Cep
|
8
|
+
include HTTParty
|
9
|
+
|
10
|
+
def self.find(cep, format)
|
11
|
+
self.get("http://ceplivre.com.br/consultar/cep/#{CepLivre::Configuration.key}/#{cep}/#{format}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "CepLivre::Configuration" do
|
5
|
+
before do
|
6
|
+
CepLivre::Configuration.key = nil
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should get the ceplivre key" do
|
10
|
+
CepLivre::Configuration.key.should == "your_key"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should set a key for ceplivre api" do
|
14
|
+
key_to_test = "122345677009212"
|
15
|
+
|
16
|
+
CepLivre::Configuration.key = key_to_test
|
17
|
+
CepLivre::Configuration.key.should == key_to_test
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "CepLivre" do
|
5
|
+
before do
|
6
|
+
CepLivre::Configuration.key = "" #add a test key
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "find_cep" do
|
10
|
+
it "should get data from cep livre api" do
|
11
|
+
CepLivre::Cep.find("22031-030", :json).should == {"cep"=>[{"tp_logradouro"=>"Rua", "tp_logradouro_id"=>"11", "logradouro"=>"Silva Castro", "bairro"=>"Copacabana", "cidade"=>"Rio de Janeiro", "uf_sigla"=>"RJ", "ufnome"=>"Rio de Janeiro", "id_estado_ibge"=>"33", "cep"=>"22031-030", "muncoddv"=>"3304557", "ddd"=>"21", "altitude"=>"2", "latitude"=>"-22.903", "longitude"=>"-43.208", "area"=>"1182.296", "capital"=>"S"}]}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'ceplivre'
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ceplivre
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Eduardo Fiorezi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-09 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70346309491800 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70346309491800
|
25
|
+
description: Utilize a API ceplivre na sua aplicação
|
26
|
+
email:
|
27
|
+
- eduardofiorezi@gmail.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- README.md
|
35
|
+
- Rakefile
|
36
|
+
- ceplivre.gemspec
|
37
|
+
- lib/ceplivre.rb
|
38
|
+
- lib/ceplivre/configuration.rb
|
39
|
+
- lib/ceplivre/version.rb
|
40
|
+
- spec/ceplivre/configuration_spec.rb
|
41
|
+
- spec/ceplivre_spec.rb
|
42
|
+
- spec/spec_helper.rb
|
43
|
+
homepage: http://hooppe.com
|
44
|
+
licenses: []
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project: ceplivre
|
63
|
+
rubygems_version: 1.8.10
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: Gem para utilizar a api ceplivre
|
67
|
+
test_files:
|
68
|
+
- spec/ceplivre/configuration_spec.rb
|
69
|
+
- spec/ceplivre_spec.rb
|
70
|
+
- spec/spec_helper.rb
|