globalize3 0.2.0.beta8 → 0.2.0

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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- globalize3 (0.2.0.beta7)
4
+ globalize3 (0.2.0.beta8)
5
5
  activemodel (>= 3.0.0)
6
6
  activerecord (>= 3.0.0)
7
7
  paper_trail (~> 2)
@@ -79,7 +79,7 @@ module Globalize
79
79
  end
80
80
 
81
81
  def set_metadata(object, metadata)
82
- object.translation_metadata.merge!(meta_data) if object.respond_to?(:translation_metadata)
82
+ object.translation_metadata.merge!(metadata) if object.respond_to?(:translation_metadata)
83
83
  object
84
84
  end
85
85
 
@@ -98,7 +98,9 @@ module Globalize
98
98
  scope = scope.send(:"scoped_by_#{unt}", arguments[index])
99
99
  end
100
100
 
101
- return scope.send(match.finder) if match.is_a?(::ActiveRecord::DynamicFinderMatch)
101
+ return scope.send(match.finder).tap do |found|
102
+ found.is_a?(Array) ? found.map { |f| f.translations.reload } : found.translations.reload unless found.nil?
103
+ end if match.is_a?(::ActiveRecord::DynamicFinderMatch)
102
104
  return scope
103
105
  end
104
106
 
@@ -32,6 +32,7 @@ module Globalize
32
32
  move_data_to_translation_table if options[:migrate_data]
33
33
  remove_source_columns if options[:remove_source_columns]
34
34
  create_translations_index
35
+ clear_schema_cache!
35
36
  end
36
37
 
37
38
  def remove_source_columns
@@ -44,6 +45,7 @@ module Globalize
44
45
  move_data_to_model_table if options[:migrate_data]
45
46
  drop_translations_index
46
47
  drop_translation_table
48
+ clear_schema_cache!
47
49
  end
48
50
 
49
51
  def complete_translated_fields
@@ -83,23 +85,13 @@ module Globalize
83
85
  end
84
86
 
85
87
  def move_data_to_translation_table
86
- # this refactored version might be a good idea,
87
- # but only if made into a code that doesn't break tests
88
- # model.find_each do |record|
89
- # translation = record.translations.build(:locale => I18n.default_locale)
90
- # translated_attribute_names.each do |attribute|
91
- # translation[attribute] = record[attribute]
92
- # end
93
- # translation.save!
94
- # end
95
-
96
- # Find all of the existing untranslated attributes for this model.
97
- all_model_fields = @model.all
98
- model_attributes = all_model_fields.map(&:untranslated_attributes)
99
- all_model_fields.each do |model_record|
100
- # Assign the attributes back to the model which will enable globalize3 to translate them.
101
- model_record.attributes = model_attributes.detect{|a| a['id'] == model_record.id}
102
- model_record.save!
88
+ model.find_each do |record|
89
+ untranslated_attributes = record.untranslated_attributes
90
+ translation = record.translations.build(:locale => I18n.default_locale)
91
+ translated_attribute_names.each do |attribute|
92
+ translation[attribute] = untranslated_attributes[attribute.to_s]
93
+ end
94
+ translation.save!
103
95
  end
104
96
  end
105
97
 
@@ -144,6 +136,9 @@ module Globalize
144
136
  index_name.size < 50 ? index_name : "index_#{Digest::SHA1.hexdigest(index_name)}"
145
137
  end
146
138
 
139
+ def clear_schema_cache!
140
+ connection.schema_cache.clear! if connection.respond_to? :schema_cache
141
+ end
147
142
 
148
143
  private
149
144
 
@@ -158,4 +153,4 @@ module Globalize
158
153
  end
159
154
  end
160
155
  end
161
- end
156
+ end
@@ -17,7 +17,7 @@ module Globalize
17
17
  alias with_locale with_locales
18
18
 
19
19
  def translated_locales
20
- select('DISTINCT locale').map(&:locale)
20
+ select('DISTINCT locale').map(&:locale).sort { |l,r| l.to_s <=> r.to_s }
21
21
  end
22
22
  end
23
23
 
@@ -1,3 +1,3 @@
1
1
  module Globalize3
2
- VERSION = '0.2.0.beta8'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,15 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: globalize3
3
3
  version: !ruby/object:Gem::Version
4
- hash: -4090334684
5
- prerelease: 6
4
+ hash: 23
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
9
  - 0
10
- - beta
11
- - 8
12
- version: 0.2.0.beta8
10
+ version: 0.2.0
13
11
  platform: ruby
14
12
  authors:
15
13
  - Sven Fuchs
@@ -22,7 +20,7 @@ autorequire:
22
20
  bindir: bin
23
21
  cert_chain: []
24
22
 
25
- date: 2012-02-02 00:00:00 Z
23
+ date: 2012-02-29 00:00:00 Z
26
24
  dependencies:
27
25
  - !ruby/object:Gem::Dependency
28
26
  name: activerecord
@@ -194,20 +192,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
194
192
  required_rubygems_version: !ruby/object:Gem::Requirement
195
193
  none: false
196
194
  requirements:
197
- - - ">"
195
+ - - ">="
198
196
  - !ruby/object:Gem::Version
199
- hash: 25
197
+ hash: 3
200
198
  segments:
201
- - 1
202
- - 3
203
- - 1
204
- version: 1.3.1
199
+ - 0
200
+ version: "0"
205
201
  requirements: []
206
202
 
207
203
  rubyforge_project: "[none]"
208
- rubygems_version: 1.8.10
204
+ rubygems_version: 1.8.17
209
205
  signing_key:
210
206
  specification_version: 3
211
207
  summary: "Rails I18n: de-facto standard library for ActiveRecord 3 model/data translation"
212
208
  test_files: []
213
209
 
210
+ has_rdoc: