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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/awesome_translations/clean_ups_controller.rb +1 -1
  3. data/lib/awesome_translations/cache_database_generator/group.rb +9 -2
  4. data/lib/awesome_translations/cache_database_generator/handler.rb +9 -2
  5. data/lib/awesome_translations/cache_database_generator/handler_translation.rb +11 -3
  6. data/lib/awesome_translations/cache_database_generator/translation_key.rb +4 -4
  7. data/lib/awesome_translations/cache_database_generator/translation_value.rb +3 -1
  8. data/lib/awesome_translations/erb_inspector/file_inspector.rb +4 -4
  9. data/lib/awesome_translations/erb_inspector/translation_inspector.rb +7 -7
  10. data/lib/awesome_translations/global_translator.rb +4 -4
  11. data/lib/awesome_translations/handlers/validations_handler.rb +3 -3
  12. data/lib/awesome_translations/model_inspector.rb +6 -9
  13. data/lib/awesome_translations/version.rb +1 -1
  14. data/spec/dummy/config.ru +1 -1
  15. data/spec/features/movals_spec.rb +3 -3
  16. data/spec/handlers/file_handler_spec.rb +2 -2
  17. data/spec/handlers/model_handler_spec.rb +2 -2
  18. data/spec/lib/erb_inspector/file_inspector_spec.rb +2 -2
  19. data/spec/lib/erb_inspector/translation_inspector_spec.rb +1 -1
  20. metadata +65 -169
  21. data/spec/dummy/db/awesome_translations.sqlite3 +0 -0
  22. data/spec/dummy/db/development.sqlite3 +0 -0
  23. data/spec/dummy/db/test.sqlite3 +0 -0
  24. data/spec/dummy/log/development.log +0 -79
  25. data/spec/dummy/log/test.log +0 -1910
  26. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/-o/-oFcVYifzG9CN5_s1hdowmNEkOY9nMkeYSN1wi8jK9k.cache +0 -0
  27. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/0-/0-1MiAUTzmkJ19QVNrjLw3HNw2Cu4279NlmUcUv0lnU.cache +0 -1
  28. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/1R/1RUC_iIhcuw4UJeKhOqLFN8264iDG1axfV3uVyPv0wg.cache +0 -1
  29. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/2m/2mnPY9uUnBNkGHLxtFaWv5hB3oA7sY2K1ZtwQlZLnAY.cache +0 -2
  30. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/3N/3NnKgR2TsTI1qCXKZpts0uJzp2dRJcoYp3nnFU6YE4o.cache +0 -2
  31. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/5U/5U8HCshUrO4uN8GT_N4K-MtrOiG-4cWdiepxNuvIjAw.cache +0 -1
  32. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/6y/6y2qhWDpnSTpsocv2lVSclXFxpCRU78VjU0sy2FGrWc.cache +0 -0
  33. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/8f/8f4REKYOWkNfHexyAVqGXnbOP3vky_ANapWzlRMDeQ4.cache +0 -3
  34. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/8p/8pzZq0f95KJrJtOmdr_19FPTeyHX3zMnw6Epsu3T_6c.cache +0 -1
  35. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/8x/8xTH_c2XZMdMXFHSjlUQD4pTAYTNqnrTrjDURs8jlFI.cache +0 -1
  36. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/AC/ACPB0Rs6DHQU6RIjgT-BODcpFLYUC_sPb9CvJGvg6ro.cache +0 -1
  37. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/AJ/AJ3ShPZKDgRfZy8niYD_tk4u0Ur5Y6oC85d-0oXgc3w.cache +0 -1
  38. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/AU/AUklJJKwz_vqy3TUoKDyB5ounU8pAqv6-_tES3aPoZ8.cache +0 -0
  39. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/CP/CPuNl6dzr9CzS_s74a_K5yuTPy1ch0_-ehTglX1zaEE.cache +0 -1
  40. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/CV/CVBUxdOogbkuDTae7pFS7i66HyowCSP07Os91LwRmHY.cache +0 -0
  41. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Ca/CaGQBiCuFgkHQ5gw8ZnGQqO8iP1md3GcllDsmaKBFdQ.cache +0 -2
  42. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Do/Do83AoOat5W-c1g7piDGy2GMmffsY6JY0Qfuh5PY3GM.cache +0 -2
  43. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/ER/EREGJziB-yMwOXwJeDrZ6Tie8HJU33_JSMXwzy7JsG4.cache +0 -0
  44. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Fc/FcJbnT7qHcLV5Zp_u7NV_yomOI9o9yG-F00bV0Gzm_Q.cache +0 -1
  45. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Mj/MjwYGG9GkHD1fwwH2bg66EBYl3zCA_mqeDF9otey4-U.cache +0 -3
  46. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/O6/O6K_G66TEscDh-j-DIIwfAqivslF8smPlcj9dJCvrh4.cache +0 -0
  47. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/O6/O6zA2BS4Y306Mmq4fuRnINim1pUdJgZvv_GJkGYXFxw.cache +0 -1
  48. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Ql/QlbxNnG-vjEDZ8GyOJHhNZY-GeHvDiuCj8IATbE9C8w.cache +0 -1
  49. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/S5/S57ilTeMjIW4abqhMiTmEi59zjS9uSXp697eO1D1Wjo.cache +0 -1
  50. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/S8/S86Mp1PRbiyejdN42WqWkRnoIoKRl4WoqM5lKxqw1w4.cache +0 -1
  51. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Sb/Sb1Vug319YfPL2Rci1PLMLXJjeIFYcNbHb5hKOvO1eo.cache +0 -2
  52. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/TC/TCAloV783-iAe72Q34cyIRfs-xPaNfSgPcPF2dl-zYI.cache +0 -0
  53. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Xn/Xn4epb06guWXnirWNYPta7ddzOkxd1aVDzRMoXp8pjM.cache +0 -1
  54. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/aa/aaoYFMRQGOYTpfFXf34S0CVVWaAJUx6s8QsSHm476OQ.cache +0 -1
  55. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/cK/cK9VEAGHFBzTxd0ICAK2Fv9RWWgiv9I6347by_BYm1w.cache +0 -0
  56. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/gc/gcjjMGVBrPIbM3oh-VsmXt-W8kWTs2Hc0sM2r5hicgQ.cache +0 -1
  57. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/hc/hc75Wwlo1W1FF6zeSSelZ-DXn-n6YkTrvq3_yoXpydw.cache +0 -0
  58. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/iF/iFAZApKjMydtC8Y6hvIXTy-zC2cfmbTrsYlU62u8sJU.cache +0 -1
  59. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/iR/iRIYdMKKwG2D6Tnj-0pGybHLEINmWZ8211nkI700-0Y.cache +0 -0
  60. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/l2/l2s6YvBxO6tXxM01zv13Dv6jpXaksukCd31VGPl6vPI.cache +0 -1
  61. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/mX/mXfx3VRudxpXrRx1aejtNA5YHOwND3kwWUfvdXHSors.cache +0 -2
  62. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/p7/p70iWC7uyeRLwIEniw-3RltmTZ-lz45IJdePewoXyHY.cache +0 -0
  63. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/pv/pv6tV3CDkIAmLXdU8EPLlNEkXAKJPufVD4VP30o4fWo.cache +0 -2
  64. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/q6/q6BYa32YJF11eGVapO4ouNl6gayPIsARgMavlzZmoi0.cache +0 -2
  65. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/qZ/qZ6ZFXF-wqwyHA2DvJW0tnnFPW-sRmoNY7ysyNfUdi0.cache +0 -1
  66. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/rH/rH2d5ogZr608pUvHYHKRlqMZTk7BNi8Qp5nL1PLrir8.cache +0 -0
  67. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/rI/rITk_65QtUwq61bjRPAksGeJxbLUFfz-sFPnQiZPHjw.cache +0 -3
  68. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/sH/sHqNaY2cQIVvwCv9thQRcI9KaeVjzBt9-dJ8mKnCKMk.cache +0 -0
  69. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/x7/x7KkTV3ibfIEysLB_ug5bfmnn2VLV_BldukPR3EoPBk.cache +0 -2
  70. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/xk/xkvAEoJDntdxUR56voDrW44MZ8Cx6i9WXQXrLDh2A_w.cache +0 -2
  71. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/za/zaxpzmSeETtWCbb5X2jLBDtr4Ei16ZUatImF5HE6Mpo.cache +0 -1
  72. 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: 630fd6805a59fe0e501a01e85fec405e0c74e969334a64183fd5e001a2a86f19
