mongoid_globalize 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/Gemfile.lock +19 -17
- data/README.textile +2 -4
- data/VERSION +1 -1
- data/lib/mongoid_globalize/class_methods.rb +1 -1
- data/lib/mongoid_globalize/document_translation.rb +2 -2
- data/lib/mongoid_globalize/instance_methods.rb +2 -2
- data/mongoid_globalize.gemspec +8 -8
- data/spec/mongoid_globalize/attributes_spec.rb +1 -1
- metadata +22 -22
data/Gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
|
-
gem 'mongoid', '~> 2.
|
4
|
-
gem 'bson_ext', '
|
3
|
+
gem 'mongoid', '~> 2.4', :git => 'git://github.com/mongoid/mongoid.git', :tag => 'v2.4.1'
|
4
|
+
gem 'bson_ext', '~> 1.5'
|
5
5
|
|
6
6
|
group :development, :test do
|
7
7
|
gem 'rdoc'
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
GIT
|
2
2
|
remote: git://github.com/mongoid/mongoid.git
|
3
|
-
revision:
|
4
|
-
tag: v2.
|
3
|
+
revision: 0abef29ade4fe81c4e83be773cd6cfd6c02364f9
|
4
|
+
tag: v2.4.1
|
5
5
|
specs:
|
6
|
-
mongoid (2.
|
6
|
+
mongoid (2.4.1)
|
7
7
|
activemodel (~> 3.1)
|
8
8
|
mongo (~> 1.3)
|
9
9
|
tzinfo (~> 0.3.22)
|
@@ -22,15 +22,16 @@ GEM
|
|
22
22
|
bson_ext (1.5.2)
|
23
23
|
bson (= 1.5.2)
|
24
24
|
builder (3.0.0)
|
25
|
-
columnize (0.3.
|
26
|
-
database_cleaner (0.
|
27
|
-
diff-lcs (1.1.
|
25
|
+
columnize (0.3.6)
|
26
|
+
database_cleaner (0.7.0)
|
27
|
+
diff-lcs (1.1.3)
|
28
28
|
git (1.2.5)
|
29
29
|
i18n (0.6.0)
|
30
30
|
jeweler (1.6.4)
|
31
31
|
bundler (~> 1.0)
|
32
32
|
git (>= 1.2.5)
|
33
33
|
rake
|
34
|
+
json (1.6.4)
|
34
35
|
linecache19 (0.5.12)
|
35
36
|
ruby_core_source (>= 0.1.4)
|
36
37
|
mongo (1.5.2)
|
@@ -39,16 +40,17 @@ GEM
|
|
39
40
|
mongoid (~> 2.0)
|
40
41
|
rspec (~> 2)
|
41
42
|
multi_json (1.0.4)
|
42
|
-
rake (0.9.2)
|
43
|
-
rdoc (3.
|
44
|
-
|
45
|
-
|
46
|
-
rspec-
|
47
|
-
rspec-
|
48
|
-
|
49
|
-
rspec-
|
43
|
+
rake (0.9.2.2)
|
44
|
+
rdoc (3.12)
|
45
|
+
json (~> 1.4)
|
46
|
+
rspec (2.8.0)
|
47
|
+
rspec-core (~> 2.8.0)
|
48
|
+
rspec-expectations (~> 2.8.0)
|
49
|
+
rspec-mocks (~> 2.8.0)
|
50
|
+
rspec-core (2.8.0)
|
51
|
+
rspec-expectations (2.8.0)
|
50
52
|
diff-lcs (~> 1.1.2)
|
51
|
-
rspec-mocks (2.
|
53
|
+
rspec-mocks (2.8.0)
|
52
54
|
ruby-debug-base19 (0.11.25)
|
53
55
|
columnize (>= 0.3.1)
|
54
56
|
linecache19 (>= 0.5.11)
|
@@ -65,10 +67,10 @@ PLATFORMS
|
|
65
67
|
ruby
|
66
68
|
|
67
69
|
DEPENDENCIES
|
68
|
-
bson_ext (
|
70
|
+
bson_ext (~> 1.5)
|
69
71
|
database_cleaner
|
70
72
|
jeweler
|
71
|
-
mongoid (~> 2.
|
73
|
+
mongoid (~> 2.4)!
|
72
74
|
mongoid-rspec
|
73
75
|
rdoc
|
74
76
|
rspec
|
data/README.textile
CHANGED
@@ -2,13 +2,11 @@ h1. "!https://secure.travis-ci.org/Mik-die/mongoid_globalize.png!":http://travis
|
|
2
2
|
|
3
3
|
Mongoid::Globalize is based on Globalize3, but targeted at Mongoid. As Globalize3, it is compatible with and builds on the new "I18n API in Ruby on Rails":http://guides.rubyonrails.org/i18n.html and adds model translations to Mongoid::Document.
|
4
4
|
|
5
|
-
Mongoid::Globalize has to work with Rails3 and other frameworks, that supports Mongoid (Sinatra, Padrino, and others).
|
5
|
+
Mongoid::Globalize has to work with Rails3+ and other frameworks, that supports Mongoid (Sinatra, Padrino, and others).
|
6
6
|
|
7
7
|
h2. Requirements
|
8
8
|
|
9
|
-
Mongoid 2.
|
10
|
-
|
11
|
-
I also tested against ActiveModel-3.1.0.rc4, so Mongoid::Globalize has to work with Rails 3.1.
|
9
|
+
Mongoid 2.3. Mongoid 2.4 break some specs, so it's not supported yet. Though you can use master branch of gem.
|
12
10
|
|
13
11
|
h2. Installation
|
14
12
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -45,7 +45,7 @@ module Mongoid::Globalize
|
|
45
45
|
|
46
46
|
# Return Array of attribute names with presence validations
|
47
47
|
def required_attributes
|
48
|
-
validators.map{ |v| v.attributes if v.is_a?(
|
48
|
+
validators.map{ |v| v.attributes if v.is_a?(Mongoid::Validations::PresenceValidator) }.flatten.compact
|
49
49
|
end
|
50
50
|
|
51
51
|
# Return Array of translated attribute names with presence validations
|
@@ -4,7 +4,7 @@ module Mongoid::Globalize
|
|
4
4
|
class DocumentTranslation
|
5
5
|
include Mongoid::Document
|
6
6
|
|
7
|
-
field :locale
|
7
|
+
field :locale, :type => String
|
8
8
|
|
9
9
|
class << self
|
10
10
|
# Accessor to document class which translated
|
@@ -22,7 +22,7 @@ module Mongoid::Globalize
|
|
22
22
|
# Returns all locales used for translation.
|
23
23
|
# Return Array of Symbols
|
24
24
|
def translated_locales
|
25
|
-
all.distinct("locale").sort{ |x,y| x.to_s <=> y.to_s }.map
|
25
|
+
all.distinct("locale").sort{ |x,y| x.to_s <=> y.to_s }.map(&:to_sym)
|
26
26
|
end
|
27
27
|
|
28
28
|
# Returns translation document for given locale
|
@@ -44,7 +44,7 @@ module Mongoid::Globalize
|
|
44
44
|
end
|
45
45
|
@translated_attributes[access] = value
|
46
46
|
the_locale = options[:locale] || Mongoid::Globalize.locale
|
47
|
-
self.translations.reject!{ |t| t.new_record? && t.locale != the_locale }
|
47
|
+
self.translations.reject!{ |t| t.new_record? && t.locale != the_locale } if self.class.fallbacks_for_empty_translations
|
48
48
|
globalize.write(the_locale, name, value)
|
49
49
|
else
|
50
50
|
super(name, value)
|
@@ -181,7 +181,7 @@ module Mongoid::Globalize
|
|
181
181
|
@stop_merging_translated_attributes = true
|
182
182
|
translated_attribute_names.each do |name|
|
183
183
|
@attributes.delete name.to_s
|
184
|
-
@changed_attributes.delete name.to_s
|
184
|
+
@changed_attributes.delete name.to_s if @changed_attributes
|
185
185
|
end
|
186
186
|
globalize.prepare_translations!
|
187
187
|
end
|
data/mongoid_globalize.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "mongoid_globalize"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Mik-die"]
|
12
|
-
s.date = "2012-01-
|
12
|
+
s.date = "2012-01-16"
|
13
13
|
s.description = "Library for translating Mongoid documents, based on Globalize3 principles"
|
14
14
|
s.email = "MikDiet@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -56,8 +56,8 @@ Gem::Specification.new do |s|
|
|
56
56
|
s.specification_version = 3
|
57
57
|
|
58
58
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
59
|
-
s.add_runtime_dependency(%q<mongoid>, ["~> 2.
|
60
|
-
s.add_runtime_dependency(%q<bson_ext>, ["
|
59
|
+
s.add_runtime_dependency(%q<mongoid>, ["~> 2.4"])
|
60
|
+
s.add_runtime_dependency(%q<bson_ext>, ["~> 1.5"])
|
61
61
|
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
62
62
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
63
63
|
s.add_development_dependency(%q<mongoid-rspec>, [">= 0"])
|
@@ -65,8 +65,8 @@ Gem::Specification.new do |s|
|
|
65
65
|
s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
|
66
66
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
67
67
|
else
|
68
|
-
s.add_dependency(%q<mongoid>, ["~> 2.
|
69
|
-
s.add_dependency(%q<bson_ext>, ["
|
68
|
+
s.add_dependency(%q<mongoid>, ["~> 2.4"])
|
69
|
+
s.add_dependency(%q<bson_ext>, ["~> 1.5"])
|
70
70
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
71
71
|
s.add_dependency(%q<rspec>, [">= 0"])
|
72
72
|
s.add_dependency(%q<mongoid-rspec>, [">= 0"])
|
@@ -75,8 +75,8 @@ Gem::Specification.new do |s|
|
|
75
75
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
76
76
|
end
|
77
77
|
else
|
78
|
-
s.add_dependency(%q<mongoid>, ["~> 2.
|
79
|
-
s.add_dependency(%q<bson_ext>, ["
|
78
|
+
s.add_dependency(%q<mongoid>, ["~> 2.4"])
|
79
|
+
s.add_dependency(%q<bson_ext>, ["~> 1.5"])
|
80
80
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
81
81
|
s.add_dependency(%q<rspec>, [">= 0"])
|
82
82
|
s.add_dependency(%q<mongoid-rspec>, [">= 0"])
|
@@ -94,7 +94,7 @@ describe 'Attributes' do
|
|
94
94
|
it "works for translated attributes" do
|
95
95
|
post = Post.create(:title => 'title')
|
96
96
|
post.update_attributes(:title => "Titel", :locale => :de)
|
97
|
-
|
97
|
+
|
98
98
|
with_locale(:en) { post.title_before_type_cast.should == 'title' }
|
99
99
|
with_locale(:de) { post.title_before_type_cast.should == 'Titel' }
|
100
100
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_globalize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,33 +9,33 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-16 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|
16
|
-
requirement: &
|
16
|
+
requirement: &70298047768640 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '2.
|
21
|
+
version: '2.4'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70298047768640
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bson_ext
|
27
|
-
requirement: &
|
27
|
+
requirement: &70298047768140 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
|
-
- -
|
30
|
+
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '1.
|
32
|
+
version: '1.5'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70298047768140
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rdoc
|
38
|
-
requirement: &
|
38
|
+
requirement: &70298047767620 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70298047767620
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &70298047767120 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70298047767120
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: mongoid-rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &70298047654720 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70298047654720
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: database_cleaner
|
71
|
-
requirement: &
|
71
|
+
requirement: &70298047654240 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70298047654240
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: ruby-debug19
|
82
|
-
requirement: &
|
82
|
+
requirement: &70298047653660 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70298047653660
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: jeweler
|
93
|
-
requirement: &
|
93
|
+
requirement: &70298047653160 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70298047653160
|
102
102
|
description: Library for translating Mongoid documents, based on Globalize3 principles
|
103
103
|
email: MikDiet@gmail.com
|
104
104
|
executables: []
|
@@ -150,7 +150,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
150
|
version: '0'
|
151
151
|
segments:
|
152
152
|
- 0
|
153
|
-
hash:
|
153
|
+
hash: -2711224385223325308
|
154
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
155
|
none: false
|
156
156
|
requirements:
|