globalize3 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +14 -0
- data/Gemfile.lock +51 -0
- data/README.textile +14 -0
- data/lib/globalize/active_record/act_macro.rb +3 -3
- data/lib/globalize/active_record/adapter.rb +30 -10
- data/lib/globalize/active_record/attributes.rb +6 -6
- data/lib/globalize/active_record/class_methods.rb +3 -3
- data/lib/globalize/active_record/exceptions.rb +19 -0
- data/lib/globalize/active_record/instance_methods.rb +22 -1
- data/lib/globalize/active_record/migration.rb +91 -27
- data/lib/globalize/active_record.rb +1 -4
- data/lib/globalize/version.rb +1 -1
- data/lib/globalize/versioning/vestal_versions.rb +35 -0
- data/lib/globalize/versioning.rb +5 -0
- data/lib/globalize.rb +17 -5
- data/lib/patches/active_record/query_method.rb +35 -0
- metadata +108 -4
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gem 'activerecord', '>= 3.0.0.rc'
|
4
|
+
|
5
|
+
group :test do
|
6
|
+
gem 'test_declarative'
|
7
|
+
gem 'database_cleaner'
|
8
|
+
gem 'pathname_local'
|
9
|
+
gem 'mocha'
|
10
|
+
# gem 'vestal_versions', :git => 'git@github.com:svenfuchs/vestal_versions.git'
|
11
|
+
gem 'vestal_versions', :path => '/Volumes/Users/sven/Development/projects/vestal_versions'
|
12
|
+
gem 'ruby-debug'
|
13
|
+
gem 'sqlite3-ruby'
|
14
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Volumes/Users/sven/Development/projects/vestal_versions
|
3
|
+
specs:
|
4
|
+
vestal_versions (1.0.2)
|
5
|
+
activerecord (>= 2.1.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (3.0.0.rc)
|
11
|
+
activesupport (= 3.0.0.rc)
|
12
|
+
builder (~> 2.1.2)
|
13
|
+
i18n (~> 0.4.1)
|
14
|
+
activerecord (3.0.0.rc)
|
15
|
+
activemodel (= 3.0.0.rc)
|
16
|
+
activesupport (= 3.0.0.rc)
|
17
|
+
arel (~> 0.4.0)
|
18
|
+
tzinfo (~> 0.3.22)
|
19
|
+
activesupport (3.0.0.rc)
|
20
|
+
arel (0.4.0)
|
21
|
+
activesupport (>= 3.0.0.beta)
|
22
|
+
builder (2.1.2)
|
23
|
+
columnize (0.3.1)
|
24
|
+
database_cleaner (0.5.2)
|
25
|
+
i18n (0.4.1)
|
26
|
+
linecache (0.43)
|
27
|
+
mocha (0.9.8)
|
28
|
+
rake
|
29
|
+
pathname_local (0.0.2)
|
30
|
+
rake (0.8.7)
|
31
|
+
ruby-debug (0.10.3)
|
32
|
+
columnize (>= 0.1)
|
33
|
+
ruby-debug-base (~> 0.10.3.0)
|
34
|
+
ruby-debug-base (0.10.3)
|
35
|
+
linecache (>= 0.3)
|
36
|
+
sqlite3-ruby (1.3.1)
|
37
|
+
test_declarative (0.0.3)
|
38
|
+
tzinfo (0.3.22)
|
39
|
+
|
40
|
+
PLATFORMS
|
41
|
+
ruby
|
42
|
+
|
43
|
+
DEPENDENCIES
|
44
|
+
activerecord (>= 3.0.0.rc)
|
45
|
+
database_cleaner
|
46
|
+
mocha
|
47
|
+
pathname_local
|
48
|
+
ruby-debug
|
49
|
+
sqlite3-ruby
|
50
|
+
test_declarative
|
51
|
+
vestal_versions!
|
data/README.textile
CHANGED
@@ -56,6 +56,20 @@ end
|
|
56
56
|
|
57
57
|
Note that the ActiveRecord model @Post@ must already exist and have a @translates@ directive listing the translated fields.
|
58
58
|
|
59
|
+
h2. Versioning with Globalize3
|
60
|
+
|
61
|
+
Globalize3 nicely integrates with "vestal_versions":http://github.com/laserlemon/vestal_versions:
|
62
|
+
|
63
|
+
<pre><code>
|
64
|
+
require 'globalize/versioning/vestal_versions'
|
65
|
+
</code></pre>
|
66
|
+
|
67
|
+
As of writing (2010-08-05) the original vestal_versions respository has not been updated to be compatible with Rails 3 though. You can use "this fork":http://github.com/svenfuchs/vestal_versions though. "Globalize3's Gemfile":http://github.com/svenfuchs/globalize3/blob/master/Gemfile#L10 is currently set up accordingly.
|
68
|
+
|
69
|
+
Please also note that @update_attribute@ currently hides itself from dirty tracking in ActiveRecord >= 3.0.0.beta (which is considered a "regression":http://github.com/rails/rails/commit/01629d180468049d17a8be6900e27a4f0d2b18c4#commitcomment-123199). That means that you currently need to use attribute writers or @update_attributes@ in order to track changes/versions for your models.
|
70
|
+
|
71
|
+
Also, please see the tests in test/globalize3/versioning_test.rb for some current gotchas.
|
72
|
+
|
59
73
|
h2. Changes since Globalize2
|
60
74
|
|
61
75
|
* `translation_table_name` was renamed to `translations_table_name`
|
@@ -7,13 +7,13 @@ module Globalize
|
|
7
7
|
options = attr_names.extract_options!
|
8
8
|
options[:table_name] ||= "#{table_name.singularize}_translations"
|
9
9
|
|
10
|
-
include InstanceMethods
|
11
|
-
extend ClassMethods, Migration
|
12
|
-
|
13
10
|
class_inheritable_accessor :translated_attribute_names, :translation_options
|
14
11
|
self.translated_attribute_names = attr_names.map(&:to_sym)
|
15
12
|
self.translation_options = options
|
16
13
|
|
14
|
+
include InstanceMethods
|
15
|
+
extend ClassMethods, Migration
|
16
|
+
|
17
17
|
has_many :translations, :class_name => translation_class.name,
|
18
18
|
:foreign_key => class_name.foreign_key,
|
19
19
|
:dependent => :delete_all,
|
@@ -5,27 +5,29 @@ module Globalize
|
|
5
5
|
# The stash keeps track of new or changed values that need to be saved.
|
6
6
|
attr_reader :record, :cache, :stash
|
7
7
|
|
8
|
+
delegate :translation_class, :to => :'record.class'
|
9
|
+
|
8
10
|
def initialize(record)
|
9
11
|
@record = record
|
10
12
|
@cache = Attributes.new
|
11
13
|
@stash = Attributes.new
|
12
14
|
end
|
13
15
|
|
14
|
-
def fetch(locale,
|
15
|
-
cache.contains?(locale,
|
16
|
-
cache.read(locale,
|
17
|
-
cache.write(locale,
|
16
|
+
def fetch(locale, name)
|
17
|
+
cache.contains?(locale, name) ?
|
18
|
+
type_cast(name, cache.read(locale, name)) :
|
19
|
+
cache.write(locale, name, fetch_attribute(locale, name))
|
18
20
|
end
|
19
21
|
|
20
|
-
def write(locale,
|
21
|
-
stash.write(locale,
|
22
|
-
cache.write(locale,
|
22
|
+
def write(locale, name, value)
|
23
|
+
stash.write(locale, name, value)
|
24
|
+
cache.write(locale, name, value)
|
23
25
|
end
|
24
26
|
|
25
27
|
def save_translations!
|
26
28
|
stash.each do |locale, attrs|
|
27
29
|
translation = record.translations.find_or_initialize_by_locale(locale.to_s)
|
28
|
-
attrs.each { |
|
30
|
+
attrs.each { |name, value| translation[name] = value }
|
29
31
|
translation.save!
|
30
32
|
end
|
31
33
|
stash.clear
|
@@ -37,6 +39,24 @@ module Globalize
|
|
37
39
|
|
38
40
|
protected
|
39
41
|
|
42
|
+
def type_cast(name, value)
|
43
|
+
if value.nil?
|
44
|
+
nil
|
45
|
+
elsif column = column_for_attribute(name)
|
46
|
+
column.type_cast(value)
|
47
|
+
else
|
48
|
+
value
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def column_for_attribute(name)
|
53
|
+
translation_class.columns_hash[name.to_s]
|
54
|
+
end
|
55
|
+
|
56
|
+
def unserializable_attribute?(name, column)
|
57
|
+
column.text? && translation_class.serialized_attributes[name.to_s]
|
58
|
+
end
|
59
|
+
|
40
60
|
def fetch_translation(locale)
|
41
61
|
locale = locale.to_sym
|
42
62
|
record.translations.loaded? ? record.translations.detect { |t| t.locale == locale } :
|
@@ -49,13 +69,13 @@ module Globalize
|
|
49
69
|
record.translations.with_locales(Globalize.fallbacks(locale))
|
50
70
|
end
|
51
71
|
|
52
|
-
def fetch_attribute(locale,
|
72
|
+
def fetch_attribute(locale, name)
|
53
73
|
translations = fetch_translations(locale)
|
54
74
|
value, requested_locale = nil, locale
|
55
75
|
|
56
76
|
Globalize.fallbacks(locale).each do |fallback|
|
57
77
|
translation = translations.detect { |t| t.locale == fallback }
|
58
|
-
value = translation && translation.send(
|
78
|
+
value = translation && translation.send(name)
|
59
79
|
locale = fallback && break if value
|
60
80
|
end
|
61
81
|
|
@@ -10,16 +10,16 @@ module Globalize
|
|
10
10
|
self.fetch(locale)
|
11
11
|
end
|
12
12
|
|
13
|
-
def contains?(locale,
|
14
|
-
self[locale].has_key?(
|
13
|
+
def contains?(locale, name)
|
14
|
+
self[locale].has_key?(name.to_s)
|
15
15
|
end
|
16
16
|
|
17
|
-
def read(locale,
|
18
|
-
self[locale][
|
17
|
+
def read(locale, name)
|
18
|
+
self[locale][name.to_s]
|
19
19
|
end
|
20
20
|
|
21
|
-
def write(locale,
|
22
|
-
self[locale][
|
21
|
+
def write(locale, name, value)
|
22
|
+
self[locale][name.to_s] = value
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -27,7 +27,7 @@ module Globalize
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def translated?(name)
|
30
|
-
translated_attribute_names.include?(name)
|
30
|
+
translated_attribute_names.include?(name.to_sym)
|
31
31
|
end
|
32
32
|
|
33
33
|
def required_attributes
|
@@ -72,10 +72,10 @@ module Globalize
|
|
72
72
|
|
73
73
|
def translated_attr_accessor(name)
|
74
74
|
define_method(:"#{name}=") do |value|
|
75
|
-
|
75
|
+
write_attribute(name, value, Globalize.locale)
|
76
76
|
end
|
77
77
|
define_method(name) do |*args|
|
78
|
-
|
78
|
+
read_attribute(name, args.first || Globalize.locale)
|
79
79
|
end
|
80
80
|
alias_method :"#{name}_before_type_cast", name
|
81
81
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Globalize
|
2
|
+
module ActiveRecord
|
3
|
+
module Exceptions
|
4
|
+
class MigrationError < StandardError; end
|
5
|
+
|
6
|
+
class BadFieldName < MigrationError
|
7
|
+
def initialize(field)
|
8
|
+
super("Missing translated field #{field.inspect}")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class BadFieldType < MigrationError
|
13
|
+
def initialize(name, type)
|
14
|
+
super("Bad field type for field #{name.inspect} (#{type.inspect}), should be :string or :text")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -4,7 +4,7 @@ module Globalize
|
|
4
4
|
delegate :translated_locales, :to => :translations
|
5
5
|
|
6
6
|
def globalize
|
7
|
-
@globalize ||= Adapter.new
|
7
|
+
@globalize ||= Adapter.new(self)
|
8
8
|
end
|
9
9
|
|
10
10
|
def attributes
|
@@ -15,13 +15,34 @@ module Globalize
|
|
15
15
|
with_given_locale(attributes) { super }
|
16
16
|
end
|
17
17
|
|
18
|
+
def update_attributes!(attributes, *args)
|
19
|
+
with_given_locale(attributes) { super }
|
20
|
+
end
|
21
|
+
|
18
22
|
def update_attributes(attributes, *args)
|
19
23
|
with_given_locale(attributes) { super }
|
20
24
|
end
|
21
25
|
|
26
|
+
def write_attribute(name, value, locale = nil)
|
27
|
+
super(name, value)
|
28
|
+
globalize.write(locale || Globalize.locale, name, value) if translated?(name)
|
29
|
+
end
|
30
|
+
|
31
|
+
def read_attribute(name, locale = nil)
|
32
|
+
if self.class.translated?(name)
|
33
|
+
globalize.fetch(locale || Globalize.locale, name)
|
34
|
+
else
|
35
|
+
super(name)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
22
39
|
def attribute_names
|
23
40
|
translated_attribute_names.map(&:to_s) + super
|
24
41
|
end
|
42
|
+
|
43
|
+
def translated?(name)
|
44
|
+
self.class.translated?(name)
|
45
|
+
end
|
25
46
|
|
26
47
|
def translated_attributes
|
27
48
|
translated_attribute_names.inject({}) do |attributes, name|
|
@@ -1,44 +1,108 @@
|
|
1
|
+
require 'digest/sha1'
|
2
|
+
|
1
3
|
module Globalize
|
2
4
|
module ActiveRecord
|
3
5
|
module Migration
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
attr_reader :globalize_migrator
|
7
|
+
|
8
|
+
def globalize_migrator
|
9
|
+
@globalize_migrator ||= Migrator.new(self)
|
10
|
+
end
|
11
|
+
|
12
|
+
delegate :create_translation_table!, :drop_translation_table!,
|
13
|
+
:translation_index_name, :to => :globalize_migrator
|
14
|
+
|
15
|
+
class Migrator
|
16
|
+
include Globalize::ActiveRecord::Exceptions
|
17
|
+
|
18
|
+
attr_reader :model, :fields
|
19
|
+
delegate :translated_attribute_names, :connection, :table_name,
|
20
|
+
:table_name_prefix, :translations_table_name, :columns, :to => :model
|
21
|
+
|
22
|
+
def initialize(model)
|
23
|
+
@model = model
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_translation_table!(fields = {}, options = {})
|
27
|
+
@fields = fields
|
28
|
+
complete_translated_fields
|
29
|
+
validate_translated_fields
|
30
|
+
|
31
|
+
create_translation_table
|
32
|
+
move_data_to_translation_table if options[:migrate_data]
|
33
|
+
create_translations_index
|
34
|
+
end
|
35
|
+
|
36
|
+
def drop_translation_table!(options = {})
|
37
|
+
move_data_to_model_table if options[:migrate_data]
|
38
|
+
drop_translations_index
|
39
|
+
drop_translation_table
|
7
40
|
end
|
8
41
|
|
9
|
-
|
10
|
-
|
11
|
-
|
42
|
+
def complete_translated_fields
|
43
|
+
translated_attribute_names.each do |name|
|
44
|
+
fields[name] = column_type(name) unless fields[name]
|
12
45
|
end
|
13
46
|
end
|
14
47
|
|
15
|
-
|
16
|
-
|
17
|
-
|
48
|
+
def create_translation_table
|
49
|
+
connection.create_table(translations_table_name) do |t|
|
50
|
+
t.references table_name.sub(/^#{table_name_prefix}/, '').singularize
|
51
|
+
t.string :locale
|
52
|
+
fields.each { |name, type| t.column name, type }
|
53
|
+
t.timestamps
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def create_translations_index
|
58
|
+
connection.add_index(
|
59
|
+
translations_table_name,
|
60
|
+
"#{table_name.sub(/^#{table_name_prefix}/, "").singularize}_id",
|
61
|
+
:name => translation_index_name
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
def drop_translation_table
|
66
|
+
connection.drop_table(translations_table_name)
|
67
|
+
end
|
68
|
+
|
69
|
+
def drop_translations_index
|
70
|
+
connection.remove_index(translations_table_name, :name => translation_index_name) rescue nil
|
71
|
+
end
|
72
|
+
|
73
|
+
def move_data_to_translation_table
|
74
|
+
# TODO
|
75
|
+
end
|
76
|
+
|
77
|
+
def move_data_to_model_table
|
78
|
+
# TODO
|
79
|
+
end
|
80
|
+
|
81
|
+
def validate_translated_fields
|
18
82
|
fields.each do |name, type|
|
19
|
-
|
83
|
+
raise BadFieldName.new(name) unless valid_field_name?(name)
|
84
|
+
raise BadFieldType.new(name, type) unless valid_field_type?(name, type)
|
20
85
|
end
|
21
|
-
t.timestamps
|
22
86
|
end
|
23
87
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
:name => translation_index_name
|
28
|
-
)
|
29
|
-
end
|
88
|
+
def column_type(name)
|
89
|
+
columns.detect { |c| c.name == name.to_s }.try(:type)
|
90
|
+
end
|
30
91
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
92
|
+
def valid_field_name?(name)
|
93
|
+
translated_attribute_names.include?(name)
|
94
|
+
end
|
95
|
+
|
96
|
+
def valid_field_type?(name, type)
|
97
|
+
!translated_attribute_names.include?(name) || [:string, :text].include?(type)
|
98
|
+
end
|
37
99
|
|
38
|
-
|
39
|
-
|
40
|
-
|
100
|
+
def translation_index_name
|
101
|
+
# FIXME what's the max size of an index name?
|
102
|
+
index_name = "index_#{translations_table_name}_on_#{table_name.singularize}_id"
|
103
|
+
index_name.size < 50 ? index_name : "index_#{Digest::SHA1.hexdigest(index_name)}"
|
104
|
+
end
|
41
105
|
end
|
42
106
|
end
|
43
107
|
end
|
44
|
-
end
|
108
|
+
end
|
@@ -1,13 +1,10 @@
|
|
1
1
|
module Globalize
|
2
|
-
class MigrationError < StandardError; end
|
3
|
-
class MigrationMissingTranslatedField < MigrationError; end
|
4
|
-
class BadMigrationFieldType < MigrationError; end
|
5
|
-
|
6
2
|
module ActiveRecord
|
7
3
|
autoload :ActMacro, 'globalize/active_record/act_macro'
|
8
4
|
autoload :Adapter, 'globalize/active_record/adapter'
|
9
5
|
autoload :Attributes, 'globalize/active_record/attributes'
|
10
6
|
autoload :ClassMethods, 'globalize/active_record/class_methods'
|
7
|
+
autoload :Exceptions, 'globalize/active_record/exceptions'
|
11
8
|
autoload :InstanceMethods, 'globalize/active_record/instance_methods'
|
12
9
|
autoload :Migration, 'globalize/active_record/migration'
|
13
10
|
autoload :Translation, 'globalize/active_record/translation'
|
data/lib/globalize/version.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'vestal_versions'
|
2
|
+
|
3
|
+
module Globalize
|
4
|
+
module Versioning
|
5
|
+
module VestalVersions
|
6
|
+
def versioned_columns
|
7
|
+
super + self.class.translated_attribute_names
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
ActiveRecord::Base.class_eval do
|
14
|
+
class << self
|
15
|
+
def versioned_with_globalize(*args)
|
16
|
+
versioned_without_globalize(*args)
|
17
|
+
include Globalize::Versioning::VestalVersions
|
18
|
+
end
|
19
|
+
alias_method_chain :versioned, :globalize
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
VestalVersions::Version.class_eval do
|
24
|
+
before_save do |version|
|
25
|
+
version.locale = Globalize.locale.to_s
|
26
|
+
end
|
27
|
+
|
28
|
+
class Condition
|
29
|
+
def to_sql
|
30
|
+
"locale = '#{Globalize.locale.to_s}'"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
default_scope(:conditions => Condition.new)
|
35
|
+
end
|
data/lib/globalize.rb
CHANGED
@@ -1,22 +1,24 @@
|
|
1
1
|
require 'patches/active_record/xml_attribute_serializer'
|
2
|
+
require 'patches/active_record/query_method'
|
2
3
|
|
3
4
|
module Globalize
|
4
5
|
autoload :ActiveRecord, 'globalize/active_record'
|
6
|
+
autoload :Versioning, 'globalize/versioning'
|
5
7
|
|
6
8
|
class << self
|
7
9
|
def locale
|
8
|
-
|
10
|
+
read_locale || I18n.locale
|
9
11
|
end
|
10
12
|
|
11
13
|
def locale=(locale)
|
12
|
-
|
14
|
+
set_locale(locale)
|
13
15
|
end
|
14
16
|
|
15
17
|
def with_locale(locale, &block)
|
16
|
-
previous_locale =
|
17
|
-
|
18
|
+
previous_locale = read_locale
|
19
|
+
set_locale(locale)
|
18
20
|
result = yield
|
19
|
-
|
21
|
+
set_locale(previous_locale)
|
20
22
|
result
|
21
23
|
end
|
22
24
|
|
@@ -27,6 +29,16 @@ module Globalize
|
|
27
29
|
def fallbacks(locale = self.locale)
|
28
30
|
fallbacks? ? I18n.fallbacks[locale] : [locale.to_sym]
|
29
31
|
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
def read_locale
|
36
|
+
Thread.current[:globalize_locale]
|
37
|
+
end
|
38
|
+
|
39
|
+
def set_locale(locale)
|
40
|
+
Thread.current[:globalize_locale] = locale
|
41
|
+
end
|
30
42
|
end
|
31
43
|
end
|
32
44
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'active_record/attribute_methods/query'
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
module AttributeMethods
|
5
|
+
module Query
|
6
|
+
def query_attribute(attr_name)
|
7
|
+
unless value = read_attribute(attr_name)
|
8
|
+
false
|
9
|
+
else
|
10
|
+
column = self.class.columns_hash[attr_name]
|
11
|
+
if column.nil?
|
12
|
+
|
13
|
+
# TODO submit a rails patch
|
14
|
+
|
15
|
+
# not sure what active_record tests say but i guess this should mean:
|
16
|
+
# call to_i and check zero? if the value is a Numeric or starts with
|
17
|
+
# a digit, so it can meaningfully be typecasted by to_i
|
18
|
+
|
19
|
+
# if Numeric === value || value !~ /[^0-9]/
|
20
|
+
if Numeric === value || value.to_s =~ /^[0-9]/
|
21
|
+
!value.to_i.zero?
|
22
|
+
else
|
23
|
+
return false if ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(value)
|
24
|
+
!value.blank?
|
25
|
+
end
|
26
|
+
elsif column.number?
|
27
|
+
!value.zero?
|
28
|
+
else
|
29
|
+
!value.blank?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: globalize3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sven Fuchs
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2010-08-
|
21
|
+
date: 2010-08-15 00:00:00 +02:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
@@ -38,6 +38,104 @@ dependencies:
|
|
38
38
|
version: 3.0.0.rc
|
39
39
|
type: :runtime
|
40
40
|
version_requirements: *id001
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: database_cleaner
|
43
|
+
prerelease: false
|
44
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
hash: 3
|
50
|
+
segments:
|
51
|
+
- 0
|
52
|
+
version: "0"
|
53
|
+
type: :development
|
54
|
+
version_requirements: *id002
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mocha
|
57
|
+
prerelease: false
|
58
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
hash: 3
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
67
|
+
type: :development
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pathname_local
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 3
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
version: "0"
|
81
|
+
type: :development
|
82
|
+
version_requirements: *id004
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: test_declarative
|
85
|
+
prerelease: false
|
86
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
hash: 3
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
version: "0"
|
95
|
+
type: :development
|
96
|
+
version_requirements: *id005
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: vestal_versions
|
99
|
+
prerelease: false
|
100
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
hash: 3
|
106
|
+
segments:
|
107
|
+
- 0
|
108
|
+
version: "0"
|
109
|
+
type: :development
|
110
|
+
version_requirements: *id006
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: ruby-debug
|
113
|
+
prerelease: false
|
114
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 3
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
version: "0"
|
123
|
+
type: :development
|
124
|
+
version_requirements: *id007
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: sqlite3-ruby
|
127
|
+
prerelease: false
|
128
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
hash: 3
|
134
|
+
segments:
|
135
|
+
- 0
|
136
|
+
version: "0"
|
137
|
+
type: :development
|
138
|
+
version_requirements: *id008
|
41
139
|
description: "Rails I18n: de-facto standard library for ActiveRecord 3 model/data translation."
|
42
140
|
email: nobody@globalize-rails.org
|
43
141
|
executables: []
|
@@ -51,16 +149,22 @@ files:
|
|
51
149
|
- lib/globalize/active_record/adapter.rb
|
52
150
|
- lib/globalize/active_record/attributes.rb
|
53
151
|
- lib/globalize/active_record/class_methods.rb
|
152
|
+
- lib/globalize/active_record/exceptions.rb
|
54
153
|
- lib/globalize/active_record/instance_methods.rb
|
55
154
|
- lib/globalize/active_record/migration.rb
|
56
155
|
- lib/globalize/active_record/translation.rb
|
57
156
|
- lib/globalize/active_record.rb
|
58
157
|
- lib/globalize/version.rb
|
158
|
+
- lib/globalize/versioning/vestal_versions.rb
|
159
|
+
- lib/globalize/versioning.rb
|
59
160
|
- lib/globalize.rb
|
60
161
|
- lib/globalize3.rb
|
61
162
|
- lib/i18n/missing_translations_log_handler.rb
|
62
163
|
- lib/i18n/missing_translations_raise_handler.rb
|
164
|
+
- lib/patches/active_record/query_method.rb
|
63
165
|
- lib/patches/active_record/xml_attribute_serializer.rb
|
166
|
+
- Gemfile
|
167
|
+
- Gemfile.lock
|
64
168
|
- LICENSE
|
65
169
|
- Rakefile
|
66
170
|
- README.textile
|