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 +4 -4
- data/lib/rails-formation/formatters/factories/value.rb +1 -1
- data/lib/rails-formation/formatters/factory.rb +1 -1
- data/lib/rails-formation/formatters/migration.rb +11 -0
- data/lib/rails-formation/formatters/migrations/options.rb +19 -0
- data/lib/rails-formation/templates/factory.rb.tt +3 -0
- data/lib/rails-formation/templates/migration.rb.tt +4 -4
- data/lib/rails-formation/version.rb +1 -1
- data/lib/rails_formation.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8efb69cf115eb4c7ca797d5992be87fa2a87eb43846b939454f9c59b42142e1c
|
4
|
+
data.tar.gz: 237ccc291969455ce85cc68e3a73b2989ccd504550b945aeb0e82930bd6773dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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' => "
|
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',
|
@@ -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
|
@@ -1,11 +1,11 @@
|
|
1
|
-
class Create<%=
|
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
|
-
|
8
|
-
|
7
|
+
<%- if timestamps? -%>
|
8
|
+
t.timestamps
|
9
9
|
<% end -%>
|
10
10
|
end
|
11
11
|
|
data/lib/rails_formation.rb
CHANGED
@@ -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('
|
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.
|
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-
|
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
|