business-br 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 945e0ff628076ab4ea68a869a518ab7a8ef685f4
4
+ data.tar.gz: 81942a3a415168d008103909ffce55762cc08e6a
5
+ SHA512:
6
+ metadata.gz: 9e24c5e30bc6fa9a061373f4e63c52f5ac4ee2b9ff30888ee4813b576be5f187516bd4d2b54d99ea8f3aa433ebe7f39fa5209f1550626ebbe4ca5220743ed459
7
+ data.tar.gz: aaf04550aff19c50ef761142d40189cdec78a1694bbe3fe2d2a9d5720d6a2934462cb8e9aa87b2a523579906ca47d045ab531c70cc3011986c1562e5ef926411
data/.gitignore ADDED
@@ -0,0 +1,90 @@
1
+
2
+ # Created by https://www.gitignore.io/api/perl,vim,ruby
3
+
4
+ ### Perl ###
5
+ /blib/
6
+ /.build/
7
+ _build/
8
+ cover_db/
9
+ inc/
10
+ Build
11
+ !Build/
12
+ Build.bat
13
+ .last_cover_stats
14
+ /Makefile
15
+ /Makefile.old
16
+ /MANIFEST.bak
17
+ /META.yml
18
+ /META.json
19
+ /MYMETA.*
20
+ nytprof.out
21
+ /pm_to_blib
22
+ *.o
23
+ *.bs
24
+ /_eumm/
25
+
26
+
27
+ ### Vim ###
28
+ # swap
29
+ [._]*.s[a-w][a-z]
30
+ [._]s[a-w][a-z]
31
+ # session
32
+ Session.vim
33
+ # temporary
34
+ .netrwhist
35
+ *~
36
+ # auto-generated tag files
37
+ tags
38
+
39
+
40
+ ### Ruby ###
41
+ *.gem
42
+ *.rbc
43
+ /.config
44
+ /coverage/
45
+ /InstalledFiles
46
+ /pkg/
47
+ /spec/reports/
48
+ /spec/examples.txt
49
+ /test/tmp/
50
+ /test/version_tmp/
51
+ /tmp/
52
+
53
+ # Used by dotenv library to load environment variables.
54
+ # .env
55
+
56
+ ## Specific to RubyMotion:
57
+ .dat*
58
+ .repl_history
59
+ build/
60
+ *.bridgesupport
61
+ build-iPhoneOS/
62
+ build-iPhoneSimulator/
63
+
64
+ ## Specific to RubyMotion (use of CocoaPods):
65
+ #
66
+ # We recommend against adding the Pods directory to your .gitignore. However
67
+ # you should judge for yourself, the pros and cons are mentioned at:
68
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
69
+ #
70
+ # vendor/Pods/
71
+
72
+ ## Documentation cache and generated files:
73
+ /.yardoc/
74
+ /_yardoc/
75
+ /doc/
76
+ /rdoc/
77
+
78
+ ## Environment normalization:
79
+ /.bundle/
80
+ /vendor/bundle
81
+ /lib/bundler/man/
82
+
83
+ # for a library or gem, you might want to ignore these files since the code is
84
+ # intended to run in multiple environments; otherwise, check them in:
85
+ # Gemfile.lock
86
+ # .ruby-version
87
+ # .ruby-gemset
88
+
89
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
90
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in business-br.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ business-br (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.2.5)
10
+ rake (10.4.2)
11
+ rspec (3.5.0)
12
+ rspec-core (~> 3.5.0)
13
+ rspec-expectations (~> 3.5.0)
14
+ rspec-mocks (~> 3.5.0)
15
+ rspec-core (3.5.2)
16
+ rspec-support (~> 3.5.0)
17
+ rspec-expectations (3.5.0)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.5.0)
20
+ rspec-mocks (3.5.0)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.5.0)
23
+ rspec-support (3.5.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.12)
30
+ business-br!
31
+ rake (~> 10.0)
32
+ rspec (~> 3.0)
33
+
34
+ BUNDLED WITH
35
+ 1.12.5
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Business::Br
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/business/br`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'business-br'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install business-br
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/business-br.
36
+
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
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'business-br/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "business-br"
9
+ spec.version = Business::BR::VERSION
10
+ spec.authors = ["Daniel Vinciguerra"]
11
+ spec.email = ["daniel.vinciguerra@bivee.com.br"]
12
+
13
+ spec.summary = %q{This project provide classes for validations and conversions to use in brazilian ruby projects.}
14
+ spec.description = %q{Business::BR is a namespace to place all validations like CPF, CNPJ, CEP and some other things to be used in a brazilian ruby project.}
15
+ spec.homepage = "https://github.com/dvinciguerra/business-br"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ #spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.12"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ end
@@ -0,0 +1,62 @@
1
+ module Business::BR
2
+ class CEP
3
+
4
+ @@regions = [
5
+ ['SP'],
6
+ ['SP'],
7
+ ['RJ', 'ES'],
8
+ ['MG'],
9
+ ['BA', 'SE'],
10
+ ['PE', 'AL', 'PB', 'RN'],
11
+ ['CE', 'PI', 'MA', 'PA', 'AM', 'AC', 'AP', 'RR'],
12
+ ['DF', 'GO', 'TO', 'MT', 'MG', 'RO'],
13
+ ['PR', 'SC'],
14
+ ['RS'],
15
+ ]
16
+
17
+
18
+ def initialize(opts = {})
19
+ @opts = opts || {}
20
+ end
21
+
22
+
23
+ def validate(cep)
24
+ return false unless cep =~ /^\d{5}-?\d{3}$/
25
+ return false unless cep.length == 8 || cep.length == 9
26
+ true
27
+ end
28
+
29
+
30
+ def valid?(cep)
31
+ validate(cep)
32
+ end
33
+
34
+
35
+ def normalize(cep)
36
+ raise Exception.new('This cep is not valid') unless valid?(cep)
37
+ "#{$1}-#{$2}" if cep =~ /^(\d{5})-?(\d{3})$/
38
+ end
39
+
40
+
41
+ def region(cep)
42
+ raise Exception.new('This cep is not valid') unless valid?(cep)
43
+ @@regions[cep[0].to_i]
44
+ end
45
+
46
+
47
+ def type(cep)
48
+ raise Exception.new('This cep is not valid') unless valid?(cep)
49
+
50
+ cep = normalize(cep)
51
+ suffix = cep[6..8].to_i
52
+ case
53
+ when suffix < 900 then 'LOGRADOURO'
54
+ when suffix < 960 then 'ESPECIAL'
55
+ when suffix < 970 then 'PROMOCIONAIS'
56
+ when suffix < 990 || suffix == 999 then 'CORREIOS'
57
+ else 'CAIXAPOSTAL';
58
+ end
59
+ end
60
+
61
+ end
62
+ end
@@ -0,0 +1,5 @@
1
+ module Business
2
+ module BR
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ require "business-br/version"
2
+
3
+ # register our paths
4
+ lib_dir = File.expand_path(File.dirname(__FILE__))
5
+ $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
6
+
7
+ require 'business-br/cep'
8
+
9
+ module Business::BR
10
+ def self::load(clazz)
11
+ clazz.new
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: business-br
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Vinciguerra
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-09-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: Business::BR is a namespace to place all validations like CPF, CNPJ,
56
+ CEP and some other things to be used in a brazilian ruby project.
57
+ email:
58
+ - daniel.vinciguerra@bivee.com.br
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - README.md
67
+ - Rakefile
68
+ - business-br.gemspec
69
+ - lib/business-br.rb
70
+ - lib/business-br/cep.rb
71
+ - lib/business-br/version.rb
72
+ homepage: https://github.com/dvinciguerra/business-br
73
+ licenses: []
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.5.1
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: This project provide classes for validations and conversions to use in brazilian
95
+ ruby projects.
96
+ test_files: []