dm-sweatshop 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008 Ben Burkert
1
+ Copyright (c) 2009 Ben Burkert
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -6,7 +6,7 @@ dm-sweatshop is a model factory for DataMapper. It makes it easy & painless to
6
6
 
7
7
  * Easy generation of random models with data that fits the application domain.
8
8
  * Simple syntax for declaring and generating model patterns.
9
- * Add context to model patterns, allowing grouping and
9
+ * Add context to model patterns, allowing grouping and
10
10
  * Effortlessly generate or fill in associations for creating complex models with few lines of code.
11
11
 
12
12
  == How it works
@@ -56,13 +56,13 @@ A fixture for the user model can be defined using the @fixture@ method.
56
56
  :email => "#{username}@example.com",
57
57
  :password => (password = /\w+/.gen),
58
58
  :pasword_confirmation => password
59
-
59
+
60
60
  # The /\w+/.gen notation is part of the randexp gem:
61
61
  # http://github.com/benburkert/randexp/
62
62
  }}
63
63
 
64
64
  Notice the double curly brace (@{{@), a quick little way to pass a block that returns a hash to the fixture method. This is important because it ensures the data is random when we generate a new instance of the model, by calling the block every time.
65
-
65
+
66
66
  Code snippet above stores a Proc that returns attributes hash in model map for
67
67
  class User. Since you did not explicitly specify fixture name, default name is
68
68
  used (99+% of the cases it is :default).
@@ -105,10 +105,10 @@ Now to a model that has given attributes, use
105
105
  The real power of sweatshop is generating working associations.
106
106
 
107
107
  DataMapper.setup(:default, "sqlite3::memory:")
108
-
108
+
109
109
  class Tweet
110
110
  include DataMapper::Resource
111
-
111
+
112
112
  property :id, Serial
113
113
  property :message, String, :length => 140
114
114
  property :user_id, Integer
@@ -116,7 +116,7 @@ The real power of sweatshop is generating working associations.
116
116
  belongs_to :user
117
117
  has n, :tags, :through => Resource
118
118
  end
119
-
119
+
120
120
  class Tag
121
121
  include DataMapper::Resource
122
122
 
@@ -125,13 +125,13 @@ The real power of sweatshop is generating working associations.
125
125
 
126
126
  has n, :tweets, :through => Resource
127
127
  end
128
-
128
+
129
129
  class User
130
130
  include DataMapper::Resource
131
-
131
+
132
132
  property :id, Serial
133
133
  property :username, String
134
-
134
+
135
135
  has n, :tweets
136
136
  end
137
137
 
@@ -141,7 +141,7 @@ The real power of sweatshop is generating working associations.
141
141
  :username => /\w+/.gen,
142
142
  :tweets => 500.of {Tweet.make}
143
143
  }}
144
-
144
+
145
145
  Tweet.fix {{
146
146
  :message => /[:sentence:]/.gen[0..140],
147
147
  :tags => (0..10).of {Tag.make}
@@ -150,7 +150,7 @@ The real power of sweatshop is generating working associations.
150
150
  Tag.fix {{
151
151
  :name => /\w+/.gen
152
152
  }}
153
-
153
+
154
154
  # now lets generate 100 users, each with 500 tweets. Also, the tweet's have 0 to 10 tags!
155
155
  users = 10.of {User.gen}
156
156
 
@@ -161,18 +161,18 @@ That's going to generate alot of tags, way more than you would see in the produc
161
161
  :username => /\w+/.gen,
162
162
  :tweets => 500.of {Tweet.make}
163
163
  }}
164
-
164
+
165
165
  Tweet.fix {{
166
166
  :message => /[:sentence:]/.gen[0..140],
167
167
  :tags => (0..10).of {Tag.pick} #lets pick, not make this time
168
168
  }}
169
-
169
+
170
170
  Tag.fix {{
171
171
  :name => /\w+/.gen
172
172
  }}
173
-
173
+
174
174
  50.times {Tag.gen}
175
-
175
+
176
176
  users = 10.of {User.gen}
177
177
 
178
178
 
