rails_db_localize 0.0.2 → 0.0.3

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.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -0
  3. data/app/models/rails_db_localize/translation.rb +2 -10
  4. data/lib/ext/active_record_ext.rb +1 -1
  5. data/lib/ext/controller_ext.rb +1 -1
  6. data/lib/rails_db_localize/railtie.rb +5 -0
  7. data/lib/rails_db_localize/version.rb +1 -1
  8. data/lib/rails_db_localize.rb +7 -3
  9. data/lib/tasks/rails_db_localize_tasks.rake +31 -11
  10. metadata +5 -150
  11. data/test/dummy/README.rdoc +0 -28
  12. data/test/dummy/Rakefile +0 -6
  13. data/test/dummy/app/assets/javascripts/application.js +0 -13
  14. data/test/dummy/app/assets/javascripts/translatables.js +0 -2
  15. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  16. data/test/dummy/app/assets/stylesheets/translatables.css +0 -4
  17. data/test/dummy/app/controllers/application_controller.rb +0 -5
  18. data/test/dummy/app/controllers/translatables_controller.rb +0 -16
  19. data/test/dummy/app/helpers/application_helper.rb +0 -2
  20. data/test/dummy/app/helpers/translatables_helper.rb +0 -2
  21. data/test/dummy/app/models/translatable.rb +0 -3
  22. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  23. data/test/dummy/app/views/translatables/index.html.erb +0 -36
  24. data/test/dummy/bin/bundle +0 -3
  25. data/test/dummy/bin/rails +0 -4
  26. data/test/dummy/bin/rake +0 -4
  27. data/test/dummy/bin/setup +0 -29
  28. data/test/dummy/config/application.rb +0 -26
  29. data/test/dummy/config/boot.rb +0 -5
  30. data/test/dummy/config/database.yml +0 -25
  31. data/test/dummy/config/environment.rb +0 -5
  32. data/test/dummy/config/environments/development.rb +0 -41
  33. data/test/dummy/config/environments/production.rb +0 -79
  34. data/test/dummy/config/environments/test.rb +0 -42
  35. data/test/dummy/config/initializers/assets.rb +0 -11
  36. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  37. data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  38. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  39. data/test/dummy/config/initializers/inflections.rb +0 -16
  40. data/test/dummy/config/initializers/mime_types.rb +0 -4
  41. data/test/dummy/config/initializers/session_store.rb +0 -3
  42. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  43. data/test/dummy/config/locales/en.yml +0 -23
  44. data/test/dummy/config/routes.rb +0 -59
  45. data/test/dummy/config/secrets.yml +0 -22
  46. data/test/dummy/config.ru +0 -4
  47. data/test/dummy/db/development.sqlite3 +0 -0
  48. data/test/dummy/db/migrate/20150907053532_create_translation_table.rb +0 -5
  49. data/test/dummy/db/migrate/20150907053908_create_translatable.rb +0 -7
  50. data/test/dummy/db/schema.rb +0 -40
  51. data/test/dummy/lib/tasks/populate.rake +0 -11
  52. data/test/dummy/log/development.log +0 -12164
  53. data/test/dummy/public/404.html +0 -67
  54. data/test/dummy/public/422.html +0 -67
  55. data/test/dummy/public/500.html +0 -66
  56. data/test/dummy/public/favicon.ico +0 -0
  57. data/test/dummy/test/controllers/translatables_controller_test.rb +0 -7
  58. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/3O2pqsT3ybnPUm6Gi7ErjmLeCBRRUWz4fMCvw-ibCB0.cache +0 -2
  59. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +0 -2
  60. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/6qyNdZnWUudLJAOThY51h8UbkuubQ6d87qQokqr9_Io.cache +0 -0
  61. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/9yOpc3M6o_Vd_0RjCLTe8PJNtWsWGrV4zdvCJgbMtvw.cache +0 -0
  62. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/ANeC_6Mk_I5aOnvx2d-aSzot3B_oq6NBEI2K_mJEnWM.cache +0 -1
  63. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/BAArHgUaRCG_NHra3C0s9BRNUfg8e8yJC8Tw0wOKH-A.cache +0 -1
  64. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/B_ZbUByps36PvVRYHSdlhwdAtP5-Zf3zVtDzL-IQNrQ.cache +0 -2
  65. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/Cg8aXWizze0m2o4NT5ZriA69UfhbMK2hDD1D0oPK1JI.cache +0 -1
  66. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/DpdBg7WBC-mtsYWWSF3TjYyBBi-Evpi_ana2Hh_30LM.cache +0 -1
  67. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/ELlZNzycCi1-_hT_LCUVm1uUF65_XGNtAbDizvvphuA.cache +0 -1
  68. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/EzYy4pCO7n17PL8udZ40Mjw8k09nEOwcWk4Oi-a_Hwg.cache +0 -1
  69. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/NnJakuOJenyIjIygEryzdLDMdyyxVbseqRcdbkwnoAI.cache +0 -1
  70. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/O4S1k7_Y87AttftaL1s29JQtwbK4syBxZMLzIVuu1vk.cache +0 -0
  71. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +0 -2
  72. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/P3uTHiFsLRdy5tNIFjY3okQd6odvdpdGk6oogoFhoGk.cache +0 -0
  73. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/ZffU_0SbArG9GYeAowBJuJgaF1hVGbMNGeDIj9bqa9A.cache +0 -0
  74. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/c8KYVj1rHA3NliflfWZWsyCpCQAFkHuDTGW0GGTL0Bo.cache +0 -1
  75. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +0 -2
  76. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/iN2MkusZ4QURJ8-cxj-e7yLM4a1aqMS4VNwG63KkVZY.cache +0 -1
  77. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/lCUSCqZNMlgdamWEpHVlaxIHvpPKRbmiI3DgkCQqQRQ.cache +0 -2
  78. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/lZwz80GEq6cMAemaJYqRQdQbxAb92jM-0r0zq11lMxI.cache +0 -0
  79. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +0 -2
  80. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/vvbyKzG93brAbyVrZ7Q2gGUXUgcsVmB6eDpz25kvPFg.cache +0 -1
  81. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/znAAVScTWs7VUkicijSLxlPcvxUCnkiPoFshMXcE458.cache +0 -1
  82. data/test/rails_db_localize_test.rb +0 -7
  83. data/test/test_helper.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6dddf4c074ccd2e53d6ae27b8f6894b3036760a8
4
- data.tar.gz: 5093a12848cb94da0b88ffba1996f83de8bcfc82
3
+ metadata.gz: 0855f92777523618d4335e741efb90b8bc5c2fe4
4
+ data.tar.gz: acede288df13e639afeb15c1fcbb3dbf3e82f2cf
5
5
  SHA512:
6
- metadata.gz: 1a1b65ecb96440a0135817ed14dcb1a2560da07422d084007af852ba617ee994559586b0a5b01c05ee7d566ba8dd9d21386d29590b295f121425bdfc441dabd8
7
- data.tar.gz: fe7630b9035ac83ee4565bbcc71e12e00d14084e9cac2d121d707290a6b7b7fecbcaf56e30b6e62f6d72f9d5709fa175df315fda6c73a9aba6ca553bb3d9820a
6
+ metadata.gz: ccc2b2021f288fff616c15fe2c074322dddc77548ac3ef50119091f0c8f1ddc5b56e27c2181addf58e87c09eb552c3af523f73f31358ae3c0376e63414cbe7c4
7
+ data.tar.gz: aad994566c29fa328fd035d3716f246e3de6adde4ce5e0c4c2375997e98119a7ff44bfa0538855c14688d52f29868cb1c96ae08c270a06247c1b2446c2d0abcd
data/README.md CHANGED
@@ -121,6 +121,14 @@ Create two users with role translator with from/to_language "en/fr" and "fr/es".
121
121
 
122
122
  # Changelog
123
123
 
