rails-formation 0.0.0.3 → 0.0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50040a27201ad285113ca45ba39a904f4cc29e6876d6054a12253bc2294e209b
4
- data.tar.gz: c10d8b45c7478f6592c5437346ce70682dec3463911f5f9db322822b0b812d53
3
+ metadata.gz: 8efb69cf115eb4c7ca797d5992be87fa2a87eb43846b939454f9c59b42142e1c
4
+ data.tar.gz: 237ccc291969455ce85cc68e3a73b2989ccd504550b945aeb0e82930bd6773dd
5
5
  SHA512:
6
- metadata.gz: 7daf43d31ef3128f8e4a154d7fb76c1eee8158146b63908bfbe01346057a961dbbd23af918df1c87db4874b3f04546dbf471fa565800db32405bed4679b64362
7
- data.tar.gz: 77415da7829c9badc09107668c5085d270a775d3c16dddfb1b362334119783d8f146b3eb3649187a31ade1b3271db3d9d4f93a91e0741569e26f05b19b7634c6
6
+ metadata.gz: 561247aecde1b2afc1f5aad8a26fb34da6130c97435d0f5a0b4748b86ab6f26e1952bd09af8c279ba1f0f8ea76e773dde4412beac5d5d5174300dd1cabdf9796
7
+ data.tar.gz: '038e3871279c32d1365f7cb8beaf66bcc7f0433ba04d7fb989b80597fc84148d31d443496fc73301954a7fd7e2d3c216f90872270790f38a12ee17fed5d63cc1'
@@ -49,7 +49,7 @@ module RailsFormation
49
49
  'email' => 'FFaker::Internet.email',
50
50
  'username' => 'FFaker::Internet.user_name',
51
51
  'domain' => 'FFaker::Internet.domain_name',
52
- 'slug' => "Faker::Internet.slug(nil, '-')",
52
+ 'slug' => "FFaker::Internet.slug(nil, '-')",
53
53
  'job_title' => 'FFaker::Job.title',
54
54
  'locale' => 'FFaker::Locale.code',
55
55
  'language' => 'FFaker::Locale.language',
@@ -25,7 +25,7 @@ module RailsFormation
25
25
  end
26
26
 
27
27
  def associations
28
- []
28
+ factory_configuration.fetch('associations', [])
29
29
  end
30
30
 
31
31
  def columns
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative 'migrations/column'
4
4
  require_relative 'migrations/index'
5
+ require_relative 'migrations/options'
5
6
 
6
7
  module RailsFormation
7
8
  module Formatters
@@ -25,10 +26,20 @@ module RailsFormation
25
26
  migration_configuration.fetch('table')
26
27
  end
27
28
 
29
+ def migration_name
30
+ migration_configuration.fetch('migration_name')
31
+ end
32
+
28
33
  def timestamps?
29
34
  migration_configuration.fetch('timestamps', false)
30
35
  end
31
36
 
37
+ def table_options
38
+ RailsFormation::Formatters::Migrations::Options.new(
39
+ migration_configuration.fetch('options', [])
40
+ ).to_s
41
+ end
42
+
32
43
  def columns
33
44
  migration_configuration.fetch('columns', []).map do |config|
34
45
  RailsFormation::Formatters::Migrations::Column.new(config).to_s
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsFormation
4
+ module Formatters
5
+ module Migrations
6
+ class Options
7
+ def initialize(options)
8
+ @options = options
9
+ end
10
+
11
+ def to_s
12
+ return if @options.size.zero?
13
+
14
+ @options.map { |option| option.values.join(': ') }.join(', ')
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -2,6 +2,9 @@ FactoryBot.define do
2
2
  factory :<%= factory_name %> do
3
3
  <% columns.each do |column| -%>
4
4
  <%= column %>
5
+ <% end -%>
6
+ <% associations.each do |association| -%>
7
+ <%= association %>
5
8
  <% end -%>
6
9
  end
7
10
  end
@@ -1,11 +1,11 @@
1
- class Create<%= table_name.capitalize %> < ActiveRecord::Migration[7.0]
1
+ class Create<%= migration_name %> < ActiveRecord::Migration[7.0]
2
2
  def change
3
- create_table :<%= table_name %> do |t|
3
+ <% if table_options.nil? %>create_table :<%= table_name %> do |t|<% else %>create_table :<%= table_name %>, <%= table_options %> do |t|<% end %>
4
4
  <% columns.each do |column| -%>
5
5
  <%= column %>
6
6
  <% end -%>
7
- <% if timestamps? -%>
8
- t.timestamps
7
+ <%- if timestamps? -%>
8
+ t.timestamps
9
9
  <% end -%>
10
10
  end
11
11
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsFormation
4
- VERSION = '0.0.0.3'
4
+ VERSION = '0.0.0.4'
5
5
  RAILS_VERSION = '7.0.2.3'
6
6
  end
@@ -84,7 +84,7 @@ module RailsFormation
84
84
 
85
85
  def create_and_build_models(models)
86
86
  models.each do |config|
87
- model_name = "#{config.fetch('name').downcase}.rb"
87
+ model_name = "#{config.fetch('file_name').downcase}.rb"
88
88
  model_path = File.join(Dir.pwd, 'app', 'models', model_name)
89
89
 
90
90
  ::RailsFormation::Formatters::Model.new([config, model_path]).invoke_all
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-formation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.3
4
+ version: 0.0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paweł Dąbrowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-18 00:00:00.000000000 Z
11
+ date: 2022-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffaker
@@ -128,6 +128,7 @@ files:
128
128
  - lib/rails-formation/formatters/migration.rb
129
129
  - lib/rails-formation/formatters/migrations/column.rb
130
130
  - lib/rails-formation/formatters/migrations/index.rb
131
+ - lib/rails-formation/formatters/migrations/options.rb
131
132
  - lib/rails-formation/formatters/model.rb
132
133
  - lib/rails-formation/formatters/models/association.rb
133
134
  - lib/rails-formation/formatters/models/validation.rb