mongoid_i18n 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,54 +1,77 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- activemodel (3.0.0.rc)
5
- activesupport (= 3.0.0.rc)
6
- builder (~> 2.1.2)
7
- i18n (~> 0.4.1)
8
- activesupport (3.0.0.rc)
9
- bson (1.0.4)
10
- bson_ext (1.0.4)
11
- builder (2.1.2)
12
- diff-lcs (1.1.2)
13
- gemcutter (0.6.1)
14
- git (1.2.5)
15
- i18n (0.4.1)
16
- jeweler (1.4.0)
17
- gemcutter (>= 0.1.0)
18
- git (>= 1.2.5)
19
- rubyforge (>= 2.0.0)
20
- json_pure (1.4.6)
21
- mocha (0.9.8)
22
- rake
23
- mongo (1.0.7)
24
- bson (>= 1.0.4)
25
- mongoid (2.0.0.beta.16)
26
- activemodel (= 3.0.0.rc)
27
- bson (= 1.0.4)
28
- mongo (= 1.0.7)
29
- tzinfo (= 0.3.22)
30
- will_paginate (~> 3.0.pre)
31
- rake (0.8.7)
32
- rspec (2.0.0.beta.19)
33
- rspec-core (= 2.0.0.beta.19)
34
- rspec-expectations (= 2.0.0.beta.19)
35
- rspec-mocks (= 2.0.0.beta.19)
36
- rspec-core (2.0.0.beta.19)
37
- rspec-expectations (2.0.0.beta.19)
38
- diff-lcs (>= 1.1.2)
39
- rspec-mocks (2.0.0.beta.19)
40
- rubyforge (2.0.4)
41
- json_pure (>= 1.1.7)
42
- tzinfo (0.3.22)
43
- will_paginate (3.0.pre2)
44
-
45
- PLATFORMS
46
- ruby
47
-
48
- DEPENDENCIES
49
- bson_ext
50
- bundler
51
- jeweler
52
- mocha
53
- mongoid (>= 2.0.0.beta.9)
54
- rspec (>= 2.0.0.beta.8)
1
+ ---
2
+ dependencies:
3
+ bson_ext:
4
+ group:
5
+ - :default
6
+ version: ">= 0"
7
+ rspec:
8
+ group:
9
+ - :default
10
+ version: ">= 2.0.0.beta.8"
11
+ mocha:
12
+ group:
13
+ - :default
14
+ version: ">= 0"
15
+ bundler:
16
+ group:
17
+ - :default
18
+ version: ">= 0"
19
+ jeweler:
20
+ group:
21
+ - :default
22
+ version: ">= 0"
23
+ mongoid:
24
+ group:
25
+ - :default
26
+ version: ">= 2.0.0.beta.9"
27
+ specs:
28
+ - rake:
29
+ version: 0.8.7
30
+ - activesupport:
31
+ version: 3.0.0.rc2
32
+ - builder:
33
+ version: 2.1.2
34
+ - i18n:
35
+ version: 0.4.1
36
+ - activemodel:
37
+ version: 3.0.0.rc2
38
+ - bson:
39
+ version: 1.0.7
40
+ - bson_ext:
41
+ version: 1.0.7
42
+ - bundler:
43
+ version: 0.9.26
44
+ - diff-lcs:
45
+ version: 1.1.2
46
+ - gemcutter:
47
+ version: 0.6.1
48
+ - git:
49
+ version: 1.2.5
50
+ - json_pure:
51
+ version: 1.4.6
52
+ - rubyforge:
53
+ version: 2.0.4
54
+ - jeweler:
55
+ version: 1.4.0
56
+ - mocha:
57
+ version: 0.9.8
58
+ - mongo:
59
+ version: 1.0.8
60
+ - tzinfo:
61
+ version: 0.3.23
62
+ - will_paginate:
63
+ version: 3.0.pre2
64
+ - mongoid:
65
+ version: 2.0.0.beta7
66
+ - rspec-core:
67
+ version: 2.0.0.beta.20
68
+ - rspec-expectations:
69
+ version: 2.0.0.beta.20
70
+ - rspec-mocks:
71
+ version: 2.0.0.beta.20
72
+ - rspec:
73
+ version: 2.0.0.beta.20
74
+ hash: 6dfab5e2b924a3176f60464404e1350aed0df898
75
+ sources:
76
+ - Rubygems:
77
+ uri: http://gemcutter.org
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.6
1
+ 0.1.7
data/lib/mongoid/i18n.rb CHANGED
@@ -20,7 +20,12 @@ module Mongoid
20
20
  if options[:type] == LocalizedField
21
21
  define_method(meth) { read_attribute(name)[::I18n.locale.to_s] rescue '' }
22
22
  define_method("#{meth}=") do |value|
