mongoid_i18n 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,8 +1,8 @@
1
1
  source :gemcutter
2
2
 
3
3
  gem 'bson_ext'
4
- gem 'mongoid', '2.0.0.beta6'
5
- gem 'rspec', '2.0.0.beta.8'
4
+ gem 'mongoid', '>= 2.0.0.beta9'
5
+ gem 'rspec', '>= 2.0.0.beta.8'
6
6
  gem 'mocha'
7
-
8
- gem 'jeweler'
7
+ gem 'jeweler'
8
+ gem 'bundler'
data/Rakefile CHANGED
@@ -11,13 +11,13 @@ begin
11
11
  gem.summary = %Q{Mongoid plugin to deal with localizable fields}
12
12
  gem.description = %Q{This gem aims to be a transparent way to deal with localizable fields.
13
13
  Basically use localized_field() instead of field() and that's it.
14
- It will take care of locales for you when using find.
14
+ It will take care of locales for you when using find or criteria.
15
15
  }
16
16
  gem.email = "papipo@gmail.com"
17
17
  gem.homepage = "http://github.com/Papipo/mongoid_i18n"
18
18
  gem.authors = ["Rodrigo Álvarez"]
19
- gem.add_dependency "mongoid", '2.0.0.beta6'
20
- gem.add_development_dependency "rspec", "2.0.0.beta.8"
19
+ gem.add_dependency "mongoid", '>= 2.0.0.beta9'
20
+ gem.add_development_dependency "rspec", ">= 2.0.0.beta.8"
21
21
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
22
22
  end
23
23
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
data/lib/mongoid/i18n.rb CHANGED
@@ -1,5 +1,3 @@
1
- gem 'mongoid', '>= 2.0.0.beta6'
2
- require 'mongoid'
3
1
  require 'mongoid/i18n/localized_field'
4
2
  require 'mongoid/i18n/localized_criteria'
5
3
 
@@ -9,7 +7,7 @@ module Mongoid
9
7
 
10
8
  module ClassMethods
11
9
  def localized_field(name, options = {})
12
- field name, options.merge(:type => LocalizedField, :default => {})
10
+ field name, options.merge(:type => LocalizedField)
13
11
  end
14
12
 
15
13
  def criteria
@@ -19,7 +17,7 @@ module Mongoid
19
17
  protected
20
18
  def create_accessors(name, meth, options = {})
21
19
  if options[:type] == LocalizedField
22
- define_method(meth) { read_attribute(name)[::I18n.locale.to_s] }
20
+ define_method(meth) { read_attribute(name)[::I18n.locale.to_s] rescue '' }
23
21
  define_method("#{meth}=") do |value|
24
22
  write_attribute(name, (@attributes[name] || {}).merge(::I18n.locale.to_s => value))
25
23
  end
@@ -10,7 +10,7 @@ module Mongoid
10
10
  protected
11
11
 
12
12
  def expand_localized_fields_in_selector
13
- @klass.fields.select { |k,f| @selector.keys.include?(k.to_sym) && f.type == LocalizedField }.each_key do |k|
13
+ @klass.fields.select { |k,f| @selector.keys.include?(k.to_sym) && f.type == LocalizedField }.each do |k,v|
14
14
  @selector["#{k}.#{::I18n.locale}"] = @selector.delete(k.to_sym)
15
15
  end
16
16
  end
data/mongoid_i18n.gemspec CHANGED
@@ -5,14 +5,14 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongoid_i18n}
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Rodrigo Álvarez"]
12
- s.date = %q{2010-05-23}
11
+ s.authors = ["Rodrigo \303\201lvarez"]
12
+ s.date = %q{2010-07-06}
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
- It will take care of locales for you when using find.
15
+ It will take care of locales for you when using find or criteria.
16
16
  }
17
17
  s.email = %q{papipo@gmail.com}
