traco 3.1.4 → 3.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzMxZDEzNjdmODYxYjJmNWVkOGUxNzI4YWYwNjE0Zjc2OTE1OWIzNw==
4
+ NWNlZTU1ZDRiYjcwMzUwMTY0YWVhOGJjM2IwNTEwMjU1Y2ZhNWU3NQ==
5
5
  data.tar.gz: !binary |-
6
- NjFmNjBhMDFhYzFhODgzYjkzYmFiYzJjZWQ4YzhlMTc0MTc1YWVkOQ==
6
+ MTQwZGExYWQ2NTNjNjcxN2Q0OGEyNWIyMmI4YTJmMTUyODhiYWFlYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmNkMjExZjYwODBlOGIyMWU1ODhhNmI4NTRkMjIxNjY3M2ZlYTUxZjdhZTQ5
10
- ZDU0MjJjNWRkZWFjZGZlMjg3ZDE1ZGVkZjY1NmNlZTk1ZTk5NTVmNmY3N2Mx
11
- NzYzYzE2ZmZlNDkzYTg1ZWJkNzkyNWMwMTQ2NWMzNWRmNDIwMjk=
9
+ ODM0MDIwNTJiOWM4ODcwMGYyMmU3YWEyNzg5ZWMwN2ExMTRkMGUxZDFhZGVm
10
+ M2JmMmEzNWFlMjlhYjE0NWNmNzIxNmNlYmQ1MzI3OWM2Y2ZkN2MzMzhlODdm
11
+ MmQxZTY2MjVkZjc3Nzc2M2IzMGY2MWExOGMwN2FjNzUyNzVmODM=
12
12
  data.tar.gz: !binary |-
13
- NDAxNjQ0NjM4NWY2ODcxYmFmZjA5ZTVlOTRkZTAwZjY4NDRjNGNhMGNmOTE4
14
- NGE4NTQwYTFlODYzYjVhMDgzNWMwNTZlZmNkMjYzMjFjNTdjMTFlMmE0ODMy
15
- MTA3OTMzZmIwMDkxMzYyZDcyZTIxNjE2NWQyMDBlYzNhYWVkYmI=
13
+ ZDkwN2E4NDg2YWQzODY1NDYwZjEwMGVmYmIxY2M3MzYwODc0Y2IyNjRkODVl
14
+ MDNmMmVkOGM5MzYxOTZjM2YzMzgxY2ZlZjZiZjQ2MmRlNzExZjJjZDJlNDI0
15
+ Njg1YWFiMjk0ZjFiZjk2YTkwMjdhMDFjYjNhNjM1OGQ3ZDBkNzg=
data/CHANGELOG.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.1.5
4
+
5
+ * Bugfix: don't raise error loading models before the DB is created. Thanks to PikachuEXE and Andrii Malyshko.
6
+
3
7
  ## 3.1.4
4
8
 
5
- * Bugfix: restore sorting of `locale_columns` and `locales_for_attribute` to put default locale first, not current locale. Thanks to Leung Ho Kuen.
9
+ * Bugfix: restore sorting of `locale_columns` and `locales_for_attribute` to put default locale first, not current locale. Thanks to PikachuEXE.
6
10
 
7
11
  ## 3.1.3
8
12
 
@@ -12,11 +16,11 @@
12
16
 
13
17
  ## 3.1.2
14
18
 
15
- * Bugfix: `.current_locale_column` handles dashed locales like "pt-BR" correctly. Thanks to Leung Ho Kuen.
19
+ * Bugfix: `.current_locale_column` handles dashed locales like "pt-BR" correctly. Thanks to PikachuEXE.
16
20
 
17
21
  ## 3.1.1
18
22
 
19
- * Bugfix around fallbacks and memoization. Thanks to Leung Ho Kuen.
23
+ * Bugfix around fallbacks and memoization. Thanks to PikachuEXE.
20
24
 
21
25
  ## 3.1.0
22
26
 
data/README.md CHANGED
@@ -162,7 +162,7 @@ Possible improvements to make:
162
162
  * Tobias Bohwalli
163
163
  * Mario Alberto Chavez
164
164
  * Philip Arndt
165
- * Leung Ho Kuen
165
+ * [PikachuEXE](https://github.com/PikachuEXE)
166
166
  * Fernando Morgenstern
167
167
  * Tomáš Horáček
168
168
  * Joakim Kolsjö
@@ -14,8 +14,6 @@ module Traco
14
14
  self.class.ensure_translatable_attributes(base)
15
15
  base.translatable_attributes |= @attributes
16
16
 
17
- self.class.warm_up_activerecord_methods(base)
18
-
19
17
  base.extend ClassMethods
20
18
  end
21
19
 
@@ -58,14 +56,5 @@ module Traco
58
56
  base.class_attribute :translatable_attributes
59
57
  base.translatable_attributes = []
60
58
  end
61
-
62
- # Force AR to create methods `title_en` etc, which are lazily evaluated,
63
- # otherwise we can't safely check `.instance_methods`.
64
- def self.warm_up_activerecord_methods(base)
65
- random_attribute = base.translatable_attributes.first
66
-
67
- instance = base.new
68
- instance.send(Traco.column(random_attribute, I18n.default_locale))
69
- end
70
59
  end
71
60
  end
@@ -58,11 +58,18 @@ module Traco
58
58
  per_attribute_cache = per_locale_cache[attribute] ||= {}
59
59
 
60
60
  per_attribute_cache[fallback] ||= begin
61
+ # AR methods are lazily evaluated, so we must use `instance.respond_to?(column)` rather
62
+ # than `instance_methods.include?(column)`.
63
+ #
64
+ # We previously forced AR to evaluate them, but that caused issues before the DB existed,
65
+ # e.g. running `rake db:create`.
66
+ instance = new
67
+
61
68
  locales_to_try = Traco.locale_with_fallbacks(I18n.locale, fallback)
62
69
 
63
70
  locales_to_try.each_with_object({}) do |locale, columns|
64
71
  column = Traco.column(attribute, locale)
65
- columns[locale] = column if instance_methods.include?(column)
72
+ columns[locale] = column if instance.respond_to?(column)
66
73
  end
67
74
  end
68
75
  end
data/lib/traco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Traco
2
- VERSION = "3.1.4"
2
+ VERSION = "3.1.5"
3
3
  end
@@ -1,8 +1,8 @@
1
1
  RSpec.configure do |config|
2
2
  config.before(:each) do
3
3
  # Clear class state before each spec.
4
- Object.send(:remove_const, 'Post')
5
- Object.send(:remove_const, 'SubPost')
4
+ Object.send(:remove_const, "Post")
5
+ Object.send(:remove_const, "SubPost")
6
6
  load "app/post.rb"
7
7
 
8
8
  # Known state.
data/spec/traco_spec.rb CHANGED
@@ -8,11 +8,11 @@ describe Traco, ".split_localized_column" do
8
8
  subject { described_class }
9
9
 
10
10
  it "returns attribute and locale" do
11
- expect(subject.split_localized_column("title_sv")).to eq [:title, :sv]
11
+ expect(subject.split_localized_column("title_sv")).to eq [ :title, :sv ]
12
12
  end
13
13
 
14
14
  it "handles normalized locales" do
15
- expect(subject.split_localized_column("title_pt_br")).to eq [:title, :"pt-BR"]
15
+ expect(subject.split_localized_column("title_pt_br")).to eq [ :title, :"pt-BR" ]
16
16
  end
17
17
 
18
18
  it "returns nil if column is not localized" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traco
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.4
4
+ version: 3.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Nyh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-13 00:00:00.000000000 Z
11
+ date: 2014-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord