symbolize 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -66,7 +66,8 @@ Other examples:
66
66
  symbolize :browser, :in => [:firefox, :opera], :i18n => false, :methods => true
67
67
 
68
68
  # Scopes
69
- symbolize :angry, :in => [true, false], :scopes => true
69
+ symbolize :angry, :in => [true, false], :scopes => true # AR
70
+ symbolize :angry, :type => Boolean, :scopes => true # Mongoid
70
71
 
71
72
  # Don`t validate
72
73
  symbolize :lang, :in => [:ruby, :js, :c, :erlang], :validate => false
@@ -101,9 +102,14 @@ In our User example, browser has this option, so you can do:
101
102
 
102
103
  === Booleans
103
104
 
104
- Its possible to use boolean fields also.
105
+ Its possible to use boolean fields also. Looks better in Mongoid.
106
+
107
+ # ActiveRecord
105
108
  symbolize :switch, :in => [true, false]
106
109
 
110
+ # Mongoid
111
+ symbolize :switch, :type => Boolean
112
+
107
113
  ...
108
114
  switch:
109
115
  "true": On
@@ -118,16 +124,15 @@ If you don`t provide a hash with values, it will try i18n:
118
124
  activerecord:
119
125
  or
120
126
  mongoid:
121
- attributes:
127
+ symbolizes:
122
128
  user:
123
- enums:
124
- gui:
125
- gnome: Gnome Desktop Enviroment
126
- kde: K Desktop Enviroment
127
- xfce: XFCE4
128
- gender:
129
- female: Girl
130
- male: Boy
129
+ gui:
130
+ gnome: Gnome Desktop Enviroment
131
+ kde: K Desktop Enviroment
132
+ xfce: XFCE4
133
+ gender:
134
+ female: Girl
135
+ male: Boy
131
136
 
132
137
 
133
138
  You can skip i18n lookup with :i18n => false
data/Rakefile CHANGED
@@ -11,16 +11,19 @@ desc "Builds the gem"
11
11
  task :gem => :build
12
12
  task :build do
13
13
  system "gem build symbolize.gemspec"
14
+ Dir.mkdir("pkg") unless Dir.exists?("pkg")
15
+ system "mv symbolize-#{Symbolize::VERSION}.gem pkg/"
14
16
  end
15
17
 
16
18
  task :install => :build do
17
- system "sudo gem install symbolize-#{Symbolize::VERSION}.gem"
19
+ system "sudo gem install pkg/symbolize-#{Symbolize::VERSION}.gem"
18
20
  end
19
21
 
22
+ desc "Release the gem - Gemcutter"
20
23
  task :release => :build do
21
24
  system "git tag -a v#{Symbolize::VERSION} -m 'Tagging #{Symbolize::VERSION}'"
22
25
  system "git push --tags"
23
- system "gem push symbolize-#{Symbolize::VERSION}.gem"
26
+ system "gem push pkg/symbolize-#{Symbolize::VERSION}.gem"
24
27
  end
25
28
 
26
29
 
@@ -24,12 +24,11 @@ module Symbolize
24
24
  # It will automattically lookup for i18n:
25
25
  #
26
26
  # activerecord:
27
- # attributes:
27
+ # symbolizes:
28
28
  # user:
29
- # enums:
30
- # gender:
31
- # female: Girl
32
- # male: Boy
29
+ # gender:
30
+ # female: Girl
31
+ # male: Boy
33
32
  #
34
33
  # You can skip i18n lookup with :i18n => false
35
34
  # symbolize :gender, :in => [:female, :male], :i18n => false
@@ -56,7 +55,7 @@ module Symbolize
56
55
  scopes = configuration.delete :scopes
57
56
  methods = configuration.delete :methods
58
57
  capitalize = configuration.delete :capitalize
59
- validation = configuration.delete(:validation) != false
58
+ validation = configuration.delete(:validate) != false
60
59
  default_option = configuration.delete :default
61
60
 
62
61
  unless enum.nil?
@@ -80,7 +79,7 @@ module Symbolize
80
79
  const_set const.upcase, values unless const_defined? const.upcase
81
80
  ev = if i18n
82
81
  # This one is a dropdown helper
83
- code = "#{const.upcase}.map { |k,v| [I18n.translate(\"activerecord.attributes.\#{ActiveSupport::Inflector.underscore(self.model_name)}.enums.#{attr_name}.\#{k}\"), k] }" #.to_sym rescue nila
82
+ code = "#{const.upcase}.map { |k,v| [I18n.translate(\"activerecord.symbolizes.\#{ActiveSupport::Inflector.underscore(self.model_name)}.#{attr_name}.\#{k}\"), k] }" #.to_sym rescue nila
84
83
  "def self.get_#{const}; #{code}; end;"
85
84
  else
86
85
  "def self.get_#{const}; #{const.upcase}.map(&:reverse); end"
@@ -109,8 +108,8 @@ module Symbolize
109
108
  end
110
109
 
111
110
  if validation
112
- validation = "validates_inclusion_of :#{attr_names.join(', :')}"
113
- validation += ", :in => #{values.keys.inspect}"
111
+ validation = "validates :#{attr_names.join(', :')}"
112
+ validation += ", :inclusion => { :in => #{values.keys.inspect} }"
114
113
  validation += ", :allow_nil => true" if configuration[:allow_nil]
115
114
  validation += ", :allow_blank => true" if configuration[:allow_blank]
116
115
  class_eval validation
@@ -158,7 +157,7 @@ module Symbolize
158
157
  def read_i18n_attribute attr_name
159
158
  attr = read_attribute(attr_name)
160
159
  return nil if attr.nil?
161
- I18n.translate("activerecord.attributes.#{ActiveSupport::Inflector.underscore(self.class.model_name)}.enums.#{attr_name}.#{attr}") #.to_sym rescue nila
160
+ I18n.translate("activerecord.symbolizes.#{ActiveSupport::Inflector.underscore(self.class.model_name)}.#{attr_name}.#{attr}") #.to_sym rescue nila
162
161
  end
163
162
 
164
163
  # Write a symbolized value. Watch out for booleans.
@@ -27,12 +27,11 @@ module Mongoid
27
27
  # It will automattically lookup for i18n:
28
28
  #
29
29
  # models:
30
- # attributes:
30
+ # symbolizes:
31
31
  # user:
32
- # enums:
33
- # gender:
34
- # female: Girl
35
- # male: Boy
32
+ # gender:
33
+ # female: Girl
34
+ # male: Boy
36
35
  #
37
36
  # You can skip i18n lookup with :i18n => false
38
37
  # symbolize :gender, :in => [:female, :male], :i18n => false
@@ -55,12 +54,14 @@ module Mongoid
55
54
  configuration.update(attr_names.extract_options!)
56
55
 
57
56
  enum = configuration[:in] || configuration[:within]
58
- i18n = configuration.delete(:i18n).nil? && !enum.instance_of?(Hash) && enum ? true : configuration[:i18n]
57
+ i18n = configuration.delete(:i18n).nil? && !enum.instance_of?(Hash) ? true : configuration[:i18n]
59
58
  scopes = configuration.delete :scopes
60
59
  methods = configuration.delete :methods
61
- capitalize = configuration.delete :capitalize
62
- validation = configuration.delete(:validation) != false
60
+ capitalize = configuration.delete :capitalize
61
+ validation = configuration.delete(:validate) != false
62
+ field_type = configuration.delete :type
63
63
  default_opt = configuration.delete :default
64
+ enum = [true, false] if field_type == Boolean
64
65
 
65
66
  unless enum.nil?
66
67
 
@@ -70,7 +71,7 @@ module Mongoid
70
71
  #
71
72
  # Builds Mongoid 'field :name, type: type, :default'
72
73
  #
73
- mongo_opts = ", :type => Symbol"
74
+ mongo_opts = ", :type => #{field_type || 'Symbol'}"
74
75
  mongo_opts += ", :default => :#{default_opt}" if default_opt
75
76
  class_eval("field :#{attr_name} #{mongo_opts}")
76
77
 
@@ -89,7 +90,7 @@ module Mongoid
89
90
  const_set const.upcase, values unless const_defined? const.upcase
90
91
  ev = if i18n
91
92
  # This one is a dropdown helper
92
- code = "#{const.upcase}.map { |k,v| [I18n.t(\"mongoid.attributes.\#{ActiveSupport::Inflector.underscore(self.model_name)}.enums.#{attr_name}.\#{k}\"), k] }" #.to_sym rescue nila
93
+ code = "#{const.upcase}.map { |k,v| [I18n.t(\"mongoid.symbolizes.\#{ActiveSupport::Inflector.underscore(self.model_name)}.#{attr_name}.\#{k}\"), k] }" #.to_sym rescue nila
93
94
  "def self.get_#{const}; #{code}; end;"
94
95
  else
95
96
  "def self.get_#{const}; #{const.upcase}.map(&:reverse); end"
@@ -114,8 +115,8 @@ module Mongoid
114
115
  end
115
116
 
116
117
  if validation
117
- validation = "validates_inclusion_of :#{attr_names.join(', :')}"
118
- validation += ", :in => #{values.keys.inspect}"
118
+ validation = "validates :#{attr_names.join(', :')}"
119
+ validation += ", :inclusion => { :in => #{values.keys.inspect} }"
119
120
  validation += ", :allow_nil => true" if configuration[:allow_nil]
120
121
  validation += ", :allow_blank => true" if configuration[:allow_blank]
121
122
  class_eval validation
@@ -130,7 +131,7 @@ module Mongoid
130
131
  if i18n # memoize call to translate... good idea?
131
132
  define_method "#{attr_name}_text" do
132
133
  return nil unless attr = read_attribute(attr_name)
133
- I18n.t("mongoid.attributes.#{ActiveSupport::Inflector.underscore(self.class.model_name)}.enums.#{attr_name}.#{attr}")
134
+ I18n.t("mongoid.symbolizes.#{ActiveSupport::Inflector.underscore(self.class.model_name)}.#{attr_name}.#{attr}")
134
135
  end
135
136
  elsif enum
136
137
  class_eval("def #{attr_name}_text; #{attr_name.to_s.upcase}_VALUES[#{attr_name}]; end")
@@ -1,3 +1,3 @@
1
1
  module Symbolize
2
- VERSION = '4.1.0'
2
+ VERSION = '4.2.0'
3
3
  end
data/spec/locales/en.yml CHANGED
@@ -1,16 +1,15 @@
1
1
  en:
2
2
  activerecord:
3
3
  attributes:
4
+ symbolizes:
4
5
  user:
5
- enums:
6
- language:
7
- pt: Portuguese
8
- en: English
9
- sex:
10
- "true": Female
11
- "false": Male
6
+ language:
7
+ pt: Portuguese
8
+ en: English
9
+ sex:
10
+ "true": Female
11
+ "false": Male
12
12
  user_skill:
13
- enums:
14
- kind:
15
- magic: Magic
16
- agility: Agility
13
+ kind:
14
+ magic: Magic
15
+ agility: Agility
data/spec/locales/pt.yml CHANGED
@@ -1,34 +1,30 @@
1
1
  pt:
2
2
  activerecord:
3
- attributes:
3
+ symbolizes:
4
4
  user:
5
- enums:
6
- language:
7
- pt: Português
8
- en: Inglês
9
- sex:
10
- "true": Feminino
11
- "false": Masculino
5
+ language:
6
+ pt: Português
7
+ en: Inglês
8
+ sex:
9
+ "true": Feminino
10
+ "false": Masculino
12
11
  user_skill:
13
- enums:
14
- kind:
15
- magic: Mágica
16
- agility: Agilidade
12
+ kind:
13
+ magic: Mágica
14
+ agility: Agilidade
17
15
  errors:
18
16
  messages: &errors_messages
19
17
  record_invalid: Inválido
20
18
  mongoid:
21
- attributes:
19
+ symbolizes:
22
20
  person:
23
- enums:
24
- language:
25
- pt: Português
26
- en: Inglês
27
- sex:
28
- "true": Feminino
29
- "false": Masculino
21
+ language:
22
+ pt: Português
23
+ en: Inglês
24
+ sex:
25
+ "true": Feminino
26
+ "false": Masculino
30
27
  person_skill:
31
- enums:
32
- kind:
33
- magic: Mágica
34
- agility: Agilidade
28
+ kind:
29
+ magic: Mágica
30
+ agility: Agilidade
@@ -11,7 +11,6 @@ else
11
11
  CreateTestingStructure.migrate(:up)
12
12
  end
13
13
 
14
- require 'support/ar_models'
15
14
 
16
15
  puts "Running AR #{ActiveRecord::VERSION::STRING}"
17
16
  # Spec::Runner.configure do |config|
@@ -1,5 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
  require 'mongoid'
3
+ require 'mongoid/version'
3
4
 
4
5
  Mongoid.configure do |config|
5
6
  config.master = Mongo::Connection.new.db("symbolize_test")
@@ -11,7 +12,6 @@ Mongoid.database.collections.each do |collection|
11
12
  end
12
13
  end
13
14
 
14
- puts "Running Mongoid 2"
15
+ puts "Running Mongoid #{Mongoid::VERSION}"
15
16
 
16
17
  require 'symbolize/mongoid'
17
- require 'support/mongoid_models'
@@ -1,6 +1,48 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require File.dirname(__FILE__) + '/../spec_helper_ar'
3
3
 
4
+ #
5
+ # Test model
6
+ class User < ActiveRecord::Base
7
+ symbolize :other
8
+ symbolize :language, :in => [:pt, :en]
9
+ symbolize :sex, :in => [true, false], :scopes => true
10
+ symbolize :status , :in => [:active, :inactive], :i18n => false, :capitalize => true, :scopes => true, :methods => true
11
+ symbolize :so, :allow_blank => true, :in => {
12
+ :linux => 'Linux',
13
+ :mac => 'Mac OS X',
14
+ :win => 'Videogame'
15
+ }, :scopes => true
16
+ symbolize :gui, :allow_blank => true, :in => [:cocoa, :qt, :gtk], :i18n => false
17
+ symbolize :karma, :in => %w{ good bad ugly}, :methods => true, :i18n => false, :allow_nil => true
18
+ symbolize :cool, :in => [true, false], :scopes => true
19
+
20
+ has_many :extras, :dependent => :destroy, :class_name => "UserExtra"
21
+ has_many :access, :dependent => :destroy, :class_name => "UserAccess"
22
+ end
23
+
24
+ class UserSkill < ActiveRecord::Base
25
+ symbolize :kind, :in => [:agility, :magic]
26
+ end
27
+
28
+ class UserExtra < ActiveRecord::Base
29
+ symbolize :key, :in => [:one, :another]
30
+ end
31
+
32
+ class Permission < ActiveRecord::Base
33
+ validates_presence_of :name
34
+ symbolize :kind, :in => [:temp, :perm], :default => :perm
35
+ symbolize :lvl, :in => (1..9).to_a, :i18n => false#, :default => 1
36
+ end
37
+
38
+ # Make with_scope public-usable for testing
39
+ #if ActiveRecord::VERSION::MAJOR < 3
40
+ class << ActiveRecord::Base
41
+ public :with_scope
42
+ end
43
+ #end
44
+
45
+
4
46
  describe "Symbolize" do
5
47
 
6
48
  it "should respond to symbolize" do
@@ -1,6 +1,73 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'spec_helper_mongoid'
3
3
 
4
+ #
5
+ # Test models
6
+ class Person
7
+ include Mongoid::Document
8
+ include Mongoid::Symbolize
9
+ include Mongoid::Timestamps
10
+
11
+ symbolize :other, :i18n => false
12
+ symbolize :language, :in => [:pt, :en]
13
+ symbolize :sex, :type => Boolean, :scopes => true
14
+ symbolize :status , :in => [:active, :inactive], :i18n => false, :capitalize => true, :scopes => true
15
+ symbolize :so, :allow_blank => true, :in => {
16
+ :linux => 'Linux',
17
+ :mac => 'Mac OS X',
18
+ :win => 'Videogame'
19
+ }, :scopes => true
20
+ symbolize :gui, :allow_blank => true, :in => [:cocoa, :qt, :gtk], :i18n => false
21
+ symbolize :karma, :in => %w{good bad ugly}, :methods => true, :i18n => false, :allow_nil => true
22
+ symbolize :planet, :in => %w{earth centauri tatooine}, :default => :earth
23
+ # symbolize :cool, :in => [true, false], :scopes => true
24
+
25
+ symbolize :year, :in => Time.now.year.downto(1980).to_a, :validate => false
26
+
27
+ has_many :rights, :dependent => :destroy
28
+ has_many :extras, :dependent => :destroy, :class_name => "PersonExtra"
29
+ embeds_many :skills, :class_name => "PersonSkill"
30
+ end
31
+
32
+ class PersonSkill
33
+ include Mongoid::Document
34
+ include Mongoid::Symbolize
35
+ embedded_in :person, :inverse_of => :skills
36
+
37
+ symbolize :kind, :in => [:agility, :magic]
38
+ end
39
+
40
+ class PersonExtra
41
+ include Mongoid::Document
42
+ include Mongoid::Symbolize
43
+ belongs_to :person, :inverse_of => :extras
44
+
45
+ symbolize :key, :in => [:one, :another]
46
+ end
47
+
48
+ class Right
49
+ include Mongoid::Document
50
+ include Mongoid::Symbolize
51
+
52
+ validates :name, :presence => true
53
+ symbolize :kind, :in => [:temp, :perm], :default => :perm
54
+ end
55
+
56
+
57
+ class Project
58
+ include Mongoid::Document
59
+
60
+ field :name
61
+ field :state, :default => 'active'
62
+
63
+ # Comment 1 line and it works, both fails:
64
+ default_scope where(:state => 'active')
65
+ # scope :inactive, any_in(:state => [:done, :wip])
66
+ scope :dead, all_of(:state => :wip, :name => "zim")
67
+
68
+ end
69
+
70
+
4
71
  describe "Symbolize" do
5
72
 
6
73
  it "should be a module" do
@@ -8,9 +75,9 @@ describe "Symbolize" do
8
75
  end
9
76
 
10
77
  it "should instantiate" do
11
- anna = Person.create(:name => 'Anna', :so => :mac, :gui => :cocoa, :language => :pt, :status => :active)
12
- anna.should be_valid
13
- # anna.errors.messages.should eql({})
78
+ anna = Person.create(:name => 'Anna', :so => :mac, :gui => :cocoa, :language => :pt, :status => :active, :sex => true)
79
+ #anna.should be_valid
80
+ anna.errors.messages.should eql({})
14
81
  end
15
82
 
16
83
  describe "Person Instantiated" do
@@ -38,19 +105,19 @@ describe "Symbolize" do
38
105
  # # person.read_attribute(:status).should be_nil
39
106
  # end
40
107
 
41
- # it "should acts nice with nil" do
42
- # person.status = nil
43
- # person.status.should be_nil
44
- # person.status_before_type_cast.should be_nil
45
- # person.read_attribute(:status).should be_nil
46
- # end
108
+ it "should acts nice with nil" do
109
+ person.karma = nil
110
+ person.karma.should be_nil
111
+ person.save
112
+ person.read_attribute(:karma).should be_nil
113
+ end
47
114
 
48
- # it "should acts nice with blank" do
49
- # person.status = ""
50
- # person.status.should be_nil
51
- # person.status_before_type_cast.should be_nil
52
- # person.read_attribute(:status).should be_nil
53
- # end
115
+ it "should acts nice with blank" do
116
+ person.so = ""
117
+ person.so.should be_blank
118
+ person.save
119
+ person.read_attribute(:so).should be_blank
120
+ end
54
121
 
55
122
  it "should not validates other" do
56
123
  person.other = nil
@@ -64,6 +131,14 @@ describe "Symbolize" do
64
131
  Person::STATUS_VALUES.should eql({ inactive: "Inactive", active: "Active"})
65
132
  end
66
133
 
134
+ it "should have a human _text method" do
135
+ person.status_text.should eql("Active")
136
+ end
137
+
138
+ it "should work nice with i18n" do
139
+ person.language_text.should eql("Português")
140
+ end
141
+
67
142
  it "test_symbolize_humanize" do
68
143
  person.status_text.should eql("Active")
69
144
  end
@@ -152,17 +227,17 @@ describe "Symbolize" do
152
227
  Person::LANGUAGE_VALUES.should eql({:pt=>"pt", :en=>"en"})
153
228
  end
154
229
 
155
- # it "should test boolean" do
156
- # person.sex_text.should eql("Feminino")
157
- # end
230
+ it "should test boolean" do
231
+ person.sex_text.should eql("Feminino")
232
+ end
158
233
 
159
- # it "should get the correct values" do
160
- # Person.get_sex_values.should eql([["Feminino", true],["Masculino", false]])
161
- # end
234
+ it "should get the correct values" do
235
+ Person.get_sex_values.should eql([["Feminino", true],["Masculino", false]])
236
+ end
162
237
 
163
- # it "should get the correct values" do
164
- # Person::SEX_VALUES.should eql({true=>"true", false=>"false"})
165
- # end
238
+ it "should get the correct values" do
239
+ Person::SEX_VALUES.should eql({true=>"true", false=>"false"})
240
+ end
166
241
 
167
242
  it "should translate a multiword classname" do
168
243
  skill = PersonSkill.new(:kind => :magic)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: symbolize
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-16 00:00:00.000000000 Z
12
+ date: 2012-01-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n
16
- requirement: &15795620 !ruby/object:Gem::Requirement
16
+ requirement: &16099800 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.6.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *15795620
24
+ version_requirements: *16099800
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &15794700 !ruby/object:Gem::Requirement
27
+ requirement: &16097600 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.8.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *15794700
35
+ version_requirements: *16097600
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: mongoid
38
- requirement: &15788120 !ruby/object:Gem::Requirement
38
+ requirement: &16110420 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.3.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *15788120
46
+ version_requirements: *16110420
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bson_ext
49
- requirement: &15787540 !ruby/object:Gem::Requirement
49
+ requirement: &16107460 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.5.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *15787540
57
+ version_requirements: *16107460
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: sqlite3
60
- requirement: &15786880 !ruby/object:Gem::Requirement
60
+ requirement: &16106020 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.3.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *15786880
68
+ version_requirements: *16106020
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pg
71
- requirement: &15786040 !ruby/object:Gem::Requirement
71
+ requirement: &16121220 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.12.2
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *15786040
79
+ version_requirements: *16121220
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: activerecord
82
- requirement: &15784660 !ruby/object:Gem::Requirement
82
+ requirement: &16119380 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: 3.1.0
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *15784660
90
+ version_requirements: *16119380
91
91
  description: ActiveRecord/Mongoid enums with i18n
92
92
  email: x@nofxx.com
93
93
  executables: []
@@ -99,8 +99,6 @@ files:
99
99
  - lib/symbolize/version.rb
100
100
  - lib/symbolize/active_record.rb
101
101
  - lib/symbolize/railtie.rb
102
- - spec/support/ar_models.rb
103
- - spec/support/mongoid_models.rb
104
102
  - spec/spec_helper_ar.rb
105
103
  - spec/locales/en.yml
106
104
  - spec/locales/pt.yml
@@ -126,7 +124,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
124
  version: '0'
127
125
  segments:
128
126
  - 0
129
- hash: 1782796710470930293
127
+ hash: 4056837590363536346
130
128
  required_rubygems_version: !ruby/object:Gem::Requirement
131
129
  none: false
132
130
  requirements:
@@ -1,41 +0,0 @@
1
-
2
- #
3
- # Test model
4
- class User < ActiveRecord::Base
5
- symbolize :other
6
- symbolize :language, :in => [:pt, :en]
7
- symbolize :sex, :in => [true, false], :scopes => true
8
- symbolize :status , :in => [:active, :inactive], :i18n => false, :capitalize => true, :scopes => true, :methods => true
9
- symbolize :so, :allow_blank => true, :in => {
10
- :linux => 'Linux',
11
- :mac => 'Mac OS X',
12
- :win => 'Videogame'
13
- }, :scopes => true
14
- symbolize :gui, :allow_blank => true, :in => [:cocoa, :qt, :gtk], :i18n => false
15
- symbolize :karma, :in => %w{ good bad ugly}, :methods => true, :i18n => false, :allow_nil => true
16
- symbolize :cool, :in => [true, false], :scopes => true
17
-
18
- has_many :extras, :dependent => :destroy, :class_name => "UserExtra"
19
- has_many :access, :dependent => :destroy, :class_name => "UserAccess"
20
- end
21
-
22
- class UserSkill < ActiveRecord::Base
23
- symbolize :kind, :in => [:agility, :magic]
24
- end
25
-
26
- class UserExtra < ActiveRecord::Base
27
- symbolize :key, :in => [:one, :another]
28
- end
29
-
30
- class Permission < ActiveRecord::Base
31
- validates_presence_of :name
32
- symbolize :kind, :in => [:temp, :perm], :default => :perm
33
- symbolize :lvl, :in => (1..9).to_a, :i18n => false#, :default => 1
34
- end
35
-
36
- # Make with_scope public-usable for testing
37
- #if ActiveRecord::VERSION::MAJOR < 3
38
- class << ActiveRecord::Base
39
- public :with_scope
40
- end
41
- #end
@@ -1,64 +0,0 @@
1
-
2
- #
3
- # Test model
4
- class Person
5
- include Mongoid::Document
6
- include Mongoid::Symbolize
7
- include Mongoid::Timestamps
8
-
9
- symbolize :other
10
- symbolize :language, :in => [:pt, :en]
11
- # symbolize :sex, :in => [true, false], :scopes => true
12
- symbolize :status , :in => [:active, :inactive], :i18n => false, :capitalize => true, :scopes => true
13
- symbolize :so, :allow_blank => true, :in => {
14
- :linux => 'Linux',
15
- :mac => 'Mac OS X',
16
- :win => 'Videogame'
17
- }, :scopes => true
18
- symbolize :gui, :allow_blank => true, :in => [:cocoa, :qt, :gtk], :i18n => false
19
- symbolize :karma, :in => %w{good bad ugly}, :methods => true, :i18n => false, :allow_nil => true
20
- symbolize :planet, :in => %w{earth centauri tatooine}, :default => :earth
21
- # symbolize :cool, :in => [true, false], :scopes => true
22
-
23
- has_many :rights, :dependent => :destroy
24
- has_many :extras, :dependent => :destroy, :class_name => "PersonExtra"
25
- embeds_many :skills, :class_name => "PersonSkill"
26
- end
27
-
28
- class PersonSkill
29
- include Mongoid::Document
30
- include Mongoid::Symbolize
31
- embedded_in :person, :inverse_of => :skills
32
-
33
- symbolize :kind, :in => [:agility, :magic]
34
- end
35
-
36
- class PersonExtra
37
- include Mongoid::Document
38
- include Mongoid::Symbolize
39
- belongs_to :person, :inverse_of => :extras
40
-
41
- symbolize :key, :in => [:one, :another]
42
- end
43
-
44
- class Right
45
- include Mongoid::Document
46
- include Mongoid::Symbolize
47
-
48
- validates_presence_of :name
49
- symbolize :kind, :in => [:temp, :perm], :default => :perm
50
- end
51
-
52
-
53
- class Project
54
- include Mongoid::Document
55
-
56
- field :name
57
- field :state, :default => 'active'
58
-
59
- # Comment 1 line and it works, both fails:
60
- default_scope where(:state => 'active')
61
- # scope :inactive, any_in(:state => [:done, :wip])
62
- scope :dead, all_of(:state => :wip, :name => "zim")
63
-
64
- end