rails-formation 0.0.0.2 → 0.0.0.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50040a27201ad285113ca45ba39a904f4cc29e6876d6054a12253bc2294e209b
|
4
|
+
data.tar.gz: c10d8b45c7478f6592c5437346ce70682dec3463911f5f9db322822b0b812d53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7daf43d31ef3128f8e4a154d7fb76c1eee8158146b63908bfbe01346057a961dbbd23af918df1c87db4874b3f04546dbf471fa565800db32405bed4679b64362
|
7
|
+
data.tar.gz: 77415da7829c9badc09107668c5085d270a775d3c16dddfb1b362334119783d8f146b3eb3649187a31ade1b3271db3d9d4f93a91e0741569e26f05b19b7634c6
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'models/validation'
|
4
|
+
require_relative 'models/association'
|
4
5
|
|
5
6
|
module RailsFormation
|
6
7
|
module Formatters
|
@@ -24,6 +25,12 @@ module RailsFormation
|
|
24
25
|
model_configuration.fetch('name')
|
25
26
|
end
|
26
27
|
|
28
|
+
def associations
|
29
|
+
model_configuration.fetch('associations', []).map do |config|
|
30
|
+
RailsFormation::Formatters::Models::Association.new(config).to_s
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
27
34
|
def validations
|
28
35
|
models_with_validations = model_configuration.fetch('columns', []).select do |config|
|
29
36
|
config.fetch('validations', []).size.positive?
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsFormation
|
4
|
+
module Formatters
|
5
|
+
module Models
|
6
|
+
class Association
|
7
|
+
def initialize(config)
|
8
|
+
@config = config
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
base_def = "#{relation} :#{destination}"
|
13
|
+
|
14
|
+
return base_def if options.size.zero?
|
15
|
+
|
16
|
+
options_def = options.map { |option| option.values.join(': ') }.join(', ')
|
17
|
+
|
18
|
+
"#{base_def}, #{options_def}"
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def relation
|
24
|
+
@config.fetch('type')
|
25
|
+
end
|
26
|
+
|
27
|
+
def destination
|
28
|
+
@config.fetch('destination')
|
29
|
+
end
|
30
|
+
|
31
|
+
def options
|
32
|
+
@config.fetch('options', [])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/rails_formation.rb
CHANGED
@@ -34,8 +34,13 @@ module RailsFormation
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def generate_project(template)
|
37
|
-
|
38
|
-
|
37
|
+
if template['architecture'] == 'api'
|
38
|
+
system "rails _#{RailsFormation::RAILS_VERSION}_ new #{template['app_name']} --api -d=postgresql"
|
39
|
+
else
|
40
|
+
system "rails _#{RailsFormation::RAILS_VERSION}_ new #{template['app_name']} -d=postgresql"
|
41
|
+
end
|
42
|
+
|
43
|
+
Dir.chdir(template['app_name'])
|
39
44
|
end
|
40
45
|
|
41
46
|
def bundle_and_install_gems(rubygems)
|
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.3
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffaker
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- lib/rails-formation/formatters/migrations/column.rb
|
130
130
|
- lib/rails-formation/formatters/migrations/index.rb
|
131
131
|
- lib/rails-formation/formatters/model.rb
|
132
|
+
- lib/rails-formation/formatters/models/association.rb
|
132
133
|
- lib/rails-formation/formatters/models/validation.rb
|
133
134
|
- lib/rails-formation/formatters/models/validations/base.rb
|
134
135
|
- lib/rails-formation/formatters/models/validations/comparsion.rb
|
@@ -175,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
176
|
- !ruby/object:Gem::Version
|
176
177
|
version: '0'
|
177
178
|
requirements: []
|
178
|
-
rubygems_version: 3.
|
179
|
+
rubygems_version: 3.2.32
|
179
180
|
signing_key:
|
180
181
|
specification_version: 4
|
181
182
|
summary: Templates for Rails bootstraping
|