audited-serialize 1.0.3 → 1.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: 9831becf62c15330c967bfb39d7de664d35f927399d49d990588c5e84ae5db3c
4
- data.tar.gz: db7ef7657110c4c0af5460c4d9a548e72caea9eaefd56c717b35de623630b7fe
3
+ metadata.gz: 0f1764964d7c63fd745b4b25b2fa88067b310992a286f3a380c2b41a2009915d
4
+ data.tar.gz: 538a27e2bd456181bd64408504e416e4cfea91031e8c2469e347aedab6046106
5
5
  SHA512:
6
- metadata.gz: 6e933f808d43686f17615b55748f1d3fca883e7ec79caf74a480a0cda8d136dc9eba4cb865a430950b831a509ebe965ad648307b9f36605396fc0750cbffc0cc
7
- data.tar.gz: '0219e93533c1844bf0992a606bcbb99fa209f3803e59fb39be8644fda11e6213844b7f61796a6fa1514486fe39fe0cfc84390d930c8735db3cfe1a1788e55eab'
6
+ metadata.gz: 1c1c4bd89a5ab831c1a777749f17af3236cd65f07eed3a5a89e4d790f3e81373b4dd99d89d2111ef4155942fc24955fbe9838c8db7d0bfae96a97ed414f8edb5
7
+ data.tar.gz: 90bfe8faf1dcdcc9516052fcb1e8d49d0cd575be3bac8df1eab66313ecf3ad9eca0e8725abdb0da2895ea9fbfa29930ee1f20acebe0b03157f1be26e60b740dd
@@ -37,6 +37,16 @@ module Audited
37
37
  "#{operation} #{entity}"
38
38
  end
39
39
 
40
+ def self.models_list
41
+ Rails.application.eager_load!
42
+
43
+ ActiveRecord::Base.descendants.map do |model|
44
+ if model.respond_to?(:auditing_enabled)
45
+ model.to_s
46
+ end
47
+ end.compact.sort
48
+ end
49
+
40
50
  end
41
51
 
42
52
  @ignored_attributes = %w[
@@ -0,0 +1,33 @@
1
+ require 'rake'
2
+
3
+ namespace :audited do
4
+
5
+ desc 'Поиск недостающих переводов названий сущностей'
6
+ task find_missing_translations: :environment do
7
+ missing = []
8
+
9
+ # модели, на которых включены аудит-логи
10
+ audited_models = Audited::Audit.models_list
11
+
12
+ # содержимое файла с переводами
13
+ content = YAML.load_file('config/locales/audited_serialize.ru.yml')
14
+ types_in_file = content['ru']['audited_serialize']['auditable_types']
15
+
16
+ # модели с пустыми переводами
17
+ missing += types_in_file.map { |model, translation| model if translation.blank? }.compact
18
+
19
+ # недостающие модели
20
+ missing += audited_models - types_in_file.keys
21
+
22
+ if missing.empty?
23
+ abort('Все модели переведены')
24
+ else
25
+ $stdout.puts 'Недостающие переводы моделей:'
26
+ end
27
+
28
+ missing.sort.each do |model|
29
+ $stdout.puts %(#{model}: "")
30
+ end
31
+ end
32
+
33
+ end
@@ -1,5 +1,6 @@
1
1
  require 'audited_config'
2
2
  require 'audited/audit_extensions'
3
+ require 'audited/rake_tasks'
3
4
 
4
5
  I18n.load_path << File.expand_path('audited/locale/ru.yml', __dir__)
5
6
 
@@ -2,6 +2,6 @@ ru:
2
2
  audited_serialize:
3
3
  auditable_types:
4
4
  # в ед. числе, в родительном падеже c маленькой буквы
5
- <%- models.each do |model| -%>
5
+ <%- Audited::Audit.models_list.each do |model| -%>
6
6
  <%= model %>: ""
7
7
  <%- end -%>
@@ -8,18 +8,6 @@ module Audited
8
8
  template 'locale.rb', File.join('config/locales/audited_serialize.ru.yml')
9
9
  end
10
10
 
11
- private
12
-
13
- def models
14
- Rails.application.eager_load!
15
-
16
- ActiveRecord::Base.descendants.map do |model|
17
- if model.respond_to?(:auditing_enabled)
18
- model.to_s
19
- end
20
- end.compact.sort
21
- end
22
-
23
11
  end
24
12
  end
25
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audited-serialize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Павел Бабин
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-11 00:00:00.000000000 Z
11
+ date: 2024-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -48,6 +48,7 @@ files:
48
48
  - lib/audited-serialize.rb
49
49
  - lib/audited/audit_extensions.rb
50
50
  - lib/audited/locale/ru.yml
51
+ - lib/audited/rake_tasks.rb
51
52
  - lib/audited/serialization.rb
52
53
  - lib/audited/serialization_changes/array_module.rb
53
54
  - lib/audited/serialization_changes/boolean_module.rb