admin_model 0.1.4 → 0.1.5
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: e8030d6044ba3d098814a0c8bdab11afffa09974a7501af67529d46d4010fb5f
|
4
|
+
data.tar.gz: f6a7bd13edc44eb74dbc89c98e806275dc96dd0ec57492c51116efe5c0370796
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9853593cb88cf29a2ac90a4ecc517216a0c82ec23ce58a6b49bafbb34728feb1717fd1a22bf9511f37bad7cb32e12c627467ec304a97ee89ee67529460e0af37
|
7
|
+
data.tar.gz: 67cc136fb042d51ff8f71b12501193dfa054ef95d46b2c81fb8562af977052e428bc6ae51a4449c359485458a7aaa65dc207e54dec6f228e23002ef1c20dcfdf
|
data/lib/admin_model/version.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
1
3
|
class AdminModelGenerator < Rails::Generators::NamedBase
|
2
4
|
source_root File.expand_path('templates', __dir__)
|
3
5
|
|
@@ -20,7 +22,40 @@ class AdminModelGenerator < Rails::Generators::NamedBase
|
|
20
22
|
inject_into_class "app/models/#{file_name}.rb", class_name, " include RailsAdmin::#{class_name}\n"
|
21
23
|
end
|
22
24
|
|
23
|
-
def
|
25
|
+
def get_translation_file
|
26
|
+
ptbr = File.read('config/locales/pt-BR.yml')
|
27
|
+
@ptbr_hash = YAML.load(ptbr)
|
28
|
+
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
|
+
def inssert_model_translation_keys
|
24
59
|
inject_into_file 'config/locales/pt-BR.yml', after: "\n models:\n" do
|
25
60
|
<<-YML
|
26
61
|
#{name}:
|
@@ -28,16 +63,29 @@ class AdminModelGenerator < Rails::Generators::NamedBase
|
|
28
63
|
other: please fill me
|
29
64
|
YML
|
30
65
|
end
|
31
|
-
|
32
|
-
|
33
|
-
|
66
|
+
end
|
67
|
+
|
68
|
+
def insert_attributes_translation_keys
|
69
|
+
model_attriutes = @attributes.reduce('') do |acc, attribute|
|
70
|
+
"#{acc}\n #{attribute.name}: please fill me"
|
34
71
|
end
|
35
|
-
|
72
|
+
ptbr = File.read("config/locales/pt-BR.yml")
|
73
|
+
inject_into_file 'config/locales/pt-BR.yml', after: ptbr[/pt-BR:\n(.*\n)* {2}activerecord:\n(.*\n)* {4}attributes:\n( {6}.+(\n( {8}.+\n)+))+/] do
|
36
74
|
<<-YML
|
37
|
-
#{name}
|
75
|
+
#{name}:\n <<: *default_attributes#{model_attriutes}
|
38
76
|
YML
|
39
77
|
end
|
40
78
|
end
|
41
79
|
|
42
|
-
|
80
|
+
def insert_attributes_errors_translation_keys
|
81
|
+
model_attriutes = @attributes.reduce('') do |acc, attribute|
|
82
|
+
"#{acc}\n #{attribute.name}:\n <<: *base_errors"
|
83
|
+
end
|
84
|
+
ptbr = File.read("config/locales/pt-BR.yml")
|
85
|
+
inject_into_file 'config/locales/pt-BR.yml', after: ptbr[/pt-BR:\n(.*\n)* {2}activerecord:\n(.*\n)* {4}errors:\n(.*\n)* {6}models:\n( {8}.+(\n( {10}.+\n)+))+/] do
|
86
|
+
<<-YML
|
87
|
+
#{name}:\n attributes:#{model_attriutes}
|
88
|
+
YML
|
89
|
+
end
|
90
|
+
end
|
43
91
|
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.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alberto Bazilio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|