journeyman 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/README.md +8 -7
- data/lib/journeyman.rb +11 -2
- data/lib/journeyman/builder.rb +1 -0
- data/lib/journeyman/missing_factory_error.rb +4 -0
- data/lib/journeyman/version.rb +4 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80e6b19998e4c462744824ae4e1e7a4200ed7d91
|
4
|
+
data.tar.gz: 1ec090c64d2903e2d893ed40e2120f3ba5e61286
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38102932e520f7b84d41c580ace722799a23cb40d64a982be5d8c3b70e8d65903e5fc59d205ed33ce80363cca3b1e78387a7f71ce9a4170b79e17da9384e9711
|
7
|
+
data.tar.gz: 8dc8d9b34e8f1b9724c5326131e47a127df66b61a148a5f47e06f4b99363b548930d8d0fac0d795f1ec1be5b9817f21d823479675f257421eb82378ef8e5e935
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
Journeyman
|
1
|
+
Journeyman
|
2
2
|
=====================
|
3
|
+
[](http://badge.fury.io/rb/journeyman) [](https://codeclimate.com/github/ElMassimo/journeyman) [](https://codeclimate.com/github/ElMassimo/journeyman) [](http://inch-ci.org/github/ElMassimo/journeyman) [](https://travis-ci.org/ElMassimo/journeyman) [](https://github.com/ElMassimo/journeyman/blob/master/LICENSE.txt)
|
3
4
|
|
4
5
|
Journeyman is a fixtures replacement with an extremely light definition syntax,
|
5
6
|
providing two default build strategies, but allowing full customization on how
|
@@ -22,7 +23,7 @@ Journeyman allows you to provide the default attributes for creation as the
|
|
22
23
|
return value of the definition block.
|
23
24
|
|
24
25
|
```ruby
|
25
|
-
Journeyman.define :album do |
|
26
|
+
Journeyman.define :album do |t|
|
26
27
|
{
|
27
28
|
title: 'Wish You Were Here',
|
28
29
|
recorded_ago: -> { (Date.today - Date.new(1975, 9, 12)).round / 365 },
|
@@ -77,16 +78,16 @@ ignore.
|
|
77
78
|
attributes. Specially useful when combined with ignore.
|
78
79
|
|
79
80
|
```ruby
|
80
|
-
Journeyman.define :employee do
|
81
|
-
find { |id| Person.find(id) }
|
81
|
+
Journeyman.define :employee do |c|
|
82
|
+
c.find { |id| Person.find(id) }
|
82
83
|
|
83
|
-
build { |attrs|
|
84
|
+
c.build { |attrs|
|
84
85
|
attrs.delete(:company).new_employee(attrs)
|
85
86
|
}
|
86
87
|
|
87
|
-
ignore :work_history
|
88
|
+
c.ignore :work_history
|
88
89
|
|
89
|
-
after_create { |employee, attrs|
|
90
|
+
c.after_create { |employee, attrs|
|
90
91
|
attrs[:work_history].each do |history|
|
91
92
|
check_references(history)
|
92
93
|
end
|
data/lib/journeyman.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'journeyman/load'
|
2
2
|
require 'journeyman/integration'
|
3
3
|
require 'journeyman/definition'
|
4
|
+
require 'journeyman/missing_factory_error'
|
4
5
|
|
5
6
|
# Public: Allows to define and use factory methods. It is capable of providing
|
6
7
|
# `build`, `create`, `find`, and `default` methods, the last two are optional.
|
@@ -39,12 +40,20 @@ module Journeyman
|
|
39
40
|
|
40
41
|
# Public: Convenience accessor for build methods.
|
41
42
|
def self.build(name, *args, &block)
|
42
|
-
@context.
|
43
|
+
if @context.respond_to?("build_#{name}")
|
44
|
+
@context.send("build_#{name}", *args, &block)
|
45
|
+
else
|
46
|
+
raise MissingFactoryError, "'#{name}' factory is not defined"
|
47
|
+
end
|
43
48
|
end
|
44
49
|
|
45
50
|
# Public: Convenience accessor for create methods.
|
46
51
|
def self.create(name, *args, &block)
|
47
|
-
@context.
|
52
|
+
if @context.respond_to?("create_#{name}")
|
53
|
+
@context.send("create_#{name}", *args, &block)
|
54
|
+
else
|
55
|
+
raise MissingFactoryError, "'#{name}' factory is not defined"
|
56
|
+
end
|
48
57
|
end
|
49
58
|
|
50
59
|
# Public: Convenience accessor for default methods.
|
data/lib/journeyman/builder.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: journeyman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Máximo Mussini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Journeyman allows you to define factories with custom build methods,
|
14
14
|
allowing you to easily bend object creation to the nuances of your application and
|
@@ -27,6 +27,8 @@ files:
|
|
27
27
|
- lib/journeyman/definition.rb
|
28
28
|
- lib/journeyman/integration.rb
|
29
29
|
- lib/journeyman/load.rb
|
30
|
+
- lib/journeyman/missing_factory_error.rb
|
31
|
+
- lib/journeyman/version.rb
|
30
32
|
homepage: https://github.com/ElMassimo/journeyman
|
31
33
|
licenses:
|
32
34
|
- MIT
|
@@ -40,7 +42,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
40
42
|
requirements:
|
41
43
|
- - ">="
|
42
44
|
- !ruby/object:Gem::Version
|
43
|
-
version: 1.
|
45
|
+
version: 2.1.0
|
44
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
47
|
requirements:
|
46
48
|
- - ">="
|
@@ -48,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
50
|
version: '0'
|
49
51
|
requirements: []
|
50
52
|
rubyforge_project:
|
51
|
-
rubygems_version: 2.
|
53
|
+
rubygems_version: 2.4.8
|
52
54
|
signing_key:
|
53
55
|
specification_version: 4
|
54
56
|
summary: Let your factories use your business logic, keeping them flexible and making
|