translateable 0.1.6 → 0.1.7
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f532d4e856de601cd5491f34a2ec3be1c3cad351
|
4
|
+
data.tar.gz: c3186ae9e0a93a89af0364ee0dcd4174c476b086
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d27e0efb7b67fd8b27b155c0c6edcb4c09194352ed192c0aa255e3e43d3e5d03d22680afde3cea7a1e322c222519042d562114f14e8f1212d3ed95cd027cc6d
|
7
|
+
data.tar.gz: bde20ce10342ce1be1fba26a7de16574d8855382216c5b31524313265dd0d43467402b4bfdc2ac681ce4f3917a1759093c588791a7410861ca0d0f916e4196f8
|
data/.rubocop.yml
CHANGED
@@ -10,14 +10,17 @@ if defined?(Rails)
|
|
10
10
|
argument :field_name, type: :string
|
11
11
|
argument :locale, type: :string, default: I18n.default_locale
|
12
12
|
|
13
|
+
# rubocop: disable Metrics/AbcSize
|
13
14
|
def create_migration_file
|
14
15
|
raise ArgumentError, "given locale #{locale} is not available, check I18n.available_locales" unless I18n.available_locales.include?(locale.to_sym)
|
15
16
|
migration_template('migration.rb.erb', "db/migrate/migrate_translateable_#{name}_#{field_name}.rb",
|
16
17
|
migration_version: migration_version,
|
17
18
|
table_name: name,
|
18
19
|
field_name: field_name,
|
20
|
+
field_type: name.classify.constantize.columns_hash[field_name].type,
|
19
21
|
locale: locale)
|
20
22
|
end
|
23
|
+
# rubocop: enable Metrics/AbcSize
|
21
24
|
|
22
25
|
private
|
23
26
|
|
@@ -13,11 +13,13 @@ class MigrateTranslateable<%= table_name.camelize + field_name.camelize %> < Act
|
|
13
13
|
SQL
|
14
14
|
remove_column :<%= table_name %>, :<%= field_name %>
|
15
15
|
rename_column :<%= table_name %>, :<%= field_name + '_t' %>, :<%= field_name %>
|
16
|
+
<% if index_exists?(table_name, field_name) %>
|
16
17
|
add_index :<%= table_name %>, :<%= field_name %>, using: :gin
|
18
|
+
<% end %>
|
17
19
|
end
|
18
20
|
|
19
21
|
dir.down do
|
20
|
-
add_column :<%= table_name %>, :<%= field_name + '_t' %>, :string
|
22
|
+
add_column :<%= table_name %>, :<%= field_name + '_t' %>, <%= field_type || ':string' %>, null: false, default: ''
|
21
23
|
execute <<-SQL
|
22
24
|
UPDATE <%= table_name %> AS m1
|
23
25
|
SET <%= field_name + '_t' %> = (
|
@@ -26,7 +28,9 @@ class MigrateTranslateable<%= table_name.camelize + field_name.camelize %> < Act
|
|
26
28
|
SQL
|
27
29
|
remove_column :<%= table_name %>, :<%= field_name %>
|
28
30
|
rename_column :<%= table_name %>, :<%= field_name + '_t' %>, :<%= field_name %>
|
31
|
+
<% if index_exists?(table_name, field_name) %>
|
29
32
|
add_index :<%= table_name %>, :<%= field_name %>
|
33
|
+
<% end %>
|
30
34
|
end
|
31
35
|
end
|
32
36
|
end
|
data/translateable.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: translateable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleg Antonyan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|