4
- data.tar.gz: c3e9fc60d2af9574536759378db9891ba6bb6297696e79357280f1fc2feddddc
3
+ metadata.gz: 55dac9259ef0eb5ae536764f8bd14c5df32277491c8aa478ee9160bef11efe2c
4
+ data.tar.gz: a74978683d4b38c71c3917d0c9e85ae7a11e28e177a0d941908fea9eabed0135
5
5
  SHA512:
6
- metadata.gz: 37c3afd48491b25cebe63b263454e32845548c1aca9ddcc6a9cadbfb1a116ce8aa74899a8084ab74770ab639ed01287fb91d1ca6e9913d3ef29fba845fe53325
7
- data.tar.gz: 7b612ecd73272de814ca2725fc10693468811ffddf6601f572da56718078b1f108ce3a7b7682ac05eafc4257a3b0a860f7eb6efa36c3c36fa304171a8f0375ff
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("handler_translations.id IS NULL")
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, dependent: :destroy, foreign_key: "group_id", class_name: "AwesomeTranslations::CacheDatabaseGenerator::HandlerTranslation"
7
- has_many :translation_keys, dependent: :destroy, foreign_key: "group_id", class_name: "AwesomeTranslations::CacheDatabaseGenerator::TranslationKey"
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, dependent: :destroy, foreign_key: "handler_id", class_name: "AwesomeTranslations::CacheDatabaseGenerator::Group"
3
- has_many :handler_translations, dependent: :destroy, foreign_key: "handler_id", class_name: "AwesomeTranslations::CacheDatabaseGenerator::HandlerTranslation"
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, foreign_key: "group_id", class_name: "AwesomeTranslations::CacheDatabaseGenerator::Group"
3
- belongs_to :handler, foreign_key: "handler_id", class_name: "AwesomeTranslations::CacheDatabaseGenerator::Handler"
4
- belongs_to :translation_key, foreign_key: "translation_key_id", class_name: "AwesomeTranslations::CacheDatabaseGenerator::TranslationKey"
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, foreign_key: "translation_key_id", class_name: "AwesomeTranslations::CacheDatabaseGenerator::TranslationKey"
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(/\"([^\"]+?)\"\s+\|\s+t\s*(\%}|\}\}|\|)/) do |match|
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(/\'([^\']+?)\'\s+\|\s+t\s*(\%}|\}\}|\|)/) do |match|
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(/\"([^\"]+?)\"\s+\|\s+val:\s*\"([^\"]+?)\"\s*,\s*(.+?)\s*\|\s+t\s*/) do |match|
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(/'([^\"]+?)'\s+\|\s+val:\s*'([^\"]+?)'\s*,\s*(.+?)\s*\|\s+t\s*/) do |match|
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? && !key.include?(".")
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.gsub!(/\Aapp\/views\//, "")
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.gsub!(/\Aapp\/cells\//, "")
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.gsub!(/\Aapp\//, "")
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.gsub(/\A\./, "")
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 = key.gsub(/\A_/, "")
84
+ key.delete_prefix!("_")
85
85
 
86
86
  # Remove '_controller' from controllers
87
- key = key.gsub(/_controller\Z/, "")
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 = @_dir.gsub(/\A#{Regexp.escape(Rails.root.to_s)}\//, "")
49
- @_dir = @_dir.gsub(/\Aspec\/dummy\//, "")
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 = @_dir.gsub(/\Aapp\//, "")
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.gsub(/\Aapp\//, "")
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).each do |name|
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 do |key, reflection|
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
@@ -1,3 +1,3 @@
1
1
  module AwesomeTranslations
2
- VERSION = "0.0.59".freeze
2
+ VERSION = "0.0.60".freeze
3
3
  end
data/spec/dummy/config.ru CHANGED
@@ -1,4 +1,4 @@
1
1
  # This file is used by Rack-based servers to start the application.
2
2
 
3
- require ::File.expand_path("../config/environment", __FILE__)
3
+ require ::File.expand_path("config/environment", __dir__)
4
4
  run Rails.application
@@ -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]