Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

doc fixes / updates

  • Loading branch information...
commit 784e398d051a17c08b7f20c6b63ccea6a28d499a 1 parent 154a5d0
@timcharper timcharper authored
View
2  .gitignore
@@ -1 +1,3 @@
/doc
+/html
+*.gem
View
2  Gemfile.lock
@@ -12,6 +12,7 @@ GEM
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
rake (0.9.2)
+ rdoc (3.8)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
@@ -36,6 +37,7 @@ PLATFORMS
DEPENDENCIES
rake
+ rdoc (= 3.8)
rspec (~> 2.6)
ruby-debug19
workbench!
View
9 README.rdoc
@@ -31,9 +31,9 @@ system getting in the way by following a few conventions that should
cover most use cases, while keeping it robust by getting out of the
way.
-Workbench is less than 70 lines, and every line counts. Moderately
-experienced rubyists should have no trouble understanding the code,
-and there is not that much to parse.
+Workbench is less than 70 lines (excluding documentation), and every
+line counts. Moderately experienced rubyists should have no trouble
+understanding the code, and there is not that much to parse.
= Usage
@@ -116,7 +116,8 @@ include it in their global test config or RSpec config (like so):
See:
* Workbench
-* Workbench#sequence
+* Workbench#use_class
+* Workbench#count_with
= Counters
View
7 Rakefile
@@ -1,10 +1,17 @@
require "bundler"
Bundler.setup
require "rspec/core/rake_task"
+require 'rdoc/task'
desc "Run all examples"
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = %w[--color]
end
+RDoc::Task.new do |rd|
+ rd.main = "README.rdoc"
+ rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
+ rd.options << "--all"
+end
+
task :default => :spec
View
51 lib/workbench.rb
@@ -3,32 +3,51 @@ module Workbench
COUNTERS = Hash.new(0)
# Declare that the next builder method is to use the said class
- # (Symbol such as :User or string such as "Models::User" are
- # acceptable)
+ #
+ # module Builders
+ # extend Workbench
+ #
+ # def user_defaults(u)
+ # ...
+ # end
+ #
+ # use_class :User
+ # def admin_user_defaults(u)
+ # ...
+ # end
+ # end
+ #
+ # === Parameters:
+ #
+ # name:: - Symbol such as :User or string such as "Models::User" are
+ # acceptable
def use_class(name)
@next_class = name
end
- # Declare that the next builder method is to count scoped to the following class,
+ # Declare that the next builder method is to count scoped to the following class
#
- # module Builders
- # extend Workbench
+ # module Builders
+ # extend Workbench
#
- # def book_defaults(u, n)
- # ...
- # end
+ # def book_defaults(u, n)
+ # ...
+ # end
#
- # count_with :Book
- # def article_defaults(u, n)
- # ...
+ # count_with :Book
+ # def article_defaults(u, n)
+ # ...
+ # end
# end
- # end
#
- # new_book # n = 1
- # new_publication # n = 2
- # new_book # n = 3
+ # new_book # n = 1
+ # new_publication # n = 2
+ # new_book # n = 3
+ #
+ # === Parameters:
#
- # expects a Symbol such as :User or string such as "Models::User" that maps to a valid class name.
+ # +name+:: - a Symbol (ie :User) or string (is "Models::User") that
+ # maps to a valid class name.
def count_with(name)
@next_count_with = name
end
View
20 workbench.gemspec
@@ -8,20 +8,13 @@ Gem::Specification.new do |s|
s.homepage = "http://github.com/leadtune/workbench"
s.summary = "A small, simple ORM agnostic factory library that does the job without any crazy tricks."
s.description = <<-EOF
-There are a lot of factory frameworks, why one more? In my experience
-the otherones use fancy DSLs that were intended to increase
-readability but instead increased confusion.
+Workbench strikes to reach a better balance between easy-to-read
+factory builders, ease of use, and robustness.
-Workbench doesn't use a fancy DSL. It uses ruby. It doesn't use any
-fancy tricks like providing proxy objects for modification, workbench
-builders operate on the actual model. Since it uses very little
-tricks, it is also ORM agnostic. If your models respond to '.new' and
-you set attributes by calling #attribute=, then Workbench will work
-with your model.
-
-I have a hard time understanding why all the complexity around factory
-builders has grown, but often I look at the resulting DSL and say
-"That's more work than just defining a method and calling Model.new!"
+Workbench doesn't use any fancy tricks. It's code is small and the
+average rubyist should have no trouble reading it. It exploits what
+ruby provides. Instead of operating on a proxy object, builders
+operate on the actual model. It's also ORM agnostic.
EOF
s.required_rubygems_version = ">= 1.3.6"
@@ -29,6 +22,7 @@ EOF
s.add_development_dependency "rspec", "~> 2.6"
s.add_development_dependency "ruby-debug19"
s.add_development_dependency "rake"
+ s.add_development_dependency "rdoc", "3.8"
s.files = Dir.glob("{spec,lib}/**/*") + %w(MIT_LICENSE README.rdoc Gemfile)
s.require_path = 'lib'
Please sign in to comment.
Something went wrong with that request. Please try again.