ffaker 0.4.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,7 +16,7 @@ A port of Perl's Data::Faker library that generates fake data.
16
16
 
17
17
  == Ffaker / Faker
18
18
 
19
- The only difference between faker and ffaker is that you need to
19
+ The are only two differences between faker and ffaker. The first one is that you need to
20
20
 
21
21
  gem install ffaker
22
22
 
@@ -28,6 +28,14 @@ instead of "faker" with only one f.
28
28
 
29
29
  The API is pretty much the same as before.
30
30
 
31
+ The second difference is that Faker::VERSION is no longer a module, so instead of accessing the version like this:
32
+
33
+ Faker::VERSION::STRING # faker
34
+
35
+ you'll need to access it like this:
36
+
37
+ Faker::VERSION # ffaker
38
+
31
39
  Fork it/ping me if you feel like adding more goodies to it.
32
40
 
33
41
  == Faster? does it really matter ?
data/Rakefile CHANGED
@@ -1,22 +1,50 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
+ require 'date'
3
4
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "ffaker"
8
- gem.summary = %Q{Faker, only cleaner and faster}
9
- gem.description = %Q{Faker refactored}
10
- gem.email = "EmmanuelOga@gmail.com"
11
- gem.homepage = "http://github.com/EmmanuelOga/ffaker"
12
- gem.authors = ["Emmanuel Oga", "James Rosen", "Rafael Souza"]
13
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
- end
15
- Jeweler::GemcutterTasks.new
16
- rescue LoadError
17
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
5
+ #############################################################################
6
+ #
7
+ # Helper functions
8
+ #
9
+ #############################################################################
10
+
11
+ def name
12
+ @name ||= Dir['*.gemspec'].first.split('.').first
13
+ end
14
+
15
+ def version
16
+ line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
17
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
18
18
  end
19
19
 
20
+ def date
21
+ Date.today.to_s
22
+ end
23
+
24
+ def rubyforge_project
25
+ name
26
+ end
27
+
28
+ def gemspec_file
29
+ "#{name}.gemspec"
30
+ end
31
+
32
+ def gem_file
33
+ "#{name}-#{version}.gem"
34
+ end
35
+
36
+ def replace_header(head, header_name)
37
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
38
+ end
39
+
40
+ #############################################################################
41
+ #
42
+ # Standard tasks
43
+ #
44
+ #############################################################################
45
+
46
+ require 'rspec/core/rake_task'
47
+
20
48
  require 'rake/testtask'
21
49
  Rake::TestTask.new(:test) do |test|
22
50
  test.libs << 'lib' << 'test'
@@ -24,29 +52,114 @@ Rake::TestTask.new(:test) do |test|
24
52
  test.verbose = true
25
53
  end
26
54
 
55
+ task :default => :test
56
+
57
+ desc "Open an irb session preloaded with this library"
58
+ task :console do
59
+ sh "irb -I ./lib/ -rubygems -r ./lib/#{name}.rb"
60
+ end
61
+
62
+
63
+ #############################################################################
64
+ #
65
+ # Custom tasks (add your own tasks here)
66
+ #
67
+ #############################################################################
68
+
27
69
  begin
28
- require 'rcov/rcovtask'
29
- Rcov::RcovTask.new do |test|
30
- test.libs << 'test'
31
- test.pattern = 'test/**/test_*.rb'
32
- test.verbose = true
33
- end
70
+ require 'yard'
71
+ YARD::Rake::YardocTask.new
34
72
  rescue LoadError
35
- task :rcov do
36
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
73
+ task :yardoc do
74
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
37
75
  end
38
76
  end
39
77
 
40
- task :test => :check_dependencies
78
+ if File.directory?("features")
79
+ begin
80
+ require 'cucumber'
81
+ require 'cucumber/rake/task'
41
82
 
42
- task :default => :test
83
+ namespace :features do
84
+ Cucumber::Rake::Task.new(:all) do |t|
85
+ t.cucumber_opts = "--format pretty"
86
+ end
43
87
 
