ceplivre 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+ gem 'httparty'
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
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
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
@@ -0,0 +1,13 @@
1
+ module CepLivre
2
+ class Configuration
3
+ @@key = nil
4
+
5
+ def self.key
6
+ @@key || "your_key"
7
+ end
8
+
9
+ def self.key=(key)
10
+ @@key = key
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module Ceplivre
2
+ VERSION = "0.0.1"
3
+ 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
@@ -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