124
+ ## 0.3
125
+
126
+ * Fix issues inside the gem.
127
+
128
+ * Add the rake task rails_db_localize:delete_orphans
129
+
130
+ This task allow you to delete the old translations which not belongs to any model and/or belongs to a field/model which isn't existing anymore.
131
+
124
132
  ## 0.2
125
133
 
126
134
  Add methods `having_translation`, `missing_translation` and `preload_translation`
@@ -11,12 +11,11 @@ class RailsDbLocalize::Translation < ActiveRecord::Base
11
11
 
12
12
  validates :content, uniqueness: { scope: [:lang, :field, :resource_type, :resource_id] }
13
13
 
14
- scope :with_language, lambda { |x| where("lang LIKE ?", "#{x}%") }
14
+ scope :for_language, lambda { |x| where(lang: x) }
15
+ scope :for_model, lambda { |m| where(resource_type: m.class, resource_id: m.id) }
15
16
 
16
17
  before_validation :set_compound_key
17
18
 
18
-
19
-
20
19
  def self.generate_ck resource_type, resource_id
21
20
  hash_long = [resource_type.to_s.underscore, resource_id].join("|").chars.map(&:ord).inject(5381) do |h, v|
22
21
  h = ((h<<5)+h)+v
@@ -26,13 +25,6 @@ class RailsDbLocalize::Translation < ActiveRecord::Base
26
25
  hash_long & 0x7fffffff
27
26
  end
28
27
 
29
-
30
- def self.get_untranslated model, field, lang
31
- model.where("id NOT IN (?)",
32
- [-1, *RailsDbLocalize::Translation.where(resource_type: k.to_s, lang: lang, field: field).pluck(:resource_id).uniq]
33
- )
34
- end
35
-
36
28
  private
37
29
  def set_compound_key
38
30
  self.compound_key = RailsDbLocalize::Translation.generate_ck(resource_type, resource_id)
@@ -6,7 +6,7 @@ class ActiveRecord::Base
6
6
  unless @__rdbl_translations
7
7
  @__rdbl_translations = true
8
8
  # Register it mostly to remove the translations once you delete an object
9
- self.has_many :translations, as: :resource, dependent: :destroy
9
+ self.has_many :translations, class_name: "RailsDbLocalize::Translation", as: :resource, dependent: :destroy
10
10
 
