admin_model 0.2.0 → 0.2.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bacb984cb5145c08980e17f42291b7614b4ef6767b912794140aee813c70b00c
|
4
|
+
data.tar.gz: a01a66662dfd0219aa96b4aa71faf946dc999e38730ff246814ed4b0cbc4924c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e98569a4c4809f7362306c453945cde759240e3553d25ab349c26df56df2e17cf1046afbc669d6f1ec21de3ef0581fa263bc8a20d11f58b1c6045569292a6814
|
7
|
+
data.tar.gz: 64158658398ebec5c815eed2303ecc0fceacb6f752ee0d17f8a4873de7e366eb08464af2c231e3cbfdfe1346dcd739a8efc34213fa442a9f59a3b44189019d0b
|
data/lib/admin_model/version.rb
CHANGED
@@ -10,55 +10,29 @@ class AdminModelGenerator < Rails::Generators::NamedBase
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def crate_rails_admin_concern
|
13
|
-
@
|
13
|
+
@pascal_name = class_name.singularize
|
14
|
+
@snake_name = file_name.singularize
|
14
15
|
@fields_list = ''
|
15
16
|
@attributes.each do |attribute|
|
16
17
|
@fields_list << "\n field :#{attribute.name}"
|
17
18
|
end
|
18
|
-
template 'admin_model.template', "app/models/concerns/rails_admin/#{
|
19
|
+
template 'admin_model.template', "app/models/concerns/rails_admin/#{@snake_name}.rb"
|
19
20
|
end
|
20
21
|
|
21
22
|
def include_rails_admin
|
22
|
-
inject_into_class "app/models/#{
|
23
|
+
inject_into_class "app/models/#{@snake_name}.rb", @pascal_name, " include RailsAdmin::#{@pascal_name}\n"
|
23
24
|
end
|
24
25
|
|
25
26
|
def get_translation_file
|
26
|
-
|
27
|
+
@ptbr_path = 'config/locales/pt-BR.yml'
|
28
|
+
ptbr = File.read(@ptbr_path)
|
27
29
|
@ptbr_hash = YAML.load(ptbr)
|
28
30
|
end
|
29
|
-
|
30
|
-
def insert_deafult_attributes_translations_if_necessary
|
31
|
-
if @ptbr_hash["pt-BR"]["activerecord"]["attributes"]["default_attributes"].nil?
|
32
|
-
inject_into_file 'config/locales/pt-BR.yml', after: "\n attributes:\n" do
|
33
|
-
<<-YML
|
34
|
-
default_attributes: &default_attributes
|
35
|
-
id: '#'
|
36
|
-
name: Nome
|
37
|
-
created_at: Data de criação
|
38
|
-
updated_at: Data de atualização
|
39
|
-
YML
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def insert_base_errors_translations_if_necessary
|
45
|
-
if @ptbr_hash["pt-BR"]["activerecord"]["errors"]["models"]["base_errors"].nil?
|
46
|
-
inject_into_file 'config/locales/pt-BR.yml', after: " errors:\n models:\n" do
|
47
|
-
<<-YML
|
48
|
-
base_errors: &base_errors
|
49
|
-
blank: não pode ficar em branco
|
50
|
-
invalid: invalido
|
51
|
-
required: é requirido
|
52
|
-
taken: já existe e deve ser único
|
53
|
-
YML
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
31
|
def inssert_model_translation_keys
|
59
|
-
|
32
|
+
ptbr = File.read(@ptbr_path)
|
33
|
+
inject_into_file @ptbr_path, after: ptbr[/pt-BR:\n(.*\n)* {2}activerecord:\n(.*\n)* {4}models:\n( {6}.+(\n( {8}.+\n)+))+/] do
|
60
34
|
<<-YML
|
61
|
-
#{
|
35
|
+
#{@snake_name}:
|
62
36
|
one: please fill me
|
63
37
|
other: please fill me
|
64
38
|
YML
|
@@ -69,22 +43,22 @@ class AdminModelGenerator < Rails::Generators::NamedBase
|
|
69
43
|
model_attriutes = @attributes.reduce('') do |acc, attribute|
|
70
44
|
"#{acc}\n #{attribute.name}: please fill me"
|
71
45
|
end
|
72
|
-
ptbr = File.read(
|
73
|
-
inject_into_file
|
46
|
+
ptbr = File.read(@ptbr_path)
|
47
|
+
inject_into_file @ptbr_path, after: ptbr[/pt-BR:\n(.*\n)* {2}activerecord:\n(.*\n)* {4}attributes:\n( {6}.+(\n( {8}.+\n)+))+/] do
|
74
48
|
<<-YML
|
75
|
-
#{
|
49
|
+
#{@snake_name}:#{model_attriutes}
|
76
50
|
YML
|
77
51
|
end
|
78
52
|
end
|
79
53
|
|
80
54
|
def insert_attributes_errors_translation_keys
|
81
55
|
model_attriutes = @attributes.reduce('') do |acc, attribute|
|
82
|
-
"#{acc}\n #{attribute.name}
|
56
|
+
"#{acc}\n #{attribute.name}:"
|
83
57
|
end
|
84
|
-
ptbr = File.read(
|
85
|
-
inject_into_file
|
58
|
+
ptbr = File.read(@ptbr_path)
|
59
|
+
inject_into_file @ptbr_path, after: ptbr[/pt-BR:\n(.*\n)* {2}activerecord:\n(.*\n)* {4}errors:\n(.*\n)* {6}models:\n( {8}.+(\n( {10}.+\n)+))+/] do
|
86
60
|
<<-YML
|
87
|
-
#{
|
61
|
+
#{@snake_name}:\n attributes:#{model_attriutes}
|
88
62
|
YML
|
89
63
|
end
|
90
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: admin_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alberto Bazilio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -59,7 +59,6 @@ files:
|
|
59
59
|
- lib/admin_model/version.rb
|
60
60
|
- lib/generators/admin_model/admin_model_generator.rb
|
61
61
|
- lib/generators/admin_model/templates/admin_model.template
|
62
|
-
- lib/tasks/admin_model_tasks.rake
|
63
62
|
homepage: https://github.com/albertobazilio98/admin_model
|
64
63
|
licenses:
|
65
64
|
- MIT
|
@@ -79,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
78
|
- !ruby/object:Gem::Version
|
80
79
|
version: '0'
|
81
80
|
requirements: []
|
82
|
-
rubygems_version: 3.
|
81
|
+
rubygems_version: 3.2.3
|
83
82
|
signing_key:
|
84
83
|
specification_version: 4
|
85
84
|
summary: Quickly create rails admin stuff
|