18
18
  s.extra_rdoc_files = [
@@ -40,7 +40,7 @@ Gem::Specification.new do |s|
40
40
  s.homepage = %q{http://github.com/Papipo/mongoid_i18n}
41
41
  s.rdoc_options = ["--charset=UTF-8"]
42
42
  s.require_paths = ["lib"]
43
- s.rubygems_version = %q{1.3.6}
43
+ s.rubygems_version = %q{1.3.7}
44
44
  s.summary = %q{Mongoid plugin to deal with localizable fields}
45
45
  s.test_files = [
46
46
  "spec/integration/mongoid/i18n_spec.rb",
@@ -53,16 +53,16 @@ Gem::Specification.new do |s|
53
53
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
54
54
  s.specification_version = 3
55
55
 
56
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
57
- s.add_runtime_dependency(%q<mongoid>, ["= 2.0.0.beta6"])
58
- s.add_development_dependency(%q<rspec>, ["= 2.0.0.beta.8"])
56
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
57
+ s.add_runtime_dependency(%q<mongoid>, [">= 2.0.0.beta9"])
58
+ s.add_development_dependency(%q<rspec>, [">= 2.0.0.beta.8"])
59
59
  else
60
- s.add_dependency(%q<mongoid>, ["= 2.0.0.beta6"])
61
- s.add_dependency(%q<rspec>, ["= 2.0.0.beta.8"])
60
+ s.add_dependency(%q<mongoid>, [">= 2.0.0.beta9"])
61
+ s.add_dependency(%q<rspec>, [">= 2.0.0.beta.8"])
62
62
  end
63
63
  else
64
- s.add_dependency(%q<mongoid>, ["= 2.0.0.beta6"])
65
- s.add_dependency(%q<rspec>, ["= 2.0.0.beta.8"])
64
+ s.add_dependency(%q<mongoid>, [">= 2.0.0.beta9"])
65
+ s.add_dependency(%q<rspec>, [">= 2.0.0.beta.8"])
66
66
  end
67
67
  end
68
68
 
@@ -14,6 +14,16 @@ describe Mongoid::I18n, "localized_field" do
14
14
  I18n.locale = :en
15
15
  end
16
16
 
17
+ describe "without an assigned value" do
18
+ before do
19
+ @entry = Entry.new
20
+ end
21
+
22
+ it "should return blank" do
23
+ @entry.title.should be_blank
24
+ end
25
+ end
26
+
17
27
  describe "with an assigned value" do
18
28
  before do
19
29
  @entry = Entry.new(:title => 'Title')
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
 
4
+ require 'mongoid'
4
5
  require 'mongoid/i18n'
5
6
  require 'rspec'
6
7
  require 'rspec/autorun'
@@ -8,7 +9,7 @@ require 'rspec/autorun'
8
9
  Rspec.configure do |config|
9
10
  config.mock_with :mocha
10
11
  config.after :each do
11
- Mongoid.master.collections.each(&:drop)
12
+ Mongoid.master.collections.reject { |c| c.name =~ /^system\./ }.each(&:drop)
12
13
  end
13
14
  end
14
15
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_i18n
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 19
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 1
8
- - 3
9
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
10
11
  platform: ruby
11
12
  authors:
12
13
  - "Rodrigo \xC3\x81lvarez"
@@ -14,30 +15,35 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-23 00:00:00 +02:00
18
+ date: 2010-07-06 00:00:00 +02:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: mongoid
23
+ prerelease: false
22
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - "="
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
29
+ hash: -1848230043
26
30
  segments:
27
31
  - 2
28
32
  - 0
29
33
  - 0
30
- - beta6
31
- version: 2.0.0.beta6
34
+ - beta9
35
+ version: 2.0.0.beta9
32
36
  type: :runtime
33
- prerelease: false
34
37
  version_requirements: *id001
35
38
  - !ruby/object:Gem::Dependency
36
39
  name: rspec
40
+ prerelease: false
37
41
  requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
38
43
  requirements:
39
- - - "="
44
+ - - ">="
40
45
  - !ruby/object:Gem::Version
46
+ hash: 62196467
41
47
  segments:
42
48
  - 2
43
49
  - 0
@@ -46,9 +52,8 @@ dependencies:
46
52
  - 8
47
53
  version: 2.0.0.beta.8
48
54
  type: :development
49
- prerelease: false
50
55
  version_requirements: *id002
51
- 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.\n "
56
+ 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 "
52
57
  email: papipo@gmail.com
53
58
  executables: []
54
59
 
@@ -84,23 +89,27 @@ rdoc_options:
84
89
  require_paths:
85
90
  - lib
86
91
  required_ruby_version: !ruby/object:Gem::Requirement
92
+ none: false
87
93
  requirements:
88
94
  - - ">="
89
95
  - !ruby/object:Gem::Version
96
+ hash: 3
90
97
  segments:
91
98
  - 0
92
99
  version: "0"
93
100
  required_rubygems_version: !ruby/object:Gem::Requirement
101
+ none: false
94
102
  requirements:
95
103
  - - ">="
96
104
  - !ruby/object:Gem::Version
105
+ hash: 3
97
106
  segments:
98
107
  - 0
99
108
  version: "0"
100
109
  requirements: []
101
110
 
102
111
  rubyforge_project:
103
- rubygems_version: 1.3.6
112
+ rubygems_version: 1.3.7
104
113
  signing_key:
105
114
  specification_version: 3
106
115
  summary: Mongoid plugin to deal with localizable fields