ffaker-cpfcnpj 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ gem 'brazilian-rails'
6
+ gem 'ffaker'
7
+ # Add dependencies to develop your gem here.
8
+ # Include everything needed to run rake, tests, features, etc.
9
+ group :development do
10
+ gem "rspec", "~> 2.3.0"
11
+ gem "bundler", "~> 1.0.0"
12
+ gem "jeweler", "~> 1.6.4"
13
+ gem "rcov", ">= 0"
14
+ gem 'pry'
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,117 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionpack (3.1.0)
5
+ activemodel (= 3.1.0)
6
+ activesupport (= 3.1.0)
7
+ builder (~> 3.0.0)
8
+ erubis (~> 2.7.0)
9
+ i18n (~> 0.6)
10
+ rack (~> 1.3.2)
11
+ rack-cache (~> 1.0.3)
12
+ rack-mount (~> 0.8.2)
13
+ rack-test (~> 0.6.1)
14
+ sprockets (~> 2.0.0)
15
+ activemodel (3.1.0)
16
+ activesupport (= 3.1.0)
17
+ bcrypt-ruby (~> 3.0.0)
18
+ builder (~> 3.0.0)
19
+ i18n (~> 0.6)
20
+ activerecord (3.1.0)
21
+ activemodel (= 3.1.0)
22
+ activesupport (= 3.1.0)
23
+ arel (~> 2.2.1)
24
+ tzinfo (~> 0.3.29)
25
+ activesupport (3.1.0)
26
+ multi_json (~> 1.0)
27
+ arel (2.2.1)
28
+ bcrypt-ruby (3.0.0)
29
+ brI18n (3.0.4)
30
+ actionpack (>= 3.0.0)
31
+ activerecord (>= 3.0.0)
32
+ activesupport (>= 3.0.0)
33
+ brazilian-rails (3.0.4)
34
+ brI18n (= 3.0.4)
35
+ brcep (= 3.0.4)
36
+ brcpfcnpj (= 3.0.4)
37
+ brdata (= 3.0.4)
38
+ brdinheiro (= 3.0.4)
39
+ brhelper (= 3.0.4)
40
+ brnumeros (= 3.0.4)
41
+ brstring (= 3.0.4)
42
+ brcep (3.0.4)
43
+ brcpfcnpj (3.0.4)
44
+ actionpack (>= 3.0.0)
45
+ activesupport (>= 3.0.0)
46
+ brdata (3.0.4)
47
+ actionpack (>= 3.0.0)
48
+ activesupport (>= 3.0.0)
49
+ brdinheiro (3.0.4)
50
+ actionpack (>= 3.0.0)
51
+ activerecord (>= 3.0.0)
52
+ brnumeros (= 3.0.4)
53
+ brhelper (3.0.4)
54
+ actionpack (>= 3.0.0)
55
+ activesupport (>= 3.0.0)
56
+ brnumeros (3.0.4)
57
+ brstring (3.0.4)
58
+ activesupport (>= 3.0.0)
59
+ builder (3.0.0)
60
+ coderay (0.9.8)
61
+ diff-lcs (1.1.3)
62
+ erubis (2.7.0)
63
+ ffaker (1.8.1)
64
+ git (1.2.5)
65
+ hike (1.2.1)
66
+ i18n (0.6.0)
67
+ jeweler (1.6.4)
68
+ bundler (~> 1.0)
69
+ git (>= 1.2.5)
70
+ rake
71
+ method_source (0.6.0)
72
+ ruby_parser (>= 2.0.5)
73
+ multi_json (1.0.3)
74
+ pry (0.9.3)
75
+ coderay (>= 0.9.8)
76
+ method_source (>= 0.6.0)
77
+ ruby_parser (>= 2.0.5)
78
+ slop (~> 1.9.0)
79
+ rack (1.3.2)
80
+ rack-cache (1.0.3)
81
+ rack (>= 0.4)
82
+ rack-mount (0.8.3)
83
+ rack (>= 1.0.0)
84
+ rack-test (0.6.1)
85
+ rack (>= 1.0)
86
+ rake (0.9.2)
87
+ rcov (0.9.10)
88
+ rspec (2.3.0)
89
+ rspec-core (~> 2.3.0)
90
+ rspec-expectations (~> 2.3.0)
91
+ rspec-mocks (~> 2.3.0)
92
+ rspec-core (2.3.1)
93
+ rspec-expectations (2.3.0)
94
+ diff-lcs (~> 1.1.2)
95
+ rspec-mocks (2.3.0)
96
+ ruby_parser (2.0.6)
97
+ sexp_processor (~> 3.0)
98
+ sexp_processor (3.0.6)
99
+ slop (1.9.1)
100
+ sprockets (2.0.0)
101
+ hike (~> 1.2)
102
+ rack (~> 1.0)
103
+ tilt (~> 1.1, != 1.3.0)
104
+ tilt (1.3.3)
105
+ tzinfo (0.3.29)
106
+
107
+ PLATFORMS
108
+ ruby
109
+
110
+ DEPENDENCIES
111
+ brazilian-rails
112
+ bundler (~> 1.0.0)
113
+ ffaker
114
+ jeweler (~> 1.6.4)
115
+ pry
116
+ rcov
117
+ rspec (~> 2.3.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Halan Pinheiro
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,23 @@
1
+ = ffaker-cpfcnpj
2
+
3
+ Quick start
4
+
5
+ Faker.CPFCNPJ.cpf # generate a valid cpf
6
+ Faker.CPFCNPJ.cnpj # generate a valid cnpj
7
+
8
+
9
+ == Contributing to ffaker-cpfcnpj
10
+
11
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
12
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
13
+ * Fork the project
14
+ * Start a feature/bugfix branch
15
+ * Commit and push until you are happy with your contribution
16
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
17
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
18
+
19
+ == Copyright
20
+
21
+ Copyright (c) 2011 Halan Pinheiro. See LICENSE.txt for
22
+ further details.
23
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "ffaker-cpfcnpj"
18
+ gem.homepage = "http://github.com/halan/ffaker-cpfcnpj"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Gem to extend FFaker to generate valids brazilian CPF or CNPJ}
21
+ gem.description = %Q{Gem to extend FFaker to generate valids brazilian CPF or CNPJ}
22
+ gem.email = "halan.pinheiro@gmail.com"
23
+ gem.authors = ["Halan Pinheiro"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rake/rdoctask'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "ffaker-cpfcnpj #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,72 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{ffaker-cpfcnpj}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Halan Pinheiro"]
12
+ s.date = %q{2011-09-03}
13
+ s.description = %q{Gem to extend FFaker to generate valids brazilian CPF or CNPJ}
14
+ s.email = %q{halan.pinheiro@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "ffaker-cpfcnpj.gemspec",
29
+ "lib/ffaker-cpfcnpj.rb",
30
+ "lib/ffaker-cpfcnpj/brazilian-rails/cpfcnpj.rb",
31
+ "lib/ffaker-cpfcnpj/cpfcnpj.rb",
32
+ "spec/ffaker-cpfcnpj_spec.rb",
33
+ "spec/spec_helper.rb"
34
+ ]
35
+ s.homepage = %q{http://github.com/halan/ffaker-cpfcnpj}
36
+ s.licenses = ["MIT"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = %q{1.3.7}
39
+ s.summary = %q{Gem to extend FFaker to generate valids brazilian CPF or CNPJ}
40
+
41
+ if s.respond_to? :specification_version then
42
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ s.add_runtime_dependency(%q<brazilian-rails>, [">= 0"])
47
+ s.add_runtime_dependency(%q<ffaker>, [">= 0"])
48
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
49
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
50
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
51
+ s.add_development_dependency(%q<rcov>, [">= 0"])
52
+ s.add_development_dependency(%q<pry>, [">= 0"])
53
+ else
54
+ s.add_dependency(%q<brazilian-rails>, [">= 0"])
55
+ s.add_dependency(%q<ffaker>, [">= 0"])
56
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
57
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
58
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
59
+ s.add_dependency(%q<rcov>, [">= 0"])
60
+ s.add_dependency(%q<pry>, [">= 0"])
61
+ end
62
+ else
63
+ s.add_dependency(%q<brazilian-rails>, [">= 0"])
64
+ s.add_dependency(%q<ffaker>, [">= 0"])
65
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
66
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
67
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
68
+ s.add_dependency(%q<rcov>, [">= 0"])
69
+ s.add_dependency(%q<pry>, [">= 0"])
70
+ end
71
+ end
72
+
@@ -0,0 +1,11 @@
1
+ module CpfCnpj
2
+ def gerar n
3
+ numbers_length = (self.instance_of?(Cpf) ? 11 : 14 )
4
+ @numero = n.to_s.rjust(numbers_length-2, '0')+'00'
5
+ @numero_puro = @numero[0..-3]
6
+ primeiro_verificador = primeiro_digito_verificador
7
+ segundo_verificador = segundo_digito_verificador(primeiro_verificador)
8
+ verificadores = primeiro_verificador+segundo_verificador
9
+ self.class.new(@numero_puro+verificadores)
10
+ end
11
+ end
@@ -0,0 +1,22 @@
1
+ require 'brazilian-rails'
2
+ require 'ffaker-cpfcnpj/brazilian-rails/cpfcnpj'
3
+
4
+ module Faker
5
+ module CPFCNPJ
6
+ extend ModuleUtils
7
+ extend self
8
+
9
+ def cpf seed = nil
10
+ Cpf.new('').gerar generate_seed(seed)
11
+ end
12
+
13
+ def cnpj seed = nil
14
+ Cnpj.new('').gerar generate_seed(seed)
15
+ end
16
+
17
+ private
18
+ def generate_seed seed = nil
19
+ seed or (1..99999).to_a.choice
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module Faker
2
+ autoload :CPFCNPJ, 'ffaker-cpfcnpj/cpfcnpj'
3
+ end
@@ -0,0 +1,20 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ require 'ffaker'
4
+ require 'ffaker-cpfcnpj'
5
+
6
+ describe "FfakerCpfcnpj" do
7
+ describe 'Cpf' do
8
+ subject {Faker::CPFCNPJ.cpf }
9
+
10
+ it { should be_valido }
11
+ it { should be_kind_of(Cpf) }
12
+ end
13
+
14
+ describe 'Cnpj' do
15
+ subject {Faker::CPFCNPJ.cnpj }
16
+
17
+ it { should be_valido }
18
+ it { should be_kind_of(Cnpj) }
19
+ end
20
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'ffaker-cpfcnpj'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,184 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ffaker-cpfcnpj
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Halan Pinheiro
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-09-03 00:00:00 -03:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ type: :runtime
23
+ prerelease: false
24
+ name: brazilian-rails
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
+ requirement: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ type: :runtime
37
+ prerelease: false
38
+ name: ffaker
39
+ version_requirements: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ requirement: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ type: :development
51
+ prerelease: false
52
+ name: rspec
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 2
61
+ - 3
62
+ - 0
63
+ version: 2.3.0
64
+ requirement: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ type: :development
67
+ prerelease: false
68
+ name: bundler
69
+ version_requirements: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ hash: 23
75
+ segments:
76
+ - 1
77
+ - 0
78
+ - 0
79
+ version: 1.0.0
80
+ requirement: *id004
81
+ - !ruby/object:Gem::Dependency
82
+ type: :development
83
+ prerelease: false
84
+ name: jeweler
85
+ version_requirements: &id005 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ hash: 7
91
+ segments:
92
+ - 1
93
+ - 6
94
+ - 4
95
+ version: 1.6.4
96
+ requirement: *id005
97
+ - !ruby/object:Gem::Dependency
98
+ type: :development
99
+ prerelease: false
100
+ name: rcov
101
+ version_requirements: &id006 !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ requirement: *id006
111
+ - !ruby/object:Gem::Dependency
112
+ type: :development
113
+ prerelease: false
114
+ name: pry
115
+ version_requirements: &id007 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ hash: 3
121
+ segments:
122
+ - 0
123
+ version: "0"
124
+ requirement: *id007
125
+ description: Gem to extend FFaker to generate valids brazilian CPF or CNPJ
126
+ email: halan.pinheiro@gmail.com
127
+ executables: []
128
+
129
+ extensions: []
130
+
131
+ extra_rdoc_files:
132
+ - LICENSE.txt
133
+ - README.rdoc
134
+ files:
135
+ - .document
136
+ - .rspec
137
+ - Gemfile
138
+ - Gemfile.lock
139
+ - LICENSE.txt
140
+ - README.rdoc
141
+ - Rakefile
142
+ - VERSION
143
+ - ffaker-cpfcnpj.gemspec
144
+ - lib/ffaker-cpfcnpj.rb
145
+ - lib/ffaker-cpfcnpj/brazilian-rails/cpfcnpj.rb
146
+ - lib/ffaker-cpfcnpj/cpfcnpj.rb
147
+ - spec/ffaker-cpfcnpj_spec.rb
148
+ - spec/spec_helper.rb
149
+ has_rdoc: true
150
+ homepage: http://github.com/halan/ffaker-cpfcnpj
151
+ licenses:
152
+ - MIT
153
+ post_install_message:
154
+ rdoc_options: []
155
+
156
+ require_paths:
157
+ - lib
158
+ required_ruby_version: !ruby/object:Gem::Requirement
159
+ none: false
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ hash: 3
164
+ segments:
165
+ - 0
166
+ version: "0"
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
168
+ none: false
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ hash: 3
173
+ segments:
174
+ - 0
175
+ version: "0"
176
+ requirements: []
177
+
178
+ rubyforge_project:
179
+ rubygems_version: 1.3.7
180
+ signing_key:
181
+ specification_version: 3
182
+ summary: Gem to extend FFaker to generate valids brazilian CPF or CNPJ
183
+ test_files: []
184
+