@@ -192,7 +192,7 @@ To keep track of all of our new fixtures, we can even give them a context.
192
192
  :message => /\@#{User.pick.name} [:sentence:]/.gen[0..140],
193
193
  :tags => (0..10).of {Tag.pick}
194
194
  }}
195
-
195
+
196
196
  Tweet.fix(:conversation) {{
197
197
  :message => /\@#{(tweet = Tweet.pick(:at_reply)).user.name} [:sentence:]/.gen[0..140],
198
198
  :tags => tweet.tags
data/Rakefile CHANGED
@@ -1,24 +1,30 @@
1
- require 'pathname'
1
+ require 'rubygems'
2
+ require 'rake'
2
3
 
3
- ROOT = Pathname(__FILE__).dirname.expand_path
4
- JRUBY = RUBY_PLATFORM =~ /java/
5
- WINDOWS = Gem.win_platform?
6
- SUDO = (WINDOWS || JRUBY) ? '' : ('sudo' unless ENV['SUDOLESS'])
4
+ begin
5
+ gem 'jeweler', '~> 1.4'
6
+ require 'jeweler'
7
7
 
8
- require ROOT + 'lib/dm-sweatshop/version'
8
+ Jeweler::Tasks.new do |gem|
9
+ gem.name = 'dm-sweatshop'
10
+ gem.summary = 'DataMapper plugin for building pseudo random models'
11
+ gem.description = gem.summary
12
+ gem.email = 'ben [a] benburkert [d] com'
13
+ gem.homepage = 'http://github.com/datamapper/dm-more/tree/master/%s' % gem.name
14
+ gem.authors = [ 'Ben Burkert' ]
9
15
 
10
- AUTHOR = 'Ben Burkert'
11
- EMAIL = 'ben [a] benburkert [d] com'
12
- GEM_NAME = 'dm-sweatshop'
13
- GEM_VERSION = DataMapper::Sweatshop::VERSION
14
- GEM_DEPENDENCIES = [['dm-core', GEM_VERSION], ['randexp', '~>0.1.4']]
15
- GEM_CLEAN = %w[ log pkg coverage ]
16
- GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.rdoc LICENSE TODO History.rdoc ] }
16
+ gem.rubyforge_project = 'datamapper'
17
17
 
18
- PROJECT_NAME = 'datamapper'
19
- PROJECT_URL = "http://github.com/datamapper/dm-more/tree/master/#{GEM_NAME}"
20
- PROJECT_DESCRIPTION = PROJECT_SUMMARY = 'DataMapper plugin for building pseudo random models'
18
+ gem.add_dependency 'dm-core', '~> 0.10.2'
19
+ gem.add_dependency 'randexp', '~> 0.1.4'
21
20
 
22
- [ ROOT, ROOT.parent ].each do |dir|
23
- Pathname.glob(dir.join('tasks/**/*.rb').to_s).each { |f| require f }
21
+ gem.add_development_dependency 'rspec', '~> 1.2.9'
22
+ gem.add_development_dependency 'yard', '~> 0.4.0'
23
+ end
24
+
25
+ Jeweler::GemcutterTasks.new
26
+
27
+ FileList['tasks/**/*.rake'].each { |task| import task }
28
+ rescue LoadError
29
+ puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
24
30
  end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.10.2
