translateable 0.1.4 → 0.1.5

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: 5f72e8b50b3719bb4620f612f3d802723c54ca78
4
- data.tar.gz: f1d37ecc104e3246da0dcb4ef69ead4e49de4799
3
+ metadata.gz: 9e12b39f79599cd0ee0824bd36c1dccc248af77f
4
+ data.tar.gz: fcd42bc9f98f5d28e02088be3b61771c7f627ccf
5
5
  SHA512:
6
- metadata.gz: 0ceb75373089abdf4117a0b981a878eb5b4ef73738b5000e1ebaa185aeb2834af891329fc56908b054085849fcd7a09974e8f6ab1832bd76d6bd47db21ee9b86
7
- data.tar.gz: d70a1d37d88c98ebae87ea395ad563154ae0770720825af35ca6af9dff5ae451fa1b65a391706e8fb92a80a770cfcab29160543a607697ed014e61c5982aa6d9
6
+ metadata.gz: a862624f81082209bc850a0e033c124983e2f1d01bfdb093beace015a9272a15a5138b3eb0afc08ac0cfaafbac815b79a8da108e8d9115f2808fd0af08d2d130
7
+ data.tar.gz: 4823cc44b1eaab551fcb820869b1a3f823ab17495c34583ba0c9f5b32a284a17f489e85ad36578734cab1b0d61baa0c012136b25825c1cf1fff82bff86742117
data/.rubocop.yml CHANGED
@@ -9,3 +9,7 @@ Style/Lambda:
9
9
 
10
10
  Style/FrozenStringLiteralComment:
11
11
  Enabled: false
12
+
13
+ Metrics/BlockLength:
14
+ Exclude:
15
+ - 'spec/**/*'
data/README.md CHANGED
@@ -147,7 +147,7 @@ Attributes must exist with `JSONB` type in a database, so create a migration:
147
147
  ```ruby
148
148
  class AddTitleToPosts < ActiveRecord::Migration
149
149
  def change
150
- add_column :posts, :title, :jsonb, null: false, default: '{}'
150
+ add_column :posts, :title, :jsonb, null: false, default: {}
151
151
  end
152
152
  end
153
153
  ```
data/lib/translateable.rb CHANGED
@@ -19,6 +19,7 @@ module Translateable
19
19
  end
20
20
 
21
21
  def translateable_sanity_check(attr)
22
+ return unless database_connection_exists?
22
23
  attr = attr.to_s
23
24
  raise ArgumentError, "no such column '#{attr}' in '#{name}' model" unless column_names.include?(attr)
24
25
  raise ArgumentError, "'#{attr}' column must be of JSONB type" unless columns_hash[attr].type.to_s.casecmp('jsonb').zero?
@@ -30,6 +31,12 @@ module Translateable
30
31
  end
31
32
  end
32
33
 
34
+ def database_connection_exists?
35
+ ActiveRecord::Base.connection_pool.with_connection(&:active?)
36
+ rescue
37
+ false
38
+ end
39
+
33
40
  # rubocop: disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
34
41
  def define_translateable_methods(attr)
35
42
  define_method("#{attr}_fetch_translateable") do
@@ -1,3 +1,3 @@
1
1
  module Translateable
2
- VERSION = '0.1.4'.freeze
2
+ VERSION = '0.1.5'.freeze
3
3
  end
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
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Antonyan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-20 00:00:00.000000000 Z
11
+ date: 2017-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  version: '0'
169
169
  requirements: []
170
170
  rubyforge_project:
171
- rubygems_version: 2.5.1
171
+ rubygems_version: 2.6.8
172
172
  signing_key:
173
173
  specification_version: 4
174
174
  summary: Allows to store text data in different languages.