mongoid_i18n 0.1.8 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm 1.8.7-p299
1
+ rvm 1.8.7-p334
data/Gemfile CHANGED
@@ -1,8 +1,8 @@
1
1
  source :gemcutter
2
2
 
3
- gem 'bson_ext'
4
- gem 'mongoid', '>= 2.0.0.beta.9'
5
- gem 'rspec', '>= 2.0.0.beta.8'
3
+ gem 'bson_ext', "~> 1.2"
4
+ gem 'mongoid', '>= 2.0.0'
5
+ gem 'rspec'
6
6
  gem 'mocha'
7
7
  gem 'jeweler'
8
8
  gem 'bundler'
data/Gemfile.lock CHANGED
@@ -1,49 +1,48 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activemodel (3.0.3)
5
- activesupport (= 3.0.3)
4
+ activemodel (3.0.6)
5
+ activesupport (= 3.0.6)
6
6
  builder (~> 2.1.2)
7
- i18n (~> 0.4)
8
- activesupport (3.0.3)
9
- bson (1.1.2)
10
- bson_ext (1.1.2)
7
+ i18n (~> 0.5.0)
8
+ activesupport (3.0.6)
9
+ bson (1.3.0)
10
+ bson_ext (1.3.0)
11
11
  builder (2.1.2)
12
12
  diff-lcs (1.1.2)
13
13
  git (1.2.5)
14
- i18n (0.4.2)
15
- jeweler (1.5.1)
14
+ i18n (0.5.0)
15
+ jeweler (1.5.2)
16
16
  bundler (~> 1.0.0)
17
17
  git (>= 1.2.5)
18
18
  rake
19
- mocha (0.9.9)
20
- rake
21
- mongo (1.1.2)
22
- bson (>= 1.1.1)
23
- mongoid (2.0.0.beta.20)
19
+ mocha (0.9.12)
20
+ mongo (1.3.0)
21
+ bson (>= 1.3.0)
22
+ mongoid (2.0.1)
24
23
  activemodel (~> 3.0)
25
- mongo (~> 1.1)
24
+ mongo (~> 1.3)
26
25
  tzinfo (~> 0.3.22)
27
26
  will_paginate (~> 3.0.pre)
28
27
  rake (0.8.7)
29
- rspec (2.1.0)
30
- rspec-core (~> 2.1.0)
31
- rspec-expectations (~> 2.1.0)
32
- rspec-mocks (~> 2.1.0)
33
- rspec-core (2.1.0)
34
- rspec-expectations (2.1.0)
28
+ rspec (2.5.0)
29
+ rspec-core (~> 2.5.0)
30
+ rspec-expectations (~> 2.5.0)
31
+ rspec-mocks (~> 2.5.0)
32
+ rspec-core (2.5.1)
33
+ rspec-expectations (2.5.0)
35
34
  diff-lcs (~> 1.1.2)
36
- rspec-mocks (2.1.0)
37
- tzinfo (0.3.23)
35
+ rspec-mocks (2.5.0)
36
+ tzinfo (0.3.26)
38
37
  will_paginate (3.0.pre2)
39
38
 
40
39
  PLATFORMS
41
40
  ruby
42
41
 
43
42
  DEPENDENCIES
44
- bson_ext
43
+ bson_ext (~> 1.2)
45
44
  bundler
46
45
  jeweler
47
46
  mocha
48
- mongoid (>= 2.0.0.beta.9)
49
- rspec (>= 2.0.0.beta.8)
47
+ mongoid (>= 2.0.0)
48
+ rspec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.8
1
+ 0.2.0
@@ -0,0 +1,10 @@
1
+ module Mongoid
2
+ module Criterion
3
+ class Selector< Hash
4
+ def []=(key, value)
5
+ key = "#{key}.#{::I18n.locale}" if fields[key.to_s].type == Mongoid::I18n::LocalizedField
6
+ super
7
+ end
8
+ end
9
+ end
10
+ end
data/lib/mongoid/i18n.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'mongoid/i18n/localized_field'
2
- require 'mongoid/i18n/localized_criteria'
2
+ require 'mongoid/i18n/criterion/selector'
3
3
 
4
4
  module Mongoid
5
5
  module I18n
@@ -10,11 +10,6 @@ module Mongoid
10
10
  field name, options.merge(:type => LocalizedField)
11
11
  end
12
12
 
13
- def criteria
14
- scope = scope_stack.last rescue nil
15
- scope || I18n::LocalizedCriteria.new(self)
16
- end
17
-
18
13
  protected
19
14
  def create_accessors(name, meth, options = {})