11
11
  scope :__rails_db_translations_sub_query, lambda{ |lang|
12
12
  ttable = RailsDbLocalize::Translation.arel_table.name
@@ -6,7 +6,7 @@ class ActionController::Base
6
6
 
7
7
  # Preload the translations string for all the collections.
8
8
  # This allow to load all translation resources in only one SQL query.
9
- # Take in consideration this will execute the request for
9
+ # Take in consideration this will execute the request
10
10
  def preload_translations_for *collections
11
11
  RailsDbLocalize::TranslationCache.instance.prefetch_collections(*collections)
12
12
  end
@@ -0,0 +1,5 @@
1
+ class RailsDbLocalize::Railtie < Rails::Railtie
2
+ rake_tasks do
3
+ Dir[File.join(RailsDbLocalize::gem_path, "lib/tasks/*.rake")].each{ |f| load f }
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module RailsDbLocalize
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -10,8 +10,8 @@ module RailsDbLocalize
10
10
 
11
11
  def add_to_schema model, field
12
12
  @schema ||= {}
13
- @schema[model.to_s] ||= []
14
- @schema[model.to_s] << field
13
+ arr = (@schema[model.to_s] ||= [])
14
+ arr << field unless arr.index(field)
15
15
  end
16
16
 
17
17
  def load!
@@ -22,6 +22,10 @@ module RailsDbLocalize
22
22
  ActiveSupport::Dependencies.autoload_once_paths.delete(path)
23
23
  end
24
24
  end
25
+
26
+ def gem_path
27
+ @gem_path ||= File.expand_path("..", File.dirname(__FILE__))
28
+ end
25
29
  end
26
30
  end
27
31
 
@@ -32,6 +36,6 @@ def __rdbl_require(*args)
32
36
  end
33
37
 
34
38
  __rdbl_require 'rails_db_localize/translation_cache'
39
+ __rdbl_require 'rails_db_localize/railtie'
35
40
  __rdbl_require 'ext/active_record_ext', 'ext/controller_ext', 'ext/migration_ext'
36
-
37
41
  RailsDbLocalize::load!
@@ -1,11 +1,31 @@
1
- # desc "Explaining what the task does"
2
- # task :rails_db_localize do
3
- # # Task goes here
4
- # end
5
-
6
- #namespace :rails_db_localize do
7
- # desc "Remove the orphans in the translations"
8
- # task :delete_orphans => :environment do
9
- # raise "TODO"
10
- # end
11
- #end
1
+ namespace :rails_db_localize do
2
+ desc "Remove the orphans in the translations"
3
+ task :delete_orphans => :environment do
4
+
5
+ # Preload all the models for building the schema.
6
+ # Only useful for development mode when the models are autoloaded.
7
+ RailsDbLocalize::Translation.group(:resource_type).pluck(:resource_type).each do |rt|
8
+ begin
9
+ rt.classify.constantize
10
+ rescue
11
+ puts "Cannot constantize `#{rt}`"
12
+ end
13
+ end
14
+
15
+ #Now we have an updated schema,
16
+ # we can remove illegal keys and illegal ids
17
+ to_delete = RailsDbLocalize::Translation
18
+ .where("resource_type NOT IN (?)", [-1, *RailsDbLocalize.schema.keys])
19
+
20
+ RailsDbLocalize.schema.each do |klass, field_list|
21
+ klass = klass.classify.constantize
22
+ to_delete += RailsDbLocalize::Translation
23
+ .where("resource_type =? AND ( field NOT IN (?) OR resource_id NOT IN (?) )",
24
+ klass, [-1, *field_list],
25
+ klass.pluck(klass.primary_key))
26
+ end
27
+
28
+ puts "REMOVED ORPHANS: #{to_delete.count}"
29
+ to_delete.each(&:destroy)
30
+ end
31
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_db_localize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yacine PETITPREZ
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-07 00:00:00.000000000 Z
11
+ date: 2015-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -96,82 +96,10 @@ files:
96
96
  - lib/ext/controller_ext.rb
97
97
  - lib/ext/migration_ext.rb
98
98
  - lib/rails_db_localize.rb
99
+ - lib/rails_db_localize/railtie.rb
99
100
  - lib/rails_db_localize/translation_cache.rb
100
101
  - lib/rails_db_localize/version.rb
101
102
  - lib/tasks/rails_db_localize_tasks.rake
102
- - test/dummy/README.rdoc
103
- - test/dummy/Rakefile
104
- - test/dummy/app/assets/javascripts/application.js
105
- - test/dummy/app/assets/javascripts/translatables.js
106
- - test/dummy/app/assets/stylesheets/application.css
107
- - test/dummy/app/assets/stylesheets/translatables.css
108
- - test/dummy/app/controllers/application_controller.rb
109
- - test/dummy/app/controllers/translatables_controller.rb
110
- - test/dummy/app/helpers/application_helper.rb
111
- - test/dummy/app/helpers/translatables_helper.rb
112
- - test/dummy/app/models/translatable.rb
113
- - test/dummy/app/views/layouts/application.html.erb
114
- - test/dummy/app/views/translatables/index.html.erb
115
- - test/dummy/bin/bundle
116
- - test/dummy/bin/rails
117
- - test/dummy/bin/rake
118
- - test/dummy/bin/setup
119
- - test/dummy/config.ru
120
- - test/dummy/config/application.rb
121
- - test/dummy/config/boot.rb
122
- - test/dummy/config/database.yml
123
- - test/dummy/config/environment.rb
124
- - test/dummy/config/environments/development.rb
125
- - test/dummy/config/environments/production.rb
126
- - test/dummy/config/environments/test.rb
127
- - test/dummy/config/initializers/assets.rb
128
- - test/dummy/config/initializers/backtrace_silencers.rb
129
- - test/dummy/config/initializers/cookies_serializer.rb
130
- - test/dummy/config/initializers/filter_parameter_logging.rb
131
- - test/dummy/config/initializers/inflections.rb
132
- - test/dummy/config/initializers/mime_types.rb
133
- - test/dummy/config/initializers/session_store.rb
134
- - test/dummy/config/initializers/wrap_parameters.rb
135
- - test/dummy/config/locales/en.yml
136
- - test/dummy/config/routes.rb
137
- - test/dummy/config/secrets.yml
138
- - test/dummy/db/development.sqlite3
139
- - test/dummy/db/migrate/20150907053532_create_translation_table.rb
140
- - test/dummy/db/migrate/20150907053908_create_translatable.rb
141
- - test/dummy/db/schema.rb
142
- - test/dummy/lib/tasks/populate.rake
143
- - test/dummy/log/development.log
144
- - test/dummy/public/404.html
145
- - test/dummy/public/422.html
146
- - test/dummy/public/500.html
147
- - test/dummy/public/favicon.ico
148
- - test/dummy/test/controllers/translatables_controller_test.rb
149
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/3O2pqsT3ybnPUm6Gi7ErjmLeCBRRUWz4fMCvw-ibCB0.cache
150
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache
151
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/6qyNdZnWUudLJAOThY51h8UbkuubQ6d87qQokqr9_Io.cache
152
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/9yOpc3M6o_Vd_0RjCLTe8PJNtWsWGrV4zdvCJgbMtvw.cache
153
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/ANeC_6Mk_I5aOnvx2d-aSzot3B_oq6NBEI2K_mJEnWM.cache
154
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/BAArHgUaRCG_NHra3C0s9BRNUfg8e8yJC8Tw0wOKH-A.cache
155
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/B_ZbUByps36PvVRYHSdlhwdAtP5-Zf3zVtDzL-IQNrQ.cache
156
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/Cg8aXWizze0m2o4NT5ZriA69UfhbMK2hDD1D0oPK1JI.cache
157
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/DpdBg7WBC-mtsYWWSF3TjYyBBi-Evpi_ana2Hh_30LM.cache
158
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/ELlZNzycCi1-_hT_LCUVm1uUF65_XGNtAbDizvvphuA.cache
159
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/EzYy4pCO7n17PL8udZ40Mjw8k09nEOwcWk4Oi-a_Hwg.cache
160
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/NnJakuOJenyIjIygEryzdLDMdyyxVbseqRcdbkwnoAI.cache
161
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/O4S1k7_Y87AttftaL1s29JQtwbK4syBxZMLzIVuu1vk.cache
162
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache
163
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/P3uTHiFsLRdy5tNIFjY3okQd6odvdpdGk6oogoFhoGk.cache
164
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/ZffU_0SbArG9GYeAowBJuJgaF1hVGbMNGeDIj9bqa9A.cache
165
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/c8KYVj1rHA3NliflfWZWsyCpCQAFkHuDTGW0GGTL0Bo.cache
166
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache
167
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/iN2MkusZ4QURJ8-cxj-e7yLM4a1aqMS4VNwG63KkVZY.cache
168
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/lCUSCqZNMlgdamWEpHVlaxIHvpPKRbmiI3DgkCQqQRQ.cache
169
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/lZwz80GEq6cMAemaJYqRQdQbxAb92jM-0r0zq11lMxI.cache
170
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache
171
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/vvbyKzG93brAbyVrZ7Q2gGUXUgcsVmB6eDpz25kvPFg.cache
172
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/znAAVScTWs7VUkicijSLxlPcvxUCnkiPoFshMXcE458.cache
173
- - test/rails_db_localize_test.rb
174
- - test/test_helper.rb
175
103
  homepage: https://github.com/anykeyh/rails_db_localize
176
104
  licenses:
177
105
  - APACHE 2.0
@@ -195,78 +123,5 @@ rubyforge_project:
195
123
  rubygems_version: 2.4.8
196
124
  signing_key:
197
125
  specification_version: 4
198
- summary: Gem for managing translations of database objects without any pain.
199
- test_files:
200
- - test/dummy/app/assets/javascripts/application.js
201
- - test/dummy/app/assets/javascripts/translatables.js
202
- - test/dummy/app/assets/stylesheets/application.css
203
- - test/dummy/app/assets/stylesheets/translatables.css
204
- - test/dummy/app/controllers/application_controller.rb
205
- - test/dummy/app/controllers/translatables_controller.rb
206
- - test/dummy/app/helpers/application_helper.rb
207
- - test/dummy/app/helpers/translatables_helper.rb
208
- - test/dummy/app/models/translatable.rb
209
- - test/dummy/app/views/layouts/application.html.erb
210
- - test/dummy/app/views/translatables/index.html.erb
211
- - test/dummy/bin/bundle
212
- - test/dummy/bin/rails
213
- - test/dummy/bin/rake
214
- - test/dummy/bin/setup
215
- - test/dummy/config/application.rb
216
- - test/dummy/config/boot.rb
217
- - test/dummy/config/database.yml
218
- - test/dummy/config/environment.rb
219
- - test/dummy/config/environments/development.rb
220
- - test/dummy/config/environments/production.rb
221
- - test/dummy/config/environments/test.rb
222
- - test/dummy/config/initializers/assets.rb
223
- - test/dummy/config/initializers/backtrace_silencers.rb
224
- - test/dummy/config/initializers/cookies_serializer.rb
225
- - test/dummy/config/initializers/filter_parameter_logging.rb
226
- - test/dummy/config/initializers/inflections.rb
227
- - test/dummy/config/initializers/mime_types.rb
228
- - test/dummy/config/initializers/session_store.rb
229
- - test/dummy/config/initializers/wrap_parameters.rb
230
- - test/dummy/config/locales/en.yml
231
- - test/dummy/config/routes.rb
232
- - test/dummy/config/secrets.yml
233
- - test/dummy/config.ru
234
- - test/dummy/db/development.sqlite3
235
- - test/dummy/db/migrate/20150907053532_create_translation_table.rb
236
- - test/dummy/db/migrate/20150907053908_create_translatable.rb
237
- - test/dummy/db/schema.rb
238
- - test/dummy/lib/tasks/populate.rake
239
- - test/dummy/log/development.log
240
- - test/dummy/public/404.html
241
- - test/dummy/public/422.html
242
- - test/dummy/public/500.html
243
- - test/dummy/public/favicon.ico
244
- - test/dummy/Rakefile
245
- - test/dummy/README.rdoc
246
- - test/dummy/test/controllers/translatables_controller_test.rb
247
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/3O2pqsT3ybnPUm6Gi7ErjmLeCBRRUWz4fMCvw-ibCB0.cache
248
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache
249
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/6qyNdZnWUudLJAOThY51h8UbkuubQ6d87qQokqr9_Io.cache
250
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/9yOpc3M6o_Vd_0RjCLTe8PJNtWsWGrV4zdvCJgbMtvw.cache
251
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/ANeC_6Mk_I5aOnvx2d-aSzot3B_oq6NBEI2K_mJEnWM.cache
252
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/B_ZbUByps36PvVRYHSdlhwdAtP5-Zf3zVtDzL-IQNrQ.cache
253
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/BAArHgUaRCG_NHra3C0s9BRNUfg8e8yJC8Tw0wOKH-A.cache
254
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/c8KYVj1rHA3NliflfWZWsyCpCQAFkHuDTGW0GGTL0Bo.cache
255
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/Cg8aXWizze0m2o4NT5ZriA69UfhbMK2hDD1D0oPK1JI.cache
256
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/DpdBg7WBC-mtsYWWSF3TjYyBBi-Evpi_ana2Hh_30LM.cache
257
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/ELlZNzycCi1-_hT_LCUVm1uUF65_XGNtAbDizvvphuA.cache
258
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/EzYy4pCO7n17PL8udZ40Mjw8k09nEOwcWk4Oi-a_Hwg.cache
259
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache
260
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/iN2MkusZ4QURJ8-cxj-e7yLM4a1aqMS4VNwG63KkVZY.cache
261
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/lCUSCqZNMlgdamWEpHVlaxIHvpPKRbmiI3DgkCQqQRQ.cache
262
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/lZwz80GEq6cMAemaJYqRQdQbxAb92jM-0r0zq11lMxI.cache
263
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/NnJakuOJenyIjIygEryzdLDMdyyxVbseqRcdbkwnoAI.cache
264
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/O4S1k7_Y87AttftaL1s29JQtwbK4syBxZMLzIVuu1vk.cache
265
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache
266
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/P3uTHiFsLRdy5tNIFjY3okQd6odvdpdGk6oogoFhoGk.cache
267
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache
268
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/vvbyKzG93brAbyVrZ7Q2gGUXUgcsVmB6eDpz25kvPFg.cache
269
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/ZffU_0SbArG9GYeAowBJuJgaF1hVGbMNGeDIj9bqa9A.cache
270
- - test/dummy/tmp/cache/assets/development/sprockets/v3.0/znAAVScTWs7VUkicijSLxlPcvxUCnkiPoFshMXcE458.cache
271
- - test/rails_db_localize_test.rb
272
- - test/test_helper.rb
126
+ summary: Manage database translations without any pain.
127
+ test_files: []
@@ -1,28 +0,0 @@
1
- == README
2
-
3
- This README would normally document whatever steps are necessary to get the
4
- application up and running.
5
-
6
- Things you may want to cover:
7
-
8
- * Ruby version
9
-
10
- * System dependencies
11
-
12
- * Configuration
13
-
14
- * Database creation
15
-
16
- * Database initialization
17
-
18
- * How to run the test suite
19
-
20
- * Services (job queues, cache servers, search engines, etc.)
21
-
22
- * Deployment instructions
23
-
24
- * ...
25
-
26
-
27
- Please feel free to use a different markup language if you do not plan to run
28
- <tt>rake doc:app</tt>.
data/test/dummy/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require File.expand_path('../config/application', __FILE__)
5
-
6
- Rails.application.load_tasks
@@ -1,13 +0,0 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file.
9
- //
10
- // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require_tree .
@@ -1,2 +0,0 @@
1
- // Place all the behaviors and hooks related to the matching controller here.
2
- // All this logic will automatically be available in application.js.
@@ -1,15 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any styles
10
- * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
- * file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
@@ -1,4 +0,0 @@
1
- /*
2
- Place all the styles related to the matching controller here.
3
- They will automatically be included in application.css.
4
- */
@@ -1,5 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- # Prevent CSRF attacks by raising an exception.
3
- # For APIs, you may want to use :null_session instead.
4
- protect_from_forgery with: :exception
5
- end
@@ -1,16 +0,0 @@
1
- class TranslatablesController < ApplicationController
2
- def index
3
- @translatables = Translatable.all
4
- preload_translations_for(@translatables)
5
- end
6
-
7
- def set_tr
8
- require 'faker'
9
-
10
- @translatable = Translatable.find(params[:id])
11
- @translatable.name_translated = Faker::Lorem.paragraph, params[:lang]
12
- @translatable.save!
13
-
14
- redirect_to "/"
15
- end
16
- end
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,2 +0,0 @@
1
- module TranslatablesHelper
2
- end
@@ -1,3 +0,0 @@
1
- class Translatable < ActiveRecord::Base
2
- has_translations :name
3
- end
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
- <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
@@ -1,36 +0,0 @@
1
- <div>
2
- <h1>Test Translatable</h1>
3
- <h2>Schema:</h2>
4
- <pre>
5
- <%= RailsDbLocalize::schema.inspect %>
6
- </pre>
7
- <h2>TR Table:</h2>
8
- <pre><%= RailsDbLocalize::Translation.all.pluck(:id, :compound_key, :field, :lang, :content).map{|x| x.inspect}.join("\n") %></pre>
9
- <h2>Cache info:</h2>
10
- <pre><%= RailsDbLocalize::TranslationCache.instance.cache %></pre>
11
- <h2>Table info:</h2>
12
- <table>
13
- <thead>
14
- <th>ID</th>
15
- <th>Name</th>
16
- <th>TR EN</th>
17
- <th>TR ES</th>
18
- <th>TR FR</th>
19
- <th>Actions</th>
20
- </thead>
21
- <% @translatables.each do |t| %>
22
- <tr>
23
- <td><%= t.id %></td>
24
- <td><%= t.name %></td>
25
- <td><%= t.name_translated %></td>
26
- <td><%= t.name_translated(:es) %></td>
27
- <td><%= t.name_translated(:fr) %></td>
28
- <td>
29
- <a href="/set_tr/<%=t.id%>/en">GEN EN</a>
30
- <a href="/set_tr/<%=t.id%>/es">GEN ES</a>
31
- <a href="/set_tr/<%=t.id%>/fr">GEN FR</a>
32
- </td>
33
- </tr>
34
- <% end %>
35
- </table>
36
- </div>
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
- load Gem.bin_path('bundler', 'bundle')
data/test/dummy/bin/rails DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
3
- require_relative '../config/boot'
4
- require 'rails/commands'
data/test/dummy/bin/rake DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require_relative '../config/boot'
3
- require 'rake'
4
- Rake.application.run
data/test/dummy/bin/setup DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'pathname'
3
-
4
- # path to your application root.
5
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
-
7
- Dir.chdir APP_ROOT do
8
- # This script is a starting point to setup your application.
9
- # Add necessary setup steps to this file:
10
-
11
- puts "== Installing dependencies =="
12
- system "gem install bundler --conservative"
13
- system "bundle check || bundle install"
14
-
15
- # puts "\n== Copying sample files =="
16
- # unless File.exist?("config/database.yml")
17
- # system "cp config/database.yml.sample config/database.yml"
18
- # end
19
-
20
- puts "\n== Preparing database =="
21
- system "bin/rake db:setup"
22
-
23
- puts "\n== Removing old logs and tempfiles =="
24
- system "rm -f log/*"
25
- system "rm -rf tmp/cache"
26
-
27
- puts "\n== Restarting application server =="
28
- system "touch tmp/restart.txt"
29
- end
@@ -1,26 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require 'rails/all'
4
-
5
- Bundler.require(*Rails.groups)
6
- require "rails_db_localize"
7
-
8
- module Dummy
9
- class Application < Rails::Application
10
- # Settings in config/environments/* take precedence over those specified here.
11
- # Application configuration should go into files in config/initializers
12
- # -- all .rb files in that directory are automatically loaded.
13
-
14
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
- # config.time_zone = 'Central Time (US & Canada)'
17
-
18
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
- # config.i18n.default_locale = :de
21
-
22
- # Do not swallow errors in after_commit/after_rollback callbacks.
23
- config.active_record.raise_in_transactional_callbacks = true
24
- end
25
- end
26
-
@@ -1,5 +0,0 @@
1
- # Set up gems listed in the Gemfile.
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
-
4
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,25 +0,0 @@
1
- # SQLite version 3.x
2
- # gem install sqlite3
3
- #
4
- # Ensure the SQLite 3 gem is defined in your Gemfile
5
- # gem 'sqlite3'
6
- #
7
- default: &default
8
- adapter: sqlite3
9
- pool: 5
10
- timeout: 5000
11
-
12
- development:
13
- <<: *default
14
- database: db/development.sqlite3
15
-
16
- # Warning: The database defined as "test" will be erased and
17
- # re-generated from your development database when you run "rake".
18
- # Do not set this db to the same as development or production.
19
- test:
20
- <<: *default
21
- database: db/test.sqlite3
22
-
23
- production:
24
- <<: *default
25
- database: db/production.sqlite3
@@ -1,5 +0,0 @@
1
- # Load the Rails application.
2
- require File.expand_path('../application', __FILE__)
3
-
4
- # Initialize the Rails application.
5
- Rails.application.initialize!