44
- require 'rake/rdoctask'
45
- Rake::RDocTask.new do |rdoc|
46
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
88
+ %w|tag|.each do |tag|
89
+ Cucumber::Rake::Task.new("#{tag}") do |t|
90
+ t.cucumber_opts = "--format pretty --tags @#{tag}"
91
+ end
92
+ end
93
+ end
47
94
 
48
- rdoc.rdoc_dir = 'rdoc'
49
- rdoc.title = "ffaker #{version}"
50
- rdoc.rdoc_files.include('README*')
51
- rdoc.rdoc_files.include('lib/**/*.rb')
95
+ rescue LoadError
96
+ desc 'Cucumber rake task not available'
97
+ task :features do
98
+ abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
99
+ end
100
+ end
101
+ end
102
+
103
+ #############################################################################
104
+ #
105
+ # Packaging tasks
106
+ #
107
+ #############################################################################
108
+
109
+ task :release => :build do
110
+ unless `git branch` =~ /^\* master$/
111
+ puts "You must be on the master branch to release!"
112
+ exit!
113
+ end
114
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
115
+ sh "git tag v#{version}"
116
+ sh "git push origin master"
117
+ sh "git push origin v#{version}"
118
+ sh "gem push pkg/#{name}-#{version}.gem"
119
+ end
120
+
121
+ task :build => :gemspec do
122
+ sh "mkdir -p pkg"
123
+ sh "gem build #{gemspec_file}"
124
+ sh "mv #{gem_file} pkg"
125
+ end
126
+
127
+ task :gemspec => :validate do
128
+ # read spec file and split out manifest section
129
+ spec = File.read(gemspec_file)
130
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
131
+
132
+ # replace name version and date
133
+ replace_header(head, :name)
134
+ replace_header(head, :version)
135
+ replace_header(head, :date)
136
+ #comment this out if your rubyforge_project has a different name
137
+ replace_header(head, :rubyforge_project)
138
+
139
+ # determine file list from git ls-files
140
+ files = `git ls-files`.
141
+ split("\n").
142
+ sort.
143
+ reject { |file| file =~ /^\./ }.
144
+ reject { |file| file =~ /^(rdoc|pkg)/ }.
145
+ map { |file| " #{file}" }.
146
+ join("\n")
147
+
148
+ # piece file back together and write
149
+ manifest = " s.files = %w[\n#{files}\n ]\n"
150
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
151
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
152
+ puts "Updated #{gemspec_file}"
153
+ end
154
+
155
+ task :validate do
156
+ libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
157
+ unless libfiles.empty?
158
+ puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
159
+ exit!
160
+ end
161
+ unless Dir['VERSION*'].empty?
162
+ puts "A `VERSION` file at root level violates Gem best practices."
163
+ exit!
164
+ end
52
165
  end
@@ -1,83 +1,59 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
1
 
6
2
  Gem::Specification.new do |s|
