awesome_translations 0.0.59 → 0.0.60
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/awesome_translations/clean_ups_controller.rb +1 -1
- data/lib/awesome_translations/cache_database_generator/group.rb +9 -2
- data/lib/awesome_translations/cache_database_generator/handler.rb +9 -2
- data/lib/awesome_translations/cache_database_generator/handler_translation.rb +11 -3
- data/lib/awesome_translations/cache_database_generator/translation_key.rb +4 -4
- data/lib/awesome_translations/cache_database_generator/translation_value.rb +3 -1
- data/lib/awesome_translations/erb_inspector/file_inspector.rb +4 -4
- data/lib/awesome_translations/erb_inspector/translation_inspector.rb +7 -7
- data/lib/awesome_translations/global_translator.rb +4 -4
- data/lib/awesome_translations/handlers/validations_handler.rb +3 -3
- data/lib/awesome_translations/model_inspector.rb +6 -9
- data/lib/awesome_translations/version.rb +1 -1
- data/spec/dummy/config.ru +1 -1
- data/spec/features/movals_spec.rb +3 -3
- data/spec/handlers/file_handler_spec.rb +2 -2
- data/spec/handlers/model_handler_spec.rb +2 -2
- data/spec/lib/erb_inspector/file_inspector_spec.rb +2 -2
- data/spec/lib/erb_inspector/translation_inspector_spec.rb +1 -1
- metadata +65 -169
- data/spec/dummy/db/awesome_translations.sqlite3 +0 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -79
- data/spec/dummy/log/test.log +0 -1910
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/-o/-oFcVYifzG9CN5_s1hdowmNEkOY9nMkeYSN1wi8jK9k.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/0-/0-1MiAUTzmkJ19QVNrjLw3HNw2Cu4279NlmUcUv0lnU.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/1R/1RUC_iIhcuw4UJeKhOqLFN8264iDG1axfV3uVyPv0wg.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/2m/2mnPY9uUnBNkGHLxtFaWv5hB3oA7sY2K1ZtwQlZLnAY.cache +0 -2
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/3N/3NnKgR2TsTI1qCXKZpts0uJzp2dRJcoYp3nnFU6YE4o.cache +0 -2
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/5U/5U8HCshUrO4uN8GT_N4K-MtrOiG-4cWdiepxNuvIjAw.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/6y/6y2qhWDpnSTpsocv2lVSclXFxpCRU78VjU0sy2FGrWc.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/8f/8f4REKYOWkNfHexyAVqGXnbOP3vky_ANapWzlRMDeQ4.cache +0 -3
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/8p/8pzZq0f95KJrJtOmdr_19FPTeyHX3zMnw6Epsu3T_6c.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/8x/8xTH_c2XZMdMXFHSjlUQD4pTAYTNqnrTrjDURs8jlFI.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/AC/ACPB0Rs6DHQU6RIjgT-BODcpFLYUC_sPb9CvJGvg6ro.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/AJ/AJ3ShPZKDgRfZy8niYD_tk4u0Ur5Y6oC85d-0oXgc3w.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/AU/AUklJJKwz_vqy3TUoKDyB5ounU8pAqv6-_tES3aPoZ8.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/CP/CPuNl6dzr9CzS_s74a_K5yuTPy1ch0_-ehTglX1zaEE.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/CV/CVBUxdOogbkuDTae7pFS7i66HyowCSP07Os91LwRmHY.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Ca/CaGQBiCuFgkHQ5gw8ZnGQqO8iP1md3GcllDsmaKBFdQ.cache +0 -2
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Do/Do83AoOat5W-c1g7piDGy2GMmffsY6JY0Qfuh5PY3GM.cache +0 -2
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/ER/EREGJziB-yMwOXwJeDrZ6Tie8HJU33_JSMXwzy7JsG4.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Fc/FcJbnT7qHcLV5Zp_u7NV_yomOI9o9yG-F00bV0Gzm_Q.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Mj/MjwYGG9GkHD1fwwH2bg66EBYl3zCA_mqeDF9otey4-U.cache +0 -3
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/O6/O6K_G66TEscDh-j-DIIwfAqivslF8smPlcj9dJCvrh4.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/O6/O6zA2BS4Y306Mmq4fuRnINim1pUdJgZvv_GJkGYXFxw.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Ql/QlbxNnG-vjEDZ8GyOJHhNZY-GeHvDiuCj8IATbE9C8w.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/S5/S57ilTeMjIW4abqhMiTmEi59zjS9uSXp697eO1D1Wjo.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/S8/S86Mp1PRbiyejdN42WqWkRnoIoKRl4WoqM5lKxqw1w4.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Sb/Sb1Vug319YfPL2Rci1PLMLXJjeIFYcNbHb5hKOvO1eo.cache +0 -2
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/TC/TCAloV783-iAe72Q34cyIRfs-xPaNfSgPcPF2dl-zYI.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Xn/Xn4epb06guWXnirWNYPta7ddzOkxd1aVDzRMoXp8pjM.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/aa/aaoYFMRQGOYTpfFXf34S0CVVWaAJUx6s8QsSHm476OQ.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/cK/cK9VEAGHFBzTxd0ICAK2Fv9RWWgiv9I6347by_BYm1w.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/gc/gcjjMGVBrPIbM3oh-VsmXt-W8kWTs2Hc0sM2r5hicgQ.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/hc/hc75Wwlo1W1FF6zeSSelZ-DXn-n6YkTrvq3_yoXpydw.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/iF/iFAZApKjMydtC8Y6hvIXTy-zC2cfmbTrsYlU62u8sJU.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/iR/iRIYdMKKwG2D6Tnj-0pGybHLEINmWZ8211nkI700-0Y.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/l2/l2s6YvBxO6tXxM01zv13Dv6jpXaksukCd31VGPl6vPI.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/mX/mXfx3VRudxpXrRx1aejtNA5YHOwND3kwWUfvdXHSors.cache +0 -2
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/p7/p70iWC7uyeRLwIEniw-3RltmTZ-lz45IJdePewoXyHY.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/pv/pv6tV3CDkIAmLXdU8EPLlNEkXAKJPufVD4VP30o4fWo.cache +0 -2
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/q6/q6BYa32YJF11eGVapO4ouNl6gayPIsARgMavlzZmoi0.cache +0 -2
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/qZ/qZ6ZFXF-wqwyHA2DvJW0tnnFPW-sRmoNY7ysyNfUdi0.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/rH/rH2d5ogZr608pUvHYHKRlqMZTk7BNi8Qp5nL1PLrir8.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/rI/rITk_65QtUwq61bjRPAksGeJxbLUFfz-sFPnQiZPHjw.cache +0 -3
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/sH/sHqNaY2cQIVvwCv9thQRcI9KaeVjzBt9-dJ8mKnCKMk.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/x7/x7KkTV3ibfIEysLB_ug5bfmnn2VLV_BldukPR3EoPBk.cache +0 -2
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/xk/xkvAEoJDntdxUR56voDrW44MZ8Cx6i9WXQXrLDh2A_w.cache +0 -2
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/za/zaxpzmSeETtWCbb5X2jLBDtr4Ei16ZUatImF5HE6Mpo.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/zh/zhMgApDdWwFGN9H6KcXRKPtCaQtDHW91V9n3vt_EhoA.cache +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55dac9259ef0eb5ae536764f8bd14c5df32277491c8aa478ee9160bef11efe2c
|
4
|
+
data.tar.gz: a74978683d4b38c71c3917d0c9e85ae7a11e28e177a0d941908fea9eabed0135
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b16c21783bffaf2205e929161bd289649a7f312bc16c670207a165f54e4287779a01873b19dab6dc925ae6d867fbf8c50a7a00b19cf22b7b134a054369a7090
|
7
|
+
data.tar.gz: 2ded14bda849ec6ddaa405bc74469c821e45744c805ac5766f4ea5f66c05663212009e72605df0ce6b9f92959b20319e33f8c69a4c67cdbf33f37849623f57d1
|
@@ -26,7 +26,7 @@ private
|
|
26
26
|
.joins(:translation_key)
|
27
27
|
.includes(:translation_key)
|
28
28
|
.joins("LEFT JOIN handler_translations ON handler_translations.translation_key_id = translation_keys.id")
|
29
|
-
.where(
|
29
|
+
.where(handler_translations: {id: nil})
|
30
30
|
.where("translation_values.file_path LIKE '%/config/locales/awesome_translations/%'")
|
31
31
|
end
|
32
32
|
end
|
@@ -3,8 +3,15 @@ class AwesomeTranslations::CacheDatabaseGenerator::Group < BazaModels::Model
|
|
3
3
|
|
4
4
|
belongs_to :handler, class_name: "AwesomeTranslations::CacheDatabaseGenerator::Handler"
|
5
5
|
|
6
|
-
has_many :handler_translations,
|
7
|
-
|
6
|
+
has_many :handler_translations,
|
7
|
+
dependent: :destroy,
|
8
|
+
foreign_key: "group_id", # rubocop:disable Rails/RedundantForeignKey
|
9
|
+
class_name: "AwesomeTranslations::CacheDatabaseGenerator::HandlerTranslation"
|
10
|
+
|
11
|
+
has_many :translation_keys,
|
12
|
+
dependent: :destroy,
|
13
|
+
foreign_key: "group_id", # rubocop:disable Rails/RedundantForeignKey
|
14
|
+
class_name: "AwesomeTranslations::CacheDatabaseGenerator::TranslationKey"
|
8
15
|
|
9
16
|
validates_presence_of :name, :handler
|
10
17
|
|
@@ -1,6 +1,13 @@
|
|
1
1
|
class AwesomeTranslations::CacheDatabaseGenerator::Handler < BazaModels::Model
|
2
|
-
has_many :groups,
|
3
|
-
|
2
|
+
has_many :groups,
|
3
|
+
dependent: :destroy,
|
4
|
+
foreign_key: "handler_id", # rubocop:disable Rails/RedundantForeignKey
|
5
|
+
class_name: "AwesomeTranslations::CacheDatabaseGenerator::Group"
|
6
|
+
|
7
|
+
has_many :handler_translations,
|
8
|
+
dependent: :destroy,
|
9
|
+
foreign_key: "handler_id", # rubocop:disable Rails/RedundantForeignKey
|
10
|
+
class_name: "AwesomeTranslations::CacheDatabaseGenerator::HandlerTranslation"
|
4
11
|
|
5
12
|
validates_presence_of :name
|
6
13
|
|
@@ -1,7 +1,15 @@
|
|
1
1
|
class AwesomeTranslations::CacheDatabaseGenerator::HandlerTranslation < BazaModels::Model
|
2
|
-
belongs_to :group,
|
3
|
-
|
4
|
-
|
2
|
+
belongs_to :group,
|
3
|
+
foreign_key: "group_id", # rubocop:disable Rails/RedundantForeignKey
|
4
|
+
class_name: "AwesomeTranslations::CacheDatabaseGenerator::Group"
|
5
|
+
|
6
|
+
belongs_to :handler,
|
7
|
+
foreign_key: "handler_id", # rubocop:disable Rails/RedundantForeignKey
|
8
|
+
class_name: "AwesomeTranslations::CacheDatabaseGenerator::Handler"
|
9
|
+
|
10
|
+
belongs_to :translation_key,
|
11
|
+
foreign_key: "translation_key_id", # rubocop:disable Rails/RedundantForeignKey
|
12
|
+
class_name: "AwesomeTranslations::CacheDatabaseGenerator::TranslationKey"
|
5
13
|
|
6
14
|
validates_presence_of :handler, :translation_key
|
7
15
|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
class AwesomeTranslations::CacheDatabaseGenerator::TranslationKey < BazaModels::Model
|
2
|
-
belongs_to :group, foreign_key: "group_id"
|
3
|
-
belongs_to :handler, foreign_key: "handler_id"
|
2
|
+
belongs_to :group, foreign_key: "group_id" # rubocop:disable Rails/RedundantForeignKey
|
3
|
+
belongs_to :handler, foreign_key: "handler_id" # rubocop:disable Rails/RedundantForeignKey
|
4
4
|
|
5
5
|
has_many :handler_translations,
|
6
6
|
dependent: :destroy,
|
7
|
-
foreign_key: "translation_key_id",
|
7
|
+
foreign_key: "translation_key_id", # rubocop:disable Rails/RedundantForeignKey
|
8
8
|
class_name: "AwesomeTranslations::CacheDatabaseGenerator::HandlerTranslation"
|
9
9
|
|
10
10
|
has_many :translation_values,
|
11
11
|
dependent: :destroy,
|
12
|
-
foreign_key: "translation_key_id",
|
12
|
+
foreign_key: "translation_key_id", # rubocop:disable Rails/RedundantForeignKey
|
13
13
|
class_name: "AwesomeTranslations::CacheDatabaseGenerator::TranslationValue"
|
14
14
|
|
15
15
|
validates_presence_of :group, :handler
|
@@ -1,5 +1,7 @@
|
|
1
1
|
class AwesomeTranslations::CacheDatabaseGenerator::TranslationValue < BazaModels::Model
|
2
|
-
belongs_to :translation_key,
|
2
|
+
belongs_to :translation_key,
|
3
|
+
foreign_key: "translation_key_id", # rubocop:disable Rails/RedundantForeignKey
|
4
|
+
class_name: "AwesomeTranslations::CacheDatabaseGenerator::TranslationKey"
|
3
5
|
|
4
6
|
validates_presence_of :translation_key
|
5
7
|
|
@@ -50,19 +50,19 @@ class AwesomeTranslations::ErbInspector::FileInspector
|
|
50
50
|
private
|
51
51
|
|
52
52
|
def parse_content_liquid(line_no, line, translations_found, yielder)
|
53
|
-
line.scan(
|
53
|
+
line.scan(/"([^"]+?)"\s+\|\s+t\s*(%}|\}\}|\|)/) do |match|
|
54
54
|
add_translation(line_no, "t", match[0], translations_found, yielder)
|
55
55
|
end
|
56
56
|
|
57
|
-
line.scan(
|
57
|
+
line.scan(/'([^']+?)'\s+\|\s+t\s*(%}|\}\}|\|)/) do |match|
|
58
58
|
add_translation(line_no, "t", match[0], translations_found, yielder)
|
59
59
|
end
|
60
60
|
|
61
|
-
line.scan(
|
61
|
+
line.scan(/"([^"]+?)"\s+\|\s+val:\s*"([^"]+?)"\s*,\s*(.+?)\s*\|\s+t\s*/) do |match|
|
62
62
|
add_translation(line_no, "t", match[0], translations_found, yielder)
|
63
63
|
end
|
64
64
|
|
65
|
-
line.scan(/'([
|
65
|
+
line.scan(/'([^"]+?)'\s+\|\s+val:\s*'([^"]+?)'\s*,\s*(.+?)\s*\|\s+t\s*/) do |match|
|
66
66
|
add_translation(line_no, "t", match[0], translations_found, yielder)
|
67
67
|
end
|
68
68
|
end
|
@@ -27,7 +27,7 @@ class AwesomeTranslations::ErbInspector::TranslationInspector
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def global?
|
30
|
-
!relative? &&
|
30
|
+
!relative? && key.exclude?(".")
|
31
31
|
end
|
32
32
|
|
33
33
|
def relative?
|
@@ -49,16 +49,16 @@ private
|
|
49
49
|
is_mailer = true
|
50
50
|
elsif @full_key.start_with?("app/views/")
|
51
51
|
# Remove "app/views" from view-translations since that doesn't get used in keys.
|
52
|
-
@full_key.
|
52
|
+
@full_key.delete_prefix!("app/views/")
|
53
53
|
elsif @full_key.start_with?("app/controllers")
|
54
54
|
# Remove "app/controllers" from controller-translations since that doesn't get used in keys.
|
55
55
|
@full_key.gsub!(/\Aapp\/controllers(\/?)/, "")
|
56
56
|
is_controller = true
|
57
57
|
elsif @full_key.start_with?("app/cells")
|
58
|
-
@full_key.
|
58
|
+
@full_key.delete_prefix!("app/cells/")
|
59
59
|
elsif @full_key.start_with?("app/")
|
60
60
|
# Remove "app" from controller- and helper-translations since that doesn't get used.
|
61
|
-
@full_key.
|
61
|
+
@full_key.delete_prefix!("app/")
|
62
62
|
end
|
63
63
|
|
64
64
|
@full_key.tr!("/", ".")
|
@@ -66,7 +66,7 @@ private
|
|
66
66
|
@full_key << file_key(@file_path)
|
67
67
|
@full_key << ".#{@last_method}" if (is_mailer || is_controller) && @last_method && @method != "controller_t"
|
68
68
|
@full_key << "."
|
69
|
-
@full_key << @key.
|
69
|
+
@full_key << @key.delete_prefix(".")
|
70
70
|
elsif @method == "I18n-js.t" || @method == "t" || @method == "helper_t" || @method == "controller_t"
|
71
71
|
@full_key = @key
|
72
72
|
else
|
@@ -81,10 +81,10 @@ private
|
|
81
81
|
key = key.match(/\A(.+?)\./)[1]
|
82
82
|
|
83
83
|
# Remove leading "_" from partials
|
84
|
-
key
|
84
|
+
key.delete_prefix!("_")
|
85
85
|
|
86
86
|
# Remove '_controller' from controllers
|
87
|
-
key
|
87
|
+
key.delete_suffix!("_controller")
|
88
88
|
|
89
89
|
key
|
90
90
|
end
|
@@ -45,8 +45,8 @@ private
|
|
45
45
|
def dir
|
46
46
|
if @_dir.nil?
|
47
47
|
@_dir = File.dirname(previous_file)
|
48
|
-
@_dir
|
49
|
-
@_dir
|
48
|
+
@_dir.delete_prefix!("#{Rails.root}/") # rubocop:disable Rails/FilePath
|
49
|
+
@_dir.delete_prefix!("spec/dummy/")
|
50
50
|
|
51
51
|
if @_dir.starts_with?("app/controllers")
|
52
52
|
@_dir = @_dir.gsub(/\Aapp\/controllers(\/?)/, "")
|
@@ -54,7 +54,7 @@ private
|
|
54
54
|
elsif @_dir.starts_with?("app/views")
|
55
55
|
@_dir = @_dir.gsub(/\Aapp\/views(\/?)/, "")
|
56
56
|
elsif @_dir.starts_with?("app/")
|
57
|
-
@_dir
|
57
|
+
@_dir.delete_prefix!("app/")
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -95,7 +95,7 @@ private
|
|
95
95
|
|
96
96
|
def translation_key
|
97
97
|
translation_key = dir
|
98
|
-
translation_key = translation_key.
|
98
|
+
translation_key = translation_key.delete_prefix("app/")
|
99
99
|
translation_key << "/#{file}"
|
100
100
|
|
101
101
|
key_parts = translation_key.split("/")
|
@@ -23,11 +23,11 @@ class AwesomeTranslations::Handlers::ValidationsHandler < AwesomeTranslations::H
|
|
23
23
|
translations_for_format_validator(validator, model_inspector, attribute_name, yielder)
|
24
24
|
elsif validator.is_a?(ActiveRecord::Validations::UniquenessValidator)
|
25
25
|
translations_for_uniqueness_validator(validator, model_inspector, attribute_name, yielder)
|
26
|
-
elsif validator.class.name == "ActiveRecord::Validations::PresenceValidator"
|
26
|
+
elsif validator.class.name == "ActiveRecord::Validations::PresenceValidator" # rubocop:disable Style/ClassEqualityComparison:
|
27
27
|
translations_for_presence_validator(validator, model_inspector, attribute_name, yielder)
|
28
|
-
elsif validator.class.name == "EmailValidator"
|
28
|
+
elsif validator.class.name == "EmailValidator" # rubocop:disable Style/ClassEqualityComparison:
|
29
29
|
translations_for_email_validator(validator, model_inspector, attribute_name, yielder)
|
30
|
-
elsif validator.class.name == "ActiveModel::Validations::ConfirmationValidator"
|
30
|
+
elsif validator.class.name == "ActiveModel::Validations::ConfirmationValidator" # rubocop:disable Style/ClassEqualityComparison:
|
31
31
|
translations_for_confirmation_validator(validator, model_inspector, attribute_name, yielder)
|
32
32
|
else
|
33
33
|
Rails.logger.error "Unhandeled validator: #{validator.class.name}"
|
@@ -2,6 +2,7 @@ class AwesomeTranslations::ModelInspector
|
|
2
2
|
autoload :Attribute, "#{File.dirname(__FILE__)}/model_inspector/attribute"
|
3
3
|
|
4
4
|
attr_reader :clazz
|
5
|
+
|
5
6
|
cattr_accessor :models_loaded
|
6
7
|
|
7
8
|
# Yields a model-inspector for each model found in the application.
|
@@ -34,12 +35,10 @@ class AwesomeTranslations::ModelInspector
|
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
37
|
-
def paperclip_attachments
|
38
|
+
def paperclip_attachments(&blk)
|
38
39
|
return unless ::Kernel.const_defined?("Paperclip")
|
39
40
|
|
40
|
-
Paperclip::AttachmentRegistry.names_for(@clazz)
|
41
|
-
yield name
|
42
|
-
end
|
41
|
+
Paperclip::AttachmentRegistry.names_for(@clazz, &blk)
|
43
42
|
end
|
44
43
|
|
45
44
|
def money_attributes
|
@@ -75,10 +74,8 @@ class AwesomeTranslations::ModelInspector
|
|
75
74
|
end
|
76
75
|
|
77
76
|
# TODO: Maybe this should yield a ModelInspector::Relationship instead?
|
78
|
-
def relationships
|
79
|
-
@clazz.reflections.each
|
80
|
-
yield key, reflection
|
81
|
-
end
|
77
|
+
def relationships(&blk)
|
78
|
+
@clazz.reflections.each(&blk)
|
82
79
|
end
|
83
80
|
|
84
81
|
def attribute_key(attribute_name)
|
@@ -138,6 +135,6 @@ class AwesomeTranslations::ModelInspector
|
|
138
135
|
end
|
139
136
|
|
140
137
|
def self.active_storage_path?(model_path)
|
141
|
-
model_path.match?(/\/gems\/activestorage-([\d
|
138
|
+
model_path.match?(/\/gems\/activestorage-([\d.]+)\//)
|
142
139
|
end
|
143
140
|
end
|
data/spec/dummy/config.ru
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe AwesomeTranslations::MovalsController do
|
3
|
+
describe AwesomeTranslations::MovalsController do # rubocop:disable RSpec/MultipleMemoizedHelpers
|
4
4
|
let!(:handler_translation) do
|
5
5
|
create :handler_translation,
|
6
6
|
translation_key: translation_key,
|
@@ -34,7 +34,7 @@ describe AwesomeTranslations::MovalsController do
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
describe "#index" do
|
37
|
+
describe "#index" do # rubocop:disable RSpec/MultipleMemoizedHelpers
|
38
38
|
it "renders the page and shows the correct results" do
|
39
39
|
visit movals_path
|
40
40
|
|
@@ -49,7 +49,7 @@ describe AwesomeTranslations::MovalsController do
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
describe "#create" do
|
52
|
+
describe "#create" do # rubocop:disable RSpec/MultipleMemoizedHelpers
|
53
53
|
it "moves the checked translations to the right path" do
|
54
54
|
visit movals_path
|
55
55
|
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe AwesomeTranslations::Handlers::FileHandler do
|
4
4
|
let(:handler) { AwesomeTranslations::Handlers::FileHandler.new }
|
5
5
|
|
6
|
-
describe "erb stuff" do
|
6
|
+
describe "erb stuff" do # rubocop:disable RSpec/MultipleMemoizedHelpers
|
7
7
|
let(:users_index_group) { handler.groups.find { |group| group.name == "app/views/users/index.html.haml" } }
|
8
8
|
let(:users_index_translations) { users_index_group.translations }
|
9
9
|
let(:users_partial_test_translations) { handler.groups.find { |group| group.name == "app/views/users/_partial_test.html.erb" }.translations }
|
@@ -40,7 +40,7 @@ describe AwesomeTranslations::Handlers::FileHandler do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
describe "library stuff" do
|
43
|
+
describe "library stuff" do # rubocop:disable RSpec/MultipleMemoizedHelpers
|
44
44
|
let(:group) { handler.groups.find { |group| group.name == "app/models/role.rb" } }
|
45
45
|
let(:mailer_group) { handler.groups.find { |group| group.name == "app/mailers/my_mailer.rb" } }
|
46
46
|
let(:subject_translation) { mailer_group.translations.find { |translation| translation.key == "my_mailer.mailer_action.custom_subject" } }
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe AwesomeTranslations::Handlers::ModelHandler do
|
3
|
+
describe AwesomeTranslations::Handlers::ModelHandler do # rubocop:disable RSpec/MultipleMemoizedHelpers
|
4
4
|
let(:model_handler) { AwesomeTranslations::Handlers::ModelHandler.new }
|
5
5
|
let(:groups) { model_handler.groups.to_a }
|
6
6
|
let(:user_group) { model_handler.groups.detect { |group| group.name == "User" } }
|
@@ -12,7 +12,7 @@ describe AwesomeTranslations::Handlers::ModelHandler do
|
|
12
12
|
expect(groups.length).to eq 5
|
13
13
|
end
|
14
14
|
|
15
|
-
describe "#translations_for_group" do
|
15
|
+
describe "#translations_for_group" do # rubocop:disable RSpec/MultipleMemoizedHelpers
|
16
16
|
it "finds the right number of translations" do
|
17
17
|
expect(user_group.translations.to_a.length).to eq 7
|
18
18
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe AwesomeTranslations::ErbInspector::FileInspector do
|
3
|
+
describe AwesomeTranslations::ErbInspector::FileInspector do # rubocop:disable RSpec/MultipleMemoizedHelpers
|
4
4
|
let(:erb_inspector) do
|
5
5
|
AwesomeTranslations::ErbInspector.new(
|
6
6
|
dirs: [Rails.root.to_s]
|
@@ -15,7 +15,7 @@ describe AwesomeTranslations::ErbInspector::FileInspector do
|
|
15
15
|
let(:user_index_translations) { user_index_inspector.translations.to_a }
|
16
16
|
let(:hello_world_translation) { user_index_translations.find { |translation| translation.key == ".hello_world" } }
|
17
17
|
|
18
|
-
describe "#translations" do
|
18
|
+
describe "#translations" do # rubocop:disable RSpec/MultipleMemoizedHelpers
|
19
19
|
it "finds the right number of translations" do
|
20
20
|
expect(user_index_translations.length).to eq 3
|
21
21
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe AwesomeTranslations::ErbInspector::TranslationInspector do
|
3
|
+
describe AwesomeTranslations::ErbInspector::TranslationInspector do # rubocop:disable RSpec/MultipleMemoizedHelpers
|
4
4
|
let(:erb_inspector) do
|
5
5
|
AwesomeTranslations::ErbInspector.new(
|
6
6
|
dirs: [Rails.root.to_s]
|