ceps 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8e6c5306fd2ad80bdd6663776b0d48fccf445f21
4
+ data.tar.gz: 4235a3a60f49cbcca3be83d5bd81475a20558d03
5
+ SHA512:
6
+ metadata.gz: 191cb4ec2fceaabbf1d9d17c379025f93245bfa945eb8a33212c79dbfa2689314b696f1976d96e900e2f008c4e3485befb45fc782fcd2ba0f306122b1e394d69
7
+ data.tar.gz: ac54e7a5d459cb408d8be745c6dc93afbca1ba1dc758b34466bf44832e07ac054672123595f45b10ddc59238ff0354109528d6cf8942520d5850994b124ce7e7
data/.gitignore ADDED
File without changes
data/README.md ADDED
File without changes
data/ceps.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ # -*- enconding: utf-8 -*-
2
+
3
+ require File.expand_path('../lib/ceps/version', __FILE__)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.authors = ['Thiago Miranda']
7
+ gem.email = ['theprogramer@theprogramer.com.br']
8
+ gem.description = 'All sorts of useful information about every brazilian cep packaged as pretty little cep objects.'
9
+ gem.summary = 'Gives you a cep object full of all sorts of useful information.'
10
+ gem.homepage = 'http://github.com/theprogramer/ceps'
11
+
12
+ gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
13
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+ gem.name = 'ceps'
16
+ gem.require_paths = ['lib']
17
+ gem.version = Ceps::VERSION
18
+
19
+ gem.add_development_dependency('rspec', '>= 3')
20
+ end
data/lib/ceps/cep.rb ADDED
@@ -0,0 +1,48 @@
1
+ module Correios
2
+
3
+ class Cep
4
+
5
+ Setup = Correios::Setup.new
6
+
7
+ AttrReaders = [
8
+ :location,
9
+ :type,
10
+ :neighborhood,
11
+ :city,
12
+ :state
13
+ ]
14
+
15
+ AttrReaders.each do |meth|
16
+ define_method meth do
17
+ @data[meth.to_s]
18
+ end
19
+ end
20
+
21
+ attr_reader :data
22
+
23
+ def initialize(cep)
24
+ @data = cep.is_a?(Hash) ? cep : Setup.ceps[cep]
25
+ end
26
+
27
+ def valid?
28
+ !(@data.nil? || @data.empty?)
29
+ end
30
+
31
+ def ==(other)
32
+ other == data
33
+ end
34
+
35
+ private
36
+
37
+ class << self
38
+
39
+ def new(cep)
40
+ if cep.is_a?(Hash) || Setup.ceps.keys.include?(cep)
41
+ super
42
+ end
43
+ end
44
+
45
+ end
46
+ end
47
+
48
+ end
data/lib/ceps/setup.rb ADDED
@@ -0,0 +1,21 @@
1
+ module Correios
2
+
3
+ ##
4
+ # Handles building the in memory store of CEP data
5
+ class Setup
6
+ def ceps
7
+ return @ceps if instance_variable_defined?('@ceps')
8
+ @ceps ||= load(['data', 'ceps.yaml'])
9
+ end
10
+
11
+ private
12
+
13
+ def datafile_path(file_array)
14
+ File.join([File.dirname(__FILE__), '..'] + file_array)
15
+ end
16
+
17
+ def load(file_array)
18
+ YAML.load_file(datafile_path(file_array))
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Ceps
2
+ VERSION = '0.0.1'
3
+ end
data/lib/ceps.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'ceps/version'
2
+
3
+ require 'correios'
4
+
5
+ class Cep < Correios::Cep
6
+
7
+ end
data/lib/correios.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'yaml'
2
+
3
+ require 'ceps/setup'
4
+ require 'ceps/cep'
@@ -0,0 +1,25 @@
1
+ ---
2
+ 10000000:
3
+ location: Paulista
4
+ type: Rua
5
+ neighbourhood: Centro
6
+ city: São Paulo
7
+ state: São Paulo
8
+ 20000000:
9
+ location: Carioca
10
+ type: Rua
11
+ neighbourhood: Centro
12
+ city: Rio de Janeiro
13
+ state: Rio de Janeiro
14
+ 20000500:
15
+ location: Carioquinha
16
+ type: Avenida
17
+ neighbourhood: Copacabana
18
+ city: Rio de Janeiro
19
+ state: Rio de Janeiro
20
+ 30000000:
21
+ location: Mineira
22
+ type: Avenida
23
+ neighbourhood: Centro
24
+ city: Belo Horizonte
25
+ state: Minas Gerais
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ceps
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Thiago Miranda
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3'
27
+ description: All sorts of useful information about every brazilian cep packaged as
28
+ pretty little cep objects.
29
+ email:
30
+ - theprogramer@theprogramer.com.br
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".gitignore"
36
+ - README.md
37
+ - ceps.gemspec
38
+ - lib/ceps.rb
39
+ - lib/ceps/cep.rb
40
+ - lib/ceps/setup.rb
41
+ - lib/ceps/version.rb
42
+ - lib/correios.rb
43
+ - lib/data/ceps.yaml
44
+ homepage: http://github.com/theprogramer/ceps
45
+ licenses: []
46
+ metadata: {}
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 2.2.2
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: Gives you a cep object full of all sorts of useful information.
67
+ test_files: []