workbench 0.2 → 0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/README.rdoc +5 -4
  2. data/lib/workbench.rb +35 -16
  3. metadata +29 -14
@@ -31,9 +31,9 @@ system getting in the way by following a few conventions that should
31
31
  cover most use cases, while keeping it robust by getting out of the
32
32
  way.
33
33
 
34
- Workbench is less than 70 lines, and every line counts. Moderately
35
- experienced rubyists should have no trouble understanding the code,
36
- and there is not that much to parse.
34
+ Workbench is less than 70 lines (excluding documentation), and every
35
+ line counts. Moderately experienced rubyists should have no trouble
36
+ understanding the code, and there is not that much to parse.
37
37
 
38
38
  = Usage
39
39
 
@@ -116,7 +116,8 @@ include it in their global test config or RSpec config (like so):
116
116
  See:
117
117
 
118
118
  * Workbench
119
- * Workbench#sequence
119
+ * Workbench#use_class
120
+ * Workbench#count_with
120
121
 
121
122
  = Counters
122
123
 
@@ -3,32 +3,51 @@ module Workbench
3
3
  COUNTERS = Hash.new(0)
4
4
 
5
5
  # Declare that the next builder method is to use the said class
6
- # (Symbol such as :User or string such as "Models::User" are
7
- # acceptable)
6
+ #
7
+ # module Builders
8
+ # extend Workbench
9
+ #
10
+ # def user_defaults(u)
11
+ # ...
12
+ # end
13
+ #
14
+ # use_class :User
15
+ # def admin_user_defaults(u)
16
+ # ...
17
+ # end
18
+ # end
19
+ #
20
+ # === Parameters:
21
+ #
22
+ # name:: - Symbol such as :User or string such as "Models::User" are
23
+ # acceptable
8
24
  def use_class(name)
9
25
  @next_class = name
10
26
  end
11
27
 
12
- # Declare that the next builder method is to count scoped to the following class,
28
+ # Declare that the next builder method is to count scoped to the following class
13
29
  #
14
- # module Builders
15
- # extend Workbench
30
+ # module Builders
31
+ # extend Workbench
16
32
  #
17
- # def book_defaults(u, n)
18
- # ...
19
- # end
33
+ # def book_defaults(u, n)
34
+ # ...
35
+ # end
20
36
  #
21
- # count_with :Book
22
- # def article_defaults(u, n)
23
- # ...
37
+ # count_with :Book
38
+ # def article_defaults(u, n)
39
+ # ...
40
+ # end
24
41
  # end
25
- # end
26
42
  #
27
- # new_book # n = 1
28
- # new_publication # n = 2
29
- # new_book # n = 3
43
+ # new_book # n = 1
44
+ # new_publication # n = 2
45
+ # new_book # n = 3
46
+ #
47
+ # === Parameters:
30
48
  #
31
- # expects a Symbol such as :User or string such as "Models::User" that maps to a valid class name.
49
+ # +name+:: - a Symbol (ie :User) or string (is "Models::User") that
50
+ # maps to a valid class name.
32
51
  def count_with(name)
33
52
  @next_count_with = name
34
53
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: workbench
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: "0.2"
5
+ version: "0.3"
6
6
  platform: ruby
7
7
  authors:
8
8
  - Tim Harper
@@ -37,21 +37,36 @@ dependencies:
37
37
  version: "0"
38
38
  type: :development
39
39
  version_requirements: *id002
40
+ - !ruby/object:Gem::Dependency
41
+ name: rake
42
+ prerelease: false
43
+ requirement: &id003 !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ type: :development
50
+ version_requirements: *id003
51
+ - !ruby/object:Gem::Dependency
52
+ name: rdoc
53
+ prerelease: false
54
+ requirement: &id004 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - "="
58
+ - !ruby/object:Gem::Version
59
+ version: "3.8"
60
+ type: :development
61
+ version_requirements: *id004
40
62
  description: |
41
- There are a lot of factory frameworks, why one more? In my experience
42
- the otherones use fancy DSLs that were intended to increase
43
- readability but instead increased confusion.
44
-
45
- Workbench doesn't use a fancy DSL. It uses ruby. It doesn't use any
46
- fancy tricks like providing proxy objects for modification, workbench
47
- builders operate on the actual model. Since it uses very little
48
- tricks, it is also ORM agnostic. If your models respond to '.new' and
49
- you set attributes by calling #attribute=, then Workbench will work
50
- with your model.
63
+ Workbench strikes to reach a better balance between easy-to-read
64
+ factory builders, ease of use, and robustness.
51
65
 
52
- I have a hard time understanding why all the complexity around factory
53
- builders has grown, but often I look at the resulting DSL and say
54
- "That's more work than just defining a method and calling Model.new!"
66
+ Workbench doesn't use any fancy tricks. It's code is small and the
67
+ average rubyist should have no trouble reading it. It exploits what
68
+ ruby provides. Instead of operating on a proxy object, builders
69
+ operate on the actual model. It's also ORM agnostic.
55
70
 
56
71
  email:
57
72
  - tim@leadtune.com