scheherazade 0.0.9 → 0.1.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.
@@ -9,7 +9,7 @@ module Scheherazade
|
|
9
9
|
@chain.unshift c
|
10
10
|
end
|
11
11
|
@model = Story.to_model(@chain.first)
|
12
|
-
story.send
|
12
|
+
story.send :building, @ar = @model.new
|
13
13
|
@chain.each{|c| story.current[c] = @ar }
|
14
14
|
end
|
15
15
|
|
@@ -27,6 +27,7 @@ module Scheherazade
|
|
27
27
|
def build(attribute_list = nil)
|
28
28
|
@seq = (story.counter[@model] += 1)
|
29
29
|
lists = [required_attributes, *default_attribute_lists, attribute_list]
|
30
|
+
lists.prepend [:created_at] if @ar.has_attribute?(:created_at)
|
30
31
|
attribute_list = lists.map{|al| canonical(al)}.inject(:merge)
|
31
32
|
log(:building, attribute_list)
|
32
33
|
set_attributes(attribute_list)
|
@@ -111,8 +112,8 @@ module Scheherazade
|
|
111
112
|
when :integer then @seq
|
112
113
|
when :float then @seq
|
113
114
|
when :decimal then "#{@seq}.99"
|
114
|
-
when :datetime then Time.now
|
115
|
-
when :date then Date.today
|
115
|
+
when :datetime then Time.now - 1.day + @seq
|
116
|
+
when :date then Date.today - 1.year + @seq
|
116
117
|
when :string then
|
117
118
|
case attribute
|
118
119
|
when :email
|
@@ -144,7 +145,7 @@ module Scheherazade
|
|
144
145
|
when nil then {}
|
145
146
|
when Hash then attribute_list
|
146
147
|
when Array
|
147
|
-
attribute_list.map
|
148
|
+
attribute_list.map do |attributes|
|
148
149
|
case attributes
|
149
150
|
when Symbol
|
150
151
|
{attributes => AUTO}
|
@@ -154,7 +155,7 @@ module Scheherazade
|
|
154
155
|
raise "Unexpected attributes #{attributes}"
|
155
156
|
end
|
156
157
|
end
|
157
|
-
|
158
|
+
.inject({}, :merge)
|
158
159
|
else
|
159
160
|
raise "Unexpected attribute_list #{attribute_list}"
|
160
161
|
end
|
data/lib/scheherazade/story.rb
CHANGED
@@ -181,8 +181,8 @@ module Scheherazade
|
|
181
181
|
@built.each(&:destroy)
|
182
182
|
end
|
183
183
|
|
184
|
-
|
185
|
-
|
186
|
-
|
184
|
+
def building(ar)
|
185
|
+
@building << ar if @building # Condition needed in case we use CharacterBuilder outside of call to `imagine`
|
186
|
+
end
|
187
187
|
end
|
188
188
|
end
|
data/lib/scheherazade/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scheherazade
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -91,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
91
|
version: '0'
|
92
92
|
segments:
|
93
93
|
- 0
|
94
|
-
hash:
|
94
|
+
hash: 2331600059561674331
|
95
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
96
|
none: false
|
97
97
|
requirements:
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
segments:
|
102
102
|
- 0
|
103
|
-
hash:
|
103
|
+
hash: 2331600059561674331
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project:
|
106
106
|
rubygems_version: 1.8.24
|