23
- write_attribute(name, (@attributes[name] || {}).merge(::I18n.locale.to_s => value))
23
+ if value.is_a?(Hash)
24
+ val = (@attributes[name] || {}).merge(value)
25
+ else
26
+ val = (@attributes[name] || {}).merge(::I18n.locale.to_s => value)
27
+ end
28
+ write_attribute(name, val)
24
29
  end
25
30
  define_method("#{meth}_translations") { read_attribute(name) }
26
31
  define_method("#{meth}_translations=") { |value| write_attribute(name, value) }
data/mongoid_i18n.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongoid_i18n}
8
- s.version = "0.1.6"
8
+ s.version = "0.1.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Rodrigo \303\201lvarez"]
12
- s.date = %q{2010-08-18}
12
+ s.date = %q{2010-08-29}
13
13
  s.description = %q{This gem aims to be a transparent way to deal with localizable fields.
14
14
  Basically use localized_field() instead of field() and that's it.
15
15
  It will take care of locales for you when using find or criteria.
@@ -41,7 +41,7 @@ Gem::Specification.new do |s|
41
41
  s.homepage = %q{http://github.com/Papipo/mongoid_i18n}
42
42
  s.rdoc_options = ["--charset=UTF-8"]
43
43
  s.require_paths = ["lib"]
44
- s.rubygems_version = %q{1.3.7}
44
+ s.rubygems_version = %q{1.3.6}
45
45
  s.summary = %q{Mongoid plugin to deal with localizable fields}
46
46
  s.test_files = [
47
47
  "spec/integration/mongoid/i18n_spec.rb",
@@ -54,7 +54,7 @@ Gem::Specification.new do |s|
54
54
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
55
55
  s.specification_version = 3
56
56
 
57
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
57
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
58
58
  s.add_runtime_dependency(%q<mongoid>, [">= 2.0.0.beta.9"])
59
59
  s.add_development_dependency(%q<rspec>, [">= 2.0.0.beta.8"])
60
60
  else
@@ -140,4 +140,28 @@ describe Mongoid::I18n, 'criteria on embeds_many association' do
140
140
  it "should contain the embedded documents" do
141
141
  @entry.sub_entries.criteria.instance_variable_get("@documents").should == @sub_entries
142
142
  end
143
+ end
144
+
145
+ describe Mongoid::I18n, 'criteria on embeds_one association' do
146
+ before do
147
+ class Entry
148
+ embeds_one :sub_entry
149
+ end
150
+
151
+ class SubEntry
152
+ include Mongoid::Document
153
+ include Mongoid::I18n
154
+ localized_field :subtitle
155
+ embedded_in :entry, :inverse_of => :sub_entries
156
+ end
157
+ @entry = Entry.new
158
+ end
159
+
160
+ it "should store the title in the right locale" do
161
+ @entry.create_sub_entry(:subtitle => "Oxford Street")
162
+
163
+ @entry.reload
164
+
165
+ @entry.sub_entry.subtitle.should == 'Oxford Street'
166
+ end
143
167
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_i18n
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 1
9
- - 6
10
- version: 0.1.6
8
+ - 7
9
+ version: 0.1.7
11
10
  platform: ruby
12
11
  authors:
13
12
  - "Rodrigo \xC3\x81lvarez"
@@ -15,18 +14,16 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-08-18 00:00:00 +02:00
17
+ date: 2010-08-29 00:00:00 +02:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: mongoid
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
25
  - - ">="
28
26
  - !ruby/object:Gem::Version
29
- hash: 62196465
30
27
  segments:
31
28
  - 2
32
29
  - 0
@@ -40,11 +37,9 @@ dependencies:
40
37
  name: rspec
41
38
  prerelease: false
42
39
  requirement: &id002 !ruby/object:Gem::Requirement
43
- none: false
44
40
  requirements:
45
41
  - - ">="
46
42
  - !ruby/object:Gem::Version
47
- hash: 62196467
48
43
  segments:
49
44
  - 2
50
45
  - 0
@@ -91,27 +86,23 @@ rdoc_options:
91
86
  require_paths:
92
87
  - lib
93
88
  required_ruby_version: !ruby/object:Gem::Requirement
94
- none: false
95
89
  requirements:
96
90
  - - ">="
97
91
  - !ruby/object:Gem::Version
98
- hash: 3
99
92
  segments:
100
93
  - 0
101
94
  version: "0"
102
95
  required_rubygems_version: !ruby/object:Gem::Requirement
103
- none: false
104
96
  requirements:
105
97
  - - ">="
106
98
  - !ruby/object:Gem::Version
107
- hash: 3
108
99
  segments:
109
100
  - 0
110
101
  version: "0"
111
102
  requirements: []
112
103
 
113
104
  rubyforge_project:
114
- rubygems_version: 1.3.7
105
+ rubygems_version: 1.3.6
115
106
  signing_key:
116
107
  specification_version: 3
117
108
  summary: Mongoid plugin to deal with localizable fields