fixturizer 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/fixturizer.gemspec +1 -1
- data/lib/fixturizer/adapters/mongoid.rb +5 -5
- data/lib/fixturizer/configuration.rb +6 -6
- data/lib/fixturizer/engines/models.rb +4 -2
- data/lib/fixturizer/rspec/helpers/database.rb +2 -2
- data/samples/Gemfile +1 -1
- data/samples/app.rb +12 -1
- data/samples/config/rules.yml +17 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cc92b66c50911ec30ffd277772939fb652d9b88e3dc33fa2b1cdbccb01aa776
|
4
|
+
data.tar.gz: 7cce30b3455b91e6e32fbdede70a1637e8b063f7b1bf3e02cce8e4e39d0bdbcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e213a056cc0d54acc95ef428a47125cc1a48a733e6065fc30a0bcee7b50c88c873b4eac799b3d9e4e4813439ba5cdc0f67c4396f33f46ac68e926451aa9ee13
|
7
|
+
data.tar.gz: 4ed4d832360555326fc93d16ef9c8413f506c250e39dfa7e56adf7cb65de20f1405812c6b3683ee00e5d4e2d937d1163c5de0cae13f276a60dd316d3e3eb454c
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.3
|
data/fixturizer.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
|
32
32
|
spec.add_dependency 'mongoid', '~> 9.0'
|
33
33
|
spec.add_dependency 'rake', '~> 13.0'
|
34
|
-
spec.add_dependency 'rspec', '~> 3.
|
34
|
+
spec.add_dependency 'rspec', '~> 3.13.0'
|
35
35
|
spec.add_dependency 'version', '~> 1.1'
|
36
36
|
|
37
37
|
spec.add_development_dependency 'bundle-audit', '~> 0.1.0'
|
@@ -8,12 +8,12 @@ module Fixturizer
|
|
8
8
|
list.each do |name|
|
9
9
|
records = @generated[name]
|
10
10
|
records.each do |record|
|
11
|
-
|
12
|
-
by = record.dig(:
|
13
|
-
pattern = record.dig(:
|
11
|
+
belong = record.dig(:belong,:to)
|
12
|
+
by = record.dig(:belong,:by)
|
13
|
+
pattern = record.dig(:belong,:search_by)
|
14
14
|
if link.is_a? Symbol then
|
15
|
-
model = Object.const_get(@models[
|
16
|
-
model.create!(record[:data]) unless model.where(@models[
|
15
|
+
model = Object.const_get(@models[belong][:class]).find_by(**pattern).send by
|
16
|
+
model.create!(record[:data]) unless model.where(@models[belong][:unicity] => record[:data][@models[belong][:unicity]]).exists?
|
17
17
|
else
|
18
18
|
model = Object.const_get(@models[name][:class])
|
19
19
|
model.create!(record[:data]) unless model.where(@models[name][:unicity] => record[:data][@models[name][:unicity]]).exists?
|
@@ -30,7 +30,7 @@ module Fixturizer
|
|
30
30
|
:dataset => [:definition, :rules],
|
31
31
|
:models => [:type, :order, :definitions],
|
32
32
|
:model_definition => [:rules,:class,:unicity, :collection],
|
33
|
-
:collection => [:attributes,:
|
33
|
+
:collection => [:attributes,:belong]
|
34
34
|
|
35
35
|
}
|
36
36
|
|
@@ -197,13 +197,13 @@ module Fixturizer
|
|
197
197
|
definitions.dig(:collection).each_with_index do |record,i|
|
198
198
|
@status[:error].push "//:fixtures/:models/:definitions/:#{name}/:collection[#{i}] not have key :attributes defined" unless record.include? :attributes
|
199
199
|
@status[:error].push "//:fixtures/:models/:definitions/:#{name}/:collection[#{i}]/:attributes is not a Hash" unless record[:attributes].is_a? Hash
|
200
|
-
if record.include? :
|
201
|
-
unless record[:
|
202
|
-
@status[:error].push "//:fixtures/:models/:definitions/:#{name}/:collection[#{i}]/:
|
200
|
+
if record.include? :belong
|
201
|
+
unless record[:belong].is_a? Hash then
|
202
|
+
@status[:error].push "//:fixtures/:models/:definitions/:#{name}/:collection[#{i}]/:belong is set but is not a Hash"
|
203
203
|
else
|
204
204
|
{to: Symbol, by: Symbol, search_by: Hash}.each do |verb,type|
|
205
|
-
@status[:error].push "//:fixtures/:models/:definitions/:#{name}/:collection[#{i}]/:
|
206
|
-
@status[:error].push "//:fixtures/:models/:definitions/:#{name}/:collection[#{i}]/:
|
205
|
+
@status[:error].push "//:fixtures/:models/:definitions/:#{name}/:collection[#{i}]/:belong not have key :#{verb} defined" unless record[:belong].include? verb
|
206
|
+
@status[:error].push "//:fixtures/:models/:definitions/:#{name}/:collection[#{i}]/:belong/:#{verb} is not a #{type}" unless record[:belong][verb].is_a? type
|
207
207
|
end
|
208
208
|
end
|
209
209
|
end
|
@@ -54,8 +54,10 @@ module Fixturizer
|
|
54
54
|
res = {data: Fixturizer::Services.get.engine(name: :dataset, parameters: { dataset:
|
55
55
|
{ definition: item[:attributes], rules: @models[name][:rules]}
|
56
56
|
}).generate }
|
57
|
-
|
58
|
-
res[:
|
57
|
+
belong = item.dig(:belong)
|
58
|
+
res[:belong] = belong if belong
|
59
|
+
have = item.dig(:have)
|
60
|
+
res[:have] = have if have
|
59
61
|
data.push res
|
60
62
|
|
61
63
|
end
|
data/samples/Gemfile
CHANGED
data/samples/app.rb
CHANGED
@@ -16,8 +16,18 @@ class Post
|
|
16
16
|
field :title, type: String
|
17
17
|
field :body, type: String
|
18
18
|
has_many :comments
|
19
|
+
has_one :type
|
19
20
|
end
|
20
21
|
|
22
|
+
|
23
|
+
class Type
|
24
|
+
include Mongoid::Document
|
25
|
+
field :name, type: String
|
26
|
+
field :description, type: String
|
27
|
+
belongs_to :post, optional: true
|
28
|
+
end
|
29
|
+
|
30
|
+
|
21
31
|
class Comment
|
22
32
|
include Mongoid::Document
|
23
33
|
field :name, type: String
|
@@ -37,7 +47,8 @@ class Application < Sinatra::Base
|
|
37
47
|
get '/posts/:post_id' do |post_id|
|
38
48
|
post = Post.find(post_id)
|
39
49
|
post.attributes.merge(
|
40
|
-
comments: post.comments
|
50
|
+
comments: post.comments,
|
51
|
+
type: post.type
|
41
52
|
).to_json
|
42
53
|
end
|
43
54
|
end
|
data/samples/config/rules.yml
CHANGED
@@ -23,9 +23,20 @@
|
|
23
23
|
:models:
|
24
24
|
:type: :mongoid
|
25
25
|
:order:
|
26
|
+
- :types
|
26
27
|
- :posts
|
27
28
|
- :comments
|
28
29
|
:definitions:
|
30
|
+
:types:
|
31
|
+
:class: Type
|
32
|
+
:unicity: :name
|
33
|
+
:collection:
|
34
|
+
- :attributes:
|
35
|
+
:name: News
|
36
|
+
:description: A fresh news
|
37
|
+
- :attributes:
|
38
|
+
:name: Reaction
|
39
|
+
:description: An instant reaction
|
29
40
|
:posts:
|
30
41
|
:rules:
|
31
42
|
:body: :preserve_body
|
@@ -35,6 +46,11 @@
|
|
35
46
|
- :attributes:
|
36
47
|
:title: First post Title
|
37
48
|
:body: First Post Body
|
49
|
+
# :have:
|
50
|
+
# :linked: :types
|
51
|
+
# :by: :type
|
52
|
+
# :search_by:
|
53
|
+
# :name: News
|
38
54
|
- :attributes:
|
39
55
|
:title: Second post Title
|
40
56
|
:body:
|
@@ -45,7 +61,7 @@
|
|
45
61
|
- :attributes:
|
46
62
|
:name: test name
|
47
63
|
:message: test message
|
48
|
-
:
|
64
|
+
:belong:
|
49
65
|
:to: :posts
|
50
66
|
:by: :comments
|
51
67
|
:search_by:
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fixturizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre ALPHONSE
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-10-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|
@@ -45,14 +45,14 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 3.
|
48
|
+
version: 3.13.0
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 3.
|
55
|
+
version: 3.13.0
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: version
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|