20
15
  if options[:type] == LocalizedField
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.8"
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 = ["Rodrigo \303\201lvarez"]
12
- s.date = %q{2010-11-19}
12
+ s.date = %q{2011-04-08}
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.
@@ -29,43 +29,38 @@ Gem::Specification.new do |s|
29
29
  "Rakefile",
30
30
  "VERSION",
31
31
  "lib/mongoid/i18n.rb",
32
- "lib/mongoid/i18n/localized_criteria.rb",
32
+ "lib/mongoid/i18n/criterion/selector.rb",
33
33
  "lib/mongoid/i18n/localized_field.rb",
34
34
  "mongoid_i18n.gemspec",
35
35
  "spec/.rspec",
36
36
  "spec/integration/mongoid/i18n_spec.rb",
37
- "spec/spec_helper.rb",
38
- "spec/unit/mongoid/i18n/localized_criteria_spec.rb",
39
- "spec/unit/mongoid/i18n_spec.rb"
37
+ "spec/spec_helper.rb"
40
38
  ]
41
39
  s.homepage = %q{http://github.com/Papipo/mongoid_i18n}
42
40
  s.require_paths = ["lib"]
43
- s.rubygems_version = %q{1.3.7}
41
+ s.rubygems_version = %q{1.6.2}
44
42
  s.summary = %q{Mongoid plugin to deal with localizable fields}
45
43
  s.test_files = [
46
44
  "spec/integration/mongoid/i18n_spec.rb",
47
- "spec/spec_helper.rb",
48
- "spec/unit/mongoid/i18n/localized_criteria_spec.rb",
49
- "spec/unit/mongoid/i18n_spec.rb"
45
+ "spec/spec_helper.rb"
50
46
  ]
51
47
 
52
48
  if s.respond_to? :specification_version then
53
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
54
49
  s.specification_version = 3
55
50
 
56
51
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
57
- s.add_runtime_dependency(%q<bson_ext>, [">= 0"])
58
- s.add_runtime_dependency(%q<mongoid>, [">= 2.0.0.beta.9"])
59
- s.add_runtime_dependency(%q<rspec>, [">= 2.0.0.beta.8"])
52
+ s.add_runtime_dependency(%q<bson_ext>, ["~> 1.2"])
53
+ s.add_runtime_dependency(%q<mongoid>, [">= 2.0.0"])
54
+ s.add_runtime_dependency(%q<rspec>, [">= 0"])
60
55
  s.add_runtime_dependency(%q<mocha>, [">= 0"])
61
56
  s.add_runtime_dependency(%q<jeweler>, [">= 0"])
62
57
  s.add_runtime_dependency(%q<bundler>, [">= 0"])
63
58
  s.add_runtime_dependency(%q<mongoid>, [">= 2.0.0.beta.20"])
64
59
  s.add_development_dependency(%q<rspec>, ["= 2.1.0"])
65
60
  else
66
- s.add_dependency(%q<bson_ext>, [">= 0"])
67
- s.add_dependency(%q<mongoid>, [">= 2.0.0.beta.9"])
68
- s.add_dependency(%q<rspec>, [">= 2.0.0.beta.8"])
61
+ s.add_dependency(%q<bson_ext>, ["~> 1.2"])
62
+ s.add_dependency(%q<mongoid>, [">= 2.0.0"])
63
+ s.add_dependency(%q<rspec>, [">= 0"])
69
64
  s.add_dependency(%q<mocha>, [">= 0"])
70
65
  s.add_dependency(%q<jeweler>, [">= 0"])
71
66
  s.add_dependency(%q<bundler>, [">= 0"])
@@ -73,9 +68,9 @@ Gem::Specification.new do |s|
73
68
  s.add_dependency(%q<rspec>, ["= 2.1.0"])
74
69
  end
75
70
  else
76
- s.add_dependency(%q<bson_ext>, [">= 0"])
77
- s.add_dependency(%q<mongoid>, [">= 2.0.0.beta.9"])
78
- s.add_dependency(%q<rspec>, [">= 2.0.0.beta.8"])
71
+ s.add_dependency(%q<bson_ext>, ["~> 1.2"])
72
+ s.add_dependency(%q<mongoid>, [">= 2.0.0"])
73
+ s.add_dependency(%q<rspec>, [">= 0"])
79
74
  s.add_dependency(%q<mocha>, [">= 0"])
80
75
  s.add_dependency(%q<jeweler>, [">= 0"])
81
76
  s.add_dependency(%q<bundler>, [">= 0"])
@@ -6,7 +6,6 @@ class Entry
6
6
  include Mongoid::I18n
7
7
 
8
8
  localized_field :title
9
- field :published, :type => Boolean
10
9
  end
11
10
 
12
11
  describe Mongoid::I18n, "localized_field" do
@@ -133,10 +132,6 @@ describe Mongoid::I18n, 'criteria on embeds_many association' do
133
132
  @sub_entries = (0..2).map { @entry.sub_entries.build }
134
133
  end
135
134
 
136
- it "should return a LocalizedCriteria" do
137
- @entry.sub_entries.criteria.should be_a(Mongoid::I18n::LocalizedCriteria)
138
- end
139
-
140
135
  it "should contain the embedded documents" do
141
136
  @entry.sub_entries.criteria.instance_variable_get("@documents").should == @sub_entries
142
137
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_i18n
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease: false
4
+ hash: 23
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 8
10
- version: 0.1.8
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Rodrigo \xC3\x81lvarez"
@@ -15,64 +15,58 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-19 00:00:00 +01:00
18
+ date: 2011-04-08 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- type: :runtime
23
22
  prerelease: false
24
- name: bson_ext
25
- version_requirements: &id001 !ruby/object:Gem::Requirement
23
+ type: :runtime
24
+ requirement: &id001 !ruby/object:Gem::Requirement
26
25
  none: false
27
26
  requirements:
28
- - - ">="
27
+ - - ~>
29
28
  - !ruby/object:Gem::Version
30
- hash: 3
29
+ hash: 11
31
30
  segments:
32
- - 0
33
- version: "0"
34
- requirement: *id001
31
+ - 1
32
+ - 2
33
+ version: "1.2"
34
+ name: bson_ext
35
+ version_requirements: *id001
35
36
  - !ruby/object:Gem::Dependency
36
- type: :runtime
37
37
  prerelease: false
38
- name: mongoid
39
- version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ type: :runtime
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ">="
43
43
  - !ruby/object:Gem::Version
44
- hash: 62196465
44
+ hash: 15
45
45
  segments:
46
46
  - 2
47
47
  - 0
48
48
  - 0
49
- - beta
50
- - 9
51
- version: 2.0.0.beta.9
52
- requirement: *id002
49
+ version: 2.0.0
50
+ name: mongoid
51
+ version_requirements: *id002
53
52
  - !ruby/object:Gem::Dependency
54
- type: :runtime
55
53
  prerelease: false
56
- name: rspec
57
- version_requirements: &id003 !ruby/object:Gem::Requirement
54
+ type: :runtime
55
+ requirement: &id003 !ruby/object:Gem::Requirement
58
56
  none: false
59
57
  requirements:
60
58
  - - ">="
61
59
  - !ruby/object:Gem::Version
62
- hash: 62196467
60
+ hash: 3
63
61
  segments:
64
- - 2
65
- - 0
66
62
  - 0
67
- - beta
68
- - 8
69
- version: 2.0.0.beta.8
70
- requirement: *id003
63
+ version: "0"
64
+ name: rspec
65
+ version_requirements: *id003
71
66
  - !ruby/object:Gem::Dependency
72
- type: :runtime
73
67
  prerelease: false
74
- name: mocha
75
- version_requirements: &id004 !ruby/object:Gem::Requirement
68
+ type: :runtime
69
+ requirement: &id004 !ruby/object:Gem::Requirement
76
70
  none: false
77
71
  requirements:
78
72
  - - ">="
@@ -81,12 +75,12 @@ dependencies:
81
75
  segments:
82
76
  - 0
83
77
  version: "0"
84
- requirement: *id004
78
+ name: mocha
79
+ version_requirements: *id004
85
80
  - !ruby/object:Gem::Dependency
86
- type: :runtime
87
81
  prerelease: false
88
- name: jeweler
89
- version_requirements: &id005 !ruby/object:Gem::Requirement
82
+ type: :runtime
83
+ requirement: &id005 !ruby/object:Gem::Requirement
90
84
  none: false
91
85
  requirements:
92
86
  - - ">="
@@ -95,12 +89,12 @@ dependencies:
95
89
  segments:
96
90
  - 0
97
91
  version: "0"
98
- requirement: *id005
92
+ name: jeweler
93
+ version_requirements: *id005
99
94
  - !ruby/object:Gem::Dependency
100
- type: :runtime
101
95
  prerelease: false
102
- name: bundler
103
- version_requirements: &id006 !ruby/object:Gem::Requirement
96
+ type: :runtime
97
+ requirement: &id006 !ruby/object:Gem::Requirement
104
98
  none: false
105
99
  requirements:
106
100
  - - ">="
@@ -109,12 +103,12 @@ dependencies:
109
103
  segments:
110
104
  - 0
111
105
  version: "0"
112
- requirement: *id006
106
+ name: bundler
107
+ version_requirements: *id006
113
108
  - !ruby/object:Gem::Dependency
114
- type: :runtime
115
109
  prerelease: false
116
- name: mongoid
117
- version_requirements: &id007 !ruby/object:Gem::Requirement
110
+ type: :runtime
111
+ requirement: &id007 !ruby/object:Gem::Requirement
118
112
  none: false
119
113
  requirements:
120
114
  - - ">="
@@ -127,12 +121,12 @@ dependencies:
127
121
  - beta
128
122
  - 20
129
123
  version: 2.0.0.beta.20
130
- requirement: *id007
124
+ name: mongoid
125
+ version_requirements: *id007
131
126
  - !ruby/object:Gem::Dependency
132
- type: :development
133
127
  prerelease: false
134
- name: rspec
135
- version_requirements: &id008 !ruby/object:Gem::Requirement
128
+ type: :development
129
+ requirement: &id008 !ruby/object:Gem::Requirement
136
130
  none: false
137
131
  requirements:
138
132
  - - "="
@@ -143,7 +137,8 @@ dependencies:
143
137
  - 1
144
138
  - 0
145
139
  version: 2.1.0
146
- requirement: *id008
140
+ name: rspec
141
+ version_requirements: *id008
147
142
  description: "This gem aims to be a transparent way to deal with localizable fields.\n Basically use localized_field() instead of field() and that's it.\n It will take care of locales for you when using find or criteria.\n "
148
143
  email: papipo@gmail.com
149
144
  executables: []
@@ -163,14 +158,12 @@ files:
163
158
  - Rakefile
164
159
  - VERSION
165
160
  - lib/mongoid/i18n.rb
166
- - lib/mongoid/i18n/localized_criteria.rb
161
+ - lib/mongoid/i18n/criterion/selector.rb
167
162
  - lib/mongoid/i18n/localized_field.rb
168
163
  - mongoid_i18n.gemspec
169
164
  - spec/.rspec
170
165
  - spec/integration/mongoid/i18n_spec.rb
171
166
  - spec/spec_helper.rb
172
- - spec/unit/mongoid/i18n/localized_criteria_spec.rb
173
- - spec/unit/mongoid/i18n_spec.rb
174
167
  has_rdoc: true
175
168
  homepage: http://github.com/Papipo/mongoid_i18n
176
169
  licenses: []
@@ -201,12 +194,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
194
  requirements: []
202
195
 
203
196
  rubyforge_project:
204
- rubygems_version: 1.3.7
197
+ rubygems_version: 1.6.2
205
198
  signing_key:
206
199
  specification_version: 3
207
200
  summary: Mongoid plugin to deal with localizable fields
208
201
  test_files:
209
202
  - spec/integration/mongoid/i18n_spec.rb
210
203
  - spec/spec_helper.rb
211
- - spec/unit/mongoid/i18n/localized_criteria_spec.rb
212
- - spec/unit/mongoid/i18n_spec.rb
@@ -1,19 +0,0 @@
1
- module Mongoid
2
- module I18n
3
- class LocalizedCriteria < Mongoid::Criteria
4
- def where(selector = nil)
5
- super
6
- expand_localized_fields_in_selector if selector.is_a?(Hash)
7
- self
8
- end
9
-
10
- protected
11
-
12
- def expand_localized_fields_in_selector
13
- @klass.fields.select { |k,f| @selector.keys.include?(k.to_sym) && f.type == LocalizedField }.each do |k,v|
14
- @selector["#{k}.#{::I18n.locale}"] = @selector.delete(k.to_sym)
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Mongoid::I18n::LocalizedCriteria do
4
- describe "where" do
5
- before do
6
- @title = Mongoid::Field.new(:title, :type => Mongoid::I18n::LocalizedField)
7
- @published = Mongoid::Field.new(:published, :type => Boolean)
8
- klass = stub(:fields => {'title' => @title, 'published' => @published})
9
- @criteria = Mongoid::I18n::LocalizedCriteria.new(klass)
10
- @criteria.where(:title.in => ['Title'], :published => true)
11
- end
12
-
13
- it "should expand fields that are LocalizedFields" do
14
- @criteria.instance_variable_get("@selector").should == {'title.en' => {'$in' => ['Title']}, :published => true}
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe Mongoid::I18n do
5
- before do
6
- @class = Class.new do
7
- include Mongoid::I18n
8
- end
9
- I18n.stubs(:locale).returns(:en)
10
- end
11
-
12
- describe "criteria" do
13
- it "should return a LocalizedCriteria" do
14
- @class.criteria.should be_a(Mongoid::I18n::LocalizedCriteria)
15
- end
16
- end
17
- end