@@ -0,0 +1,70 @@
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
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{dm-sweatshop}
8
+ s.version = "0.10.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ben Burkert"]
12
+ s.date = %q{2009-12-11}
13
+ s.description = %q{DataMapper plugin for building pseudo random models}
14
+ s.email = %q{ben [a] benburkert [d] com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ "LICENSE",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "dm-sweatshop.gemspec",
25
+ "lib/dm-sweatshop.rb",
26
+ "lib/dm-sweatshop/model.rb",
27
+ "lib/dm-sweatshop/sweatshop.rb",
28
+ "lib/dm-sweatshop/unique.rb",
29
+ "spec/dm-sweatshop/model_spec.rb",
30
+ "spec/dm-sweatshop/sweatshop_spec.rb",
31
+ "spec/dm-sweatshop/unique_spec.rb",
32
+ "spec/rcov.opts",
33
+ "spec/spec.opts",
34
+ "spec/spec_helper.rb",
35
+ "tasks/ci.rake",
36
+ "tasks/metrics.rake",
37
+ "tasks/spec.rake",
38
+ "tasks/yard.rake",
39
+ "tasks/yardstick.rake"
40
+ ]
41
+ s.homepage = %q{http://github.com/datamapper/dm-more/tree/master/dm-sweatshop}
42
+ s.rdoc_options = ["--charset=UTF-8"]
43
+ s.require_paths = ["lib"]
44
+ s.rubyforge_project = %q{datamapper}
45
+ s.rubygems_version = %q{1.3.5}
46
+ s.summary = %q{DataMapper plugin for building pseudo random models}
47
+
48
+ if s.respond_to? :specification_version then
49
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
50
+ s.specification_version = 3
51
+
52
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
53
+ s.add_runtime_dependency(%q<dm-core>, ["~> 0.10.2"])
54
+ s.add_runtime_dependency(%q<randexp>, ["~> 0.1.4"])
55
+ s.add_development_dependency(%q<rspec>, ["~> 1.2.9"])
56
+ s.add_development_dependency(%q<yard>, ["~> 0.4.0"])
57
+ else
58
+ s.add_dependency(%q<dm-core>, ["~> 0.10.2"])
59
+ s.add_dependency(%q<randexp>, ["~> 0.1.4"])
60
+ s.add_dependency(%q<rspec>, ["~> 1.2.9"])
61
+ s.add_dependency(%q<yard>, ["~> 0.4.0"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<dm-core>, ["~> 0.10.2"])
65
+ s.add_dependency(%q<randexp>, ["~> 0.1.4"])
66
+ s.add_dependency(%q<rspec>, ["~> 1.2.9"])
67
+ s.add_dependency(%q<yard>, ["~> 0.4.0"])
68
+ end
69
+ end
70
+
@@ -9,7 +9,7 @@ describe DataMapper::Model do
9
9
  property :name, String
10
10
  property :price, Integer
11
11
 
12
- belongs_to :order, :nullable => true
12
+ belongs_to :order, :required => false
13
13
  validates_present :price
14
14
  end
15
15
 
@@ -0,0 +1,6 @@
1
+ --exclude "spec"
2
+ --sort coverage
3
+ --callsites
4
+ --xrefs
5
+ --profile
6
+ --text-summary
@@ -1,2 +1,4 @@
1
1
  --colour
2
2
  --loadby random
3
+ --format profile
4
+ --backtrace
@@ -0,0 +1 @@
1
+ task :ci => [ :verify_measurements, 'metrics:all' ]
@@ -0,0 +1,36 @@
1
+ begin
2
+ require 'metric_fu'
3
+ rescue LoadError
4
+ namespace :metrics do
5
+ task :all do
6
+ abort 'metric_fu is not available. In order to run metrics:all, you must: gem install metric_fu'
7
+ end
8
+ end
9
+ end
10
+
11
+ begin
12
+ require 'reek/adapters/rake_task'
13
+
14
+ Reek::RakeTask.new do |t|
15
+ t.fail_on_error = true
16
+ t.verbose = false
17
+ t.source_files = 'lib/**/*.rb'
18
+ end
19
+ rescue LoadError
20
+ task :reek do
21
+ abort 'Reek is not available. In order to run reek, you must: gem install reek'
22
+ end
23
+ end
24
+
25
+ begin
26
+ require 'roodi'
27
+ require 'roodi_task'
28
+
29
+ RoodiTask.new do |t|
30
+ t.verbose = false
31
+ end
32
+ rescue LoadError
33
+ task :roodi do
34
+ abort 'Roodi is not available. In order to run roodi, you must: gem install roodi'
35
+ end
36
+ end
@@ -0,0 +1,41 @@
1
+ spec_defaults = lambda do |spec|
2
+ spec.pattern = 'spec/**/*_spec.rb'
3
+ spec.libs << 'lib' << 'spec'
4
+ spec.spec_opts << '--options' << 'spec/spec.opts'
5
+ end
6
+
7
+ begin
8
+ require 'spec/rake/spectask'
9
+
10
+ Spec::Rake::SpecTask.new(:spec, &spec_defaults)
11
+ rescue LoadError
12
+ task :spec do
13
+ abort 'rspec is not available. In order to run spec, you must: gem install rspec'
14
+ end
15
+ end
16
+
17
+ begin
18
+ require 'rcov'
19
+ require 'spec/rake/verify_rcov'
20
+
21
+ Spec::Rake::SpecTask.new(:rcov) do |rcov|
22
+ spec_defaults.call(rcov)
23
+ rcov.rcov = true
24
+ rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/)
25
+ end
26
+
27
+ RCov::VerifyTask.new(:verify_rcov => :rcov) do |rcov|
28
+ rcov.threshold = 100
29
+ end
30
+ rescue LoadError
31
+ %w[ rcov verify_rcov ].each do |name|
32
+ task name do
33
+ abort "rcov is not available. In order to run #{name}, you must: gem install rcov"
34
+ end
35
+ end
36
+ end
37
+
38
+ task :spec => :check_dependencies
39
+ task :rcov => :check_dependencies
40
+
41
+ task :default => :spec
@@ -0,0 +1,9 @@
1
+ begin
2
+ require 'yard'
3
+
4
+ YARD::Rake::YardocTask.new
5
+ rescue LoadError
6
+ task :yard do
7
+ abort 'YARD is not available. In order to run yard, you must: gem install yard'
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ begin
2
+ require 'pathname'
3
+ require 'yardstick/rake/measurement'
4
+ require 'yardstick/rake/verify'
5
+
6
+ # yardstick_measure task
7
+ Yardstick::Rake::Measurement.new
8
+
9
+ # verify_measurements task
10
+ Yardstick::Rake::Verify.new do |verify|
11
+ verify.threshold = 100
12
+ end
13
+ rescue LoadError
14
+ %w[ yardstick_measure verify_measurements ].each do |name|
15
+ task name.to_s do
16
+ abort "Yardstick is not available. In order to run #{name}, you must: gem install yardstick"
17
+ end
18
+ end
19
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-sweatshop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Burkert
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-30 00:00:00 -07:00
12
+ date: 2009-12-11 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -18,9 +18,9 @@ dependencies:
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - "="
21
+ - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: 0.10.1
23
+ version: 0.10.2
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: randexp
@@ -32,45 +32,63 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.1.4
34
34
  version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: rspec
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.2.9
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: yard
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.4.0
54
+ version:
35
55
  description: DataMapper plugin for building pseudo random models
36
- email:
37
- - ben [a] benburkert [d] com
56
+ email: ben [a] benburkert [d] com
38
57
  executables: []
39
58
 
40
59
  extensions: []
41
60
 
42
61
  extra_rdoc_files:
43
- - README.rdoc
44
62
  - LICENSE
45
- - TODO
46
- - History.rdoc
63
+ - README.rdoc
47
64
  files:
48
- - History.rdoc
49
65
  - LICENSE
50
- - Manifest.txt
51
66
  - README.rdoc
52
67
  - Rakefile
53
- - TODO
68
+ - VERSION
69
+ - dm-sweatshop.gemspec
54
70
  - lib/dm-sweatshop.rb
55
71
  - lib/dm-sweatshop/model.rb
56
72
  - lib/dm-sweatshop/sweatshop.rb
57
73
  - lib/dm-sweatshop/unique.rb
58
- - lib/dm-sweatshop/version.rb
59
74
  - spec/dm-sweatshop/model_spec.rb
60
75
  - spec/dm-sweatshop/sweatshop_spec.rb
61
76
  - spec/dm-sweatshop/unique_spec.rb
77
+ - spec/rcov.opts
62
78
  - spec/spec.opts
63
79
  - spec/spec_helper.rb
64
- - tasks/install.rb
65
- - tasks/spec.rb
80
+ - tasks/ci.rake
81
+ - tasks/metrics.rake
82
+ - tasks/spec.rake
83
+ - tasks/yard.rake
84
+ - tasks/yardstick.rake
66
85
  has_rdoc: true
67
86
  homepage: http://github.com/datamapper/dm-more/tree/master/dm-sweatshop
68
87
  licenses: []
69
88
 
70
89
  post_install_message:
71
90
  rdoc_options:
72
- - --main
73
- - README.rdoc
91
+ - --charset=UTF-8
74
92
  require_paths:
75
93
  - lib
76
94
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -1,42 +0,0 @@
1
- === 0.10.1 / 2009-09-30
2
-
3
- * No changes this version
4
-
5
- === 0.10.0 / 2009-09-15
6
-
7
- * Updated to work with dm-core 0.10.0
8
-
9
- === 0.9.11 / 2009-03-29
10
-
11
- * No changes this version
12
-
13
- === 0.9.10 / 2009-01-19
14
-
15
- * No changes this version
16
-
17
- === 0.9.9 / 2009-01-04
18
-
19
- * 1 minor enhancement:
20
-
21
- * Added #generate! method to create invalid fixture
22
-
23
- * 1 bug fix:
24
-
25
- * Updated spec to use local dm-validations if possible
26
-
27
- === 0.9.8 / 2008-12-07
28
-
29
- * 1 minor enhancement:
30
-
31
- * callable values now automatically expanded
32
-
33
- * 1 bug fix:
34
-
35
- * Now requiring with gem() calls and tested versions
36
-
37
- === 0.9.7 / 2008-11-18
38
-
39
- * 2 major enhancements:
40
-
41
- * Reworked unique model generator.
42
- * Improved documentation.
@@ -1,18 +0,0 @@
1
- History.rdoc
2
- LICENSE
3
- Manifest.txt
4
- README.rdoc
5
- Rakefile
6
- TODO
7
- lib/dm-sweatshop.rb
8
- lib/dm-sweatshop/model.rb
9
- lib/dm-sweatshop/sweatshop.rb
10
- lib/dm-sweatshop/unique.rb
11
- lib/dm-sweatshop/version.rb
12
- spec/dm-sweatshop/model_spec.rb
13
- spec/dm-sweatshop/sweatshop_spec.rb
14
- spec/dm-sweatshop/unique_spec.rb
15
- spec/spec.opts
16
- spec/spec_helper.rb
17
- tasks/install.rb
18
- tasks/spec.rb
data/TODO DELETED
File without changes
@@ -1,5 +0,0 @@
1
- module DataMapper
2
- class Sweatshop
3
- VERSION = '0.10.1'.freeze
4
- end
5
- end
@@ -1,13 +0,0 @@
1
- def sudo_gem(cmd)
2
- sh "#{SUDO} #{RUBY} -S gem #{cmd}", :verbose => false
3
- end
4
-
5
- desc "Install #{GEM_NAME} #{GEM_VERSION}"
6
- task :install => [ :package ] do
7
- sudo_gem "install pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources"
8
- end
9
-
10
- desc "Uninstall #{GEM_NAME} #{GEM_VERSION}"
11
- task :uninstall => [ :clobber ] do
12
- sudo_gem "uninstall #{GEM_NAME} -v#{GEM_VERSION} -Ix"
13
- end
@@ -1,25 +0,0 @@
1
- begin
2
- require 'spec/rake/spectask'
3
-
4
- task :default => [ :spec ]
5
-
6
- desc 'Run specifications'
7
- Spec::Rake::SpecTask.new(:spec) do |t|
8
- t.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
9
- t.libs << 'lib' << 'spec' # needed for CI rake spec task, duplicated in spec_helper
10
-
11
- begin
12
- require 'rcov'
13
- t.rcov = JRUBY ? false : (ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true)
14
- t.rcov_opts << '--exclude' << 'spec'
15
- t.rcov_opts << '--text-summary'
16
- t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
17
- rescue LoadError
18
- # rcov not installed
19
- rescue SyntaxError
20
- # rcov syntax invalid
21
- end
22
- end
23
- rescue LoadError
24
- # rspec not installed
25
- end