fixturizer 0.4.2 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf7a1159047eed0d85251205266b374018fc8f7c7b7c312f91db96eb632a87ae
4
- data.tar.gz: 965f93e4be42f6207e00647b2d456451425421b04eea4d7ceea984c5a2a7ce98
3
+ metadata.gz: 9cc92b66c50911ec30ffd277772939fb652d9b88e3dc33fa2b1cdbccb01aa776
4
+ data.tar.gz: 7cce30b3455b91e6e32fbdede70a1637e8b063f7b1bf3e02cce8e4e39d0bdbcd
5
5
  SHA512:
6
- metadata.gz: 0ef1bea30d4ce6398a6eb0f2df942ecb26ad25f9828339b8fb3e9067c18fe07a7bb7220ddba5ae3596c313d2202dd06dabaf40cf51ec370754b69796386d72f0
7
- data.tar.gz: 2f46d5b7386d853503abc3b95576f1fbea6fe602f5a1608e4812a7639568ee50f303f2bed11daa0632ab344b3bd717757cbc4f9aff05c3f894926fb2a2f3fc0c
6
+ metadata.gz: 3e213a056cc0d54acc95ef428a47125cc1a48a733e6065fc30a0bcee7b50c88c873b4eac799b3d9e4e4813439ba5cdc0f67c4396f33f46ac68e926451aa9ee13
7
+ data.tar.gz: 4ed4d832360555326fc93d16ef9c8413f506c250e39dfa7e56adf7cb65de20f1405812c6b3683ee00e5d4e2d937d1163c5de0cae13f276a60dd316d3e3eb454c
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
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.10.0'
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
- link = record.dig(:link,:to)
12
- by = record.dig(:link,:by)
13
- pattern = record.dig(:link,:search_by)
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[link][:class]).find_by(**pattern).send by
16
- model.create!(record[:data]) unless model.where(@models[link][:unicity] => record[:data][@models[link][:unicity]]).exists?
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,:links]
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? :link
201
- unless record[:link].is_a? Hash then
202
- @status[:error].push "//:fixtures/:models/:definitions/:#{name}/:collection[#{i}]/:link is set but is not a Hash"
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}]/:link not have key :#{verb} defined" unless record[:link].include? verb
206
- @status[:error].push "//:fixtures/:models/:definitions/:#{name}/:collection[#{i}]/:link/:#{verb} is not a #{type}" unless record[:link][verb].is_a? type
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
- link = item.dig(:link)
58
- res[:link] = link if link
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
@@ -14,8 +14,8 @@ module Fixturizer
14
14
 
15
15
  def populate
16
16
  Fixturizer::Services.get.engine(name: :models).populate
17
- rescue StandardError
18
- false
17
+ # rescue StandardError
18
+ # false
19
19
  end
20
20
  end
21
21
  end
data/samples/Gemfile CHANGED
@@ -11,7 +11,7 @@ group :test, :development do
11
11
  gem 'rack-rest-rspec', '~> 0.0.3'
12
12
  gem 'rack-test', '~> 2.0.2'
13
13
  gem 'rake', '~> 13.0'
14
- gem 'rspec', '~> 3.10.0'
14
+ gem 'rspec', '~> 3.13.0'
15
15
  end
16
16
 
17
17
  gem 'mongoid', '~> 9.0'
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
@@ -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
- :link:
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.2
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-05-22 00:00:00.000000000 Z
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.10.0
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.10.0
55
+ version: 3.13.0
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: version
58
58
  requirement: !ruby/object:Gem::Requirement