7
- s.name = %q{ffaker}
8
- s.version = "0.4.0"
9
-
3
+ s.specification_version = 2 if s.respond_to? :specification_version=
10
4
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Emmanuel Oga", "James Rosen", "Rafael Souza"]
12
- s.date = %q{2010-05-10}
13
- s.description = %q{Faker refactored}
14
- s.email = %q{EmmanuelOga@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- "History.txt",
23
- "LICENSE",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "ffaker.gemspec",
28
- "lib/ffaker.rb",
29
- "lib/ffaker/address.rb",
30
- "lib/ffaker/company.rb",
31
- "lib/ffaker/geolocation.rb",
32
- "lib/ffaker/internet.rb",
33
- "lib/ffaker/lorem.rb",
34
- "lib/ffaker/name.rb",
35
- "lib/ffaker/phone_number.rb",
36
- "lib/ffaker/utils/array_utils.rb",
37
- "lib/ffaker/utils/module_utils.rb",
38
- "lib/ffaker/version.rb",
39
- "scripts/benchmark.rb",
40
- "scripts/profile.sh",
41
- "scripts/profiling.rb",
42
- "test/helper.rb",
43
- "test/test_address.rb",
44
- "test/test_array_utils.rb",
45
- "test/test_company.rb",
46
- "test/test_faker.rb",
47
- "test/test_faker_internet.rb",
48
- "test/test_faker_name.rb",
49
- "test/test_geolocation.rb",
50
- "test/test_lorem.rb",
51
- "test/test_module_utils.rb",
52
- "test/test_phone_number.rb"
53
- ]
54
- s.homepage = %q{http://github.com/EmmanuelOga/ffaker}
5
+ s.rubygems_version = '1.3.5'
6
+
7
+ s.name = 'ffaker'
8
+ s.version = '1.0.0'
9
+ s.date = '2010-11-04'
10
+ s.rubyforge_project = 'ffaker'
11
+
12
+ s.summary = "Faster Faker, generates dummy data."
13
+ s.description = "Faster Faker, generates dummy data."
14
+
15
+ s.authors = ["Emmanuel Oga"]
16
+ s.email = 'EmmanuelOga@gmail.com'
17
+ s.homepage = 'http://github.com/emmanueloga/ffaker'
18
+
19
+ s.require_paths = %w[lib]
20
+
55
21
  s.rdoc_options = ["--charset=UTF-8"]
56
- s.require_paths = ["lib"]
57
- s.rubygems_version = %q{1.3.6}
58
- s.summary = %q{Faker, only cleaner and faster}
59
- s.test_files = [
60
- "test/test_faker_name.rb",
61
- "test/test_lorem.rb",
62
- "test/test_phone_number.rb",
63
- "test/test_array_utils.rb",
64
- "test/test_geolocation.rb",
65
- "test/test_address.rb",
66
- "test/test_faker_internet.rb",
67
- "test/test_faker.rb",
68
- "test/test_module_utils.rb",
69
- "test/helper.rb",
70
- "test/test_company.rb"
71
- ]
22
+ s.extra_rdoc_files = %w[README.rdoc LICENSE]
72
23
 
73
- if s.respond_to? :specification_version then
74
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
75
- s.specification_version = 3
24
+ # = MANIFEST =
25
+ s.files = %w[
26
+ History.txt
27
+ LICENSE
28
+ README.rdoc
29
+ Rakefile
30
+ ffaker.gemspec
31
+ lib/ffaker.rb
32
+ lib/ffaker/address.rb
33
+ lib/ffaker/company.rb
34
+ lib/ffaker/geolocation.rb
35
+ lib/ffaker/internet.rb
36
+ lib/ffaker/lorem.rb
37
+ lib/ffaker/name.rb
38
+ lib/ffaker/phone_number.rb
39
+ lib/ffaker/utils/array_utils.rb
40
+ lib/ffaker/utils/module_utils.rb
41
+ scripts/benchmark.rb
42
+ scripts/profile.sh
43
+ scripts/profiling.rb
44
+ test/helper.rb
45
+ test/test_address.rb
46
+ test/test_array_utils.rb
47
+ test/test_company.rb
48
+ test/test_faker.rb
49
+ test/test_faker_internet.rb
50
+ test/test_faker_name.rb
51
+ test/test_geolocation.rb
52
+ test/test_lorem.rb
53
+ test/test_module_utils.rb
54
+ test/test_phone_number.rb
55
+ ]
56
+ # = MANIFEST =
76
57
 
77
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
78
- else
79
- end
80
- else
81
- end
58
+ s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
82
59
  end
83
-
@@ -1,4 +1,6 @@
1
1
  module Faker
2
+ VERSION = "1.0.0"
3
+
2
4
  require 'ffaker/utils/module_utils'
3
5
 
4
6
  extend ModuleUtils
@@ -54,6 +54,10 @@ class TestAddress < Test::Unit::TestCase
54
54
  assert_match /[0-9]/, Faker::Address.zip_code
55
55
  end
56
56
 
57
+ def test_zip_code_frozen
58
+ assert Faker::Address.zip_code.frozen? == false
59
+ end
60
+
57
61
  def test_neighborhood
58
62
  assert_match /[ a-z]+/, Faker::Address::neighborhood
59
63
  end
@@ -9,6 +9,10 @@ class TestFakerInternet < Test::Unit::TestCase
9
9
  assert @tester.email.match(/.+@.+\.\w+/)
10
10
  end
11
11
 
12
+ def test_email_frozen
13
+ assert @tester.email.frozen? == false
14
+ end
15
+
12
16
  def test_free_email
13
17
  assert @tester.free_email.match(/.+@(gmail|hotmail|yahoo)\.com/)
14
18
  end
metadata CHANGED
@@ -1,42 +1,38 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffaker
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease: false
5
6
  segments:
7
+ - 1
6
8
  - 0
7
- - 4
8
9
  - 0
9
- version: 0.4.0
10
+ version: 1.0.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Emmanuel Oga
13
- - James Rosen
14
- - Rafael Souza
15
14
  autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2010-05-10 00:00:00 -03:00
18
+ date: 2010-11-04 00:00:00 -03:00
20
19
  default_executable:
21
20
  dependencies: []
22
21
 
23
- description: Faker refactored
22
+ description: Faster Faker, generates dummy data.
24
23
  email: EmmanuelOga@gmail.com
25
24
  executables: []
26
25
 
27
26
  extensions: []
28
27
 
29
28
  extra_rdoc_files:
30
- - LICENSE
31
29
  - README.rdoc
30
+ - LICENSE
32
31
  files:
33
- - .document
34
- - .gitignore
35
32
  - History.txt
36
33
  - LICENSE
37
34
  - README.rdoc
38
35
  - Rakefile
39
- - VERSION
40
36
  - ffaker.gemspec
41
37
  - lib/ffaker.rb
42
38
  - lib/ffaker/address.rb
@@ -48,7 +44,6 @@ files:
48
44
  - lib/ffaker/phone_number.rb
49
45
  - lib/ffaker/utils/array_utils.rb
50
46
  - lib/ffaker/utils/module_utils.rb
51
- - lib/ffaker/version.rb
52
47
  - scripts/benchmark.rb
53
48
  - scripts/profile.sh
54
49
  - scripts/profiling.rb
@@ -64,7 +59,7 @@ files:
64
59
  - test/test_module_utils.rb
65
60
  - test/test_phone_number.rb
66
61
  has_rdoc: true
67
- homepage: http://github.com/EmmanuelOga/ffaker
62
+ homepage: http://github.com/emmanueloga/ffaker
68
63
  licenses: []
69
64
 
70
65
  post_install_message:
@@ -73,35 +68,38 @@ rdoc_options:
73
68
  require_paths:
74
69
  - lib
75
70
  required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
76
72
  requirements:
77
73
  - - ">="
78
74
  - !ruby/object:Gem::Version
75
+ hash: 3
79
76
  segments:
80
77
  - 0
81
78
  version: "0"
82
79
  required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
83
81
  requirements:
84
82
  - - ">="
85
83
  - !ruby/object:Gem::Version
84
+ hash: 3
86
85
  segments:
87
86
  - 0
88
87
  version: "0"
89
88
  requirements: []
90
89
 
91
- rubyforge_project:
92
- rubygems_version: 1.3.6
90
+ rubyforge_project: ffaker
91
+ rubygems_version: 1.3.7
93
92
  signing_key:
94
- specification_version: 3
95
- summary: Faker, only cleaner and faster
93
+ specification_version: 2
94
+ summary: Faster Faker, generates dummy data.
96
95
  test_files:
97
- - test/test_faker_name.rb
98
- - test/test_lorem.rb
99
- - test/test_phone_number.rb
100
- - test/test_array_utils.rb
101
- - test/test_geolocation.rb
102
96
  - test/test_address.rb
103
- - test/test_faker_internet.rb
97
+ - test/test_array_utils.rb
98
+ - test/test_company.rb
104
99
  - test/test_faker.rb
100
+ - test/test_faker_internet.rb
101
+ - test/test_faker_name.rb
102
+ - test/test_geolocation.rb
103
+ - test/test_lorem.rb
105
104
  - test/test_module_utils.rb
106
- - test/helper.rb
107
- - test/test_company.rb
105
+ - test/test_phone_number.rb
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.4.0
@@ -1,9 +0,0 @@
1
- module Faker #:nodoc:
2
- module VERSION #:nodoc:
3
- MAJOR = 0
4
- MINOR = 4
5
- TINY = 0
6
-
7
- STRING = [MAJOR, MINOR, TINY].join('.')
8
- end
9
- end