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: d1b16fe35bd81101c454ca2f2760bd1b218e7845
4
- data.tar.gz: a14be735671766c73ac204e925030ff0adabe4af
3
+ metadata.gz: f532d4e856de601cd5491f34a2ec3be1c3cad351
4
+ data.tar.gz: c3186ae9e0a93a89af0364ee0dcd4174c476b086
5
5
  SHA512:
6
- metadata.gz: 28488a5d4cf542fee24ea8246267531c0e7edf6cf4d7cff4204972b1023fc4cf9b3c63373af1fb245581a2fa2aa0eb1af8fe93de5df7faa04402b3cd46ac6f9a
7
- data.tar.gz: 3324e2f02da2f5d54b5af8a894b22ac3ed48da169045db6d08bc5d8a41a3444f024da80163c881f856c63e77231a18b357f544faf5413a000801a2bd493d1e43
6
+ metadata.gz: 0d27e0efb7b67fd8b27b155c0c6edcb4c09194352ed192c0aa255e3e43d3e5d03d22680afde3cea7a1e322c222519042d562114f14e8f1212d3ed95cd027cc6d
7
+ data.tar.gz: bde20ce10342ce1be1fba26a7de16574d8855382216c5b31524313265dd0d43467402b4bfdc2ac681ce4f3917a1759093c588791a7410861ca0d0f916e4196f8
data/.rubocop.yml CHANGED
@@ -10,6 +10,9 @@ Style/Lambda:
10
10
  Style/FrozenStringLiteralComment:
11
11
  Enabled: false
12
12
 
13
+ Style/PercentLiteralDelimiters:
14
+ Enabled: false
15
+
13
16
  Metrics/BlockLength:
14
17
  Exclude:
15
18
  - 'spec/**/*'
@@ -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, null: false, default: ''
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
@@ -1,3 +1,3 @@
1
1
  module Translateable
2
- VERSION = '0.1.6'.freeze
2
+ VERSION = '0.1.7'.freeze
3
3
  end
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'translateable/version'
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.6
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-04-13 00:00:00.000000000 Z
11
+ date: 2017-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler