enumerize 0.11.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +0 -4
- data/CHANGELOG.md +10 -0
- data/lib/enumerize/base.rb +2 -4
- data/lib/enumerize/scope/activerecord.rb +2 -2
- data/lib/enumerize/scope/mongoid.rb +2 -2
- data/lib/enumerize/set.rb +4 -0
- data/lib/enumerize/version.rb +1 -1
- data/test/activerecord_test.rb +7 -0
- data/test/set_test.rb +6 -0
- data/test/test_helper.rb +4 -0
- metadata +3 -6
- data/.ruby-version +0 -1
- data/Gemfile.rails32 +0 -23
- data/lib/enumerize/form_helper.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a571fc9e3b62621d40cfddd9ba755389dda8115
|
4
|
+
data.tar.gz: e6a8a7e2043a36b8072a2f28cc547efab248770a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bda0563e282a121e0b5e0a26144a81efc8bde072ebf1a56a357da909421f272cc02b5c7dd85dac6cf7780b42a88e302f7aef020434255682dc9a7d7840e21e9a
|
7
|
+
data.tar.gz: 5c0d858c82b33958edd3a3c8e2b347822641966e6765ad87c7fae7158b1fee0ddaac08ecbc5b88849e392b928c474435e372ceeb2beec7a9c0b3052f937073a3
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -5,7 +5,6 @@ before_install:
|
|
5
5
|
- gem install bundler
|
6
6
|
gemfile:
|
7
7
|
- Gemfile
|
8
|
-
- Gemfile.rails32
|
9
8
|
rvm:
|
10
9
|
- 1.9.3
|
11
10
|
- 2.0.0
|
@@ -13,9 +12,6 @@ rvm:
|
|
13
12
|
- 2.2
|
14
13
|
- jruby-19mode
|
15
14
|
matrix:
|
16
|
-
exclude:
|
17
|
-
- rvm: 2.2
|
18
|
-
gemfile: Gemfile.rails32
|
19
15
|
include:
|
20
16
|
- rvm: 2.2
|
21
17
|
gemfile: Gemfile.rails40
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,16 @@
|
|
4
4
|
|
5
5
|
### bug fix
|
6
6
|
|
7
|
+
## 1.0.0 (August 2, 2015)
|
8
|
+
|
9
|
+
### enhancements
|
10
|
+
* Add `texts` method for getting an array of text values of the enumerized field with multiple type. (by [@huynhquancam](https://github.com/huynhquancam))
|
11
|
+
* Drop Rails 3.2 support. (by [@nashby](https://github.com/nashby))
|
12
|
+
|
13
|
+
### bug fix
|
14
|
+
|
15
|
+
* Fix conflicts when Active Record and Mongoid are used at the same time. (by [@matsu911](https://github.com/matsu911))
|
16
|
+
|
7
17
|
## 0.11.0 (March 29, 2015) ##
|
8
18
|
|
9
19
|
### enhancements
|
data/lib/enumerize/base.rb
CHANGED
@@ -91,11 +91,9 @@ module Enumerize
|
|
91
91
|
|
92
92
|
def _set_default_value_for_enumerized_attributes
|
93
93
|
self.class.enumerized_attributes.each do |attr|
|
94
|
-
|
95
|
-
# https://github.com/brainspec/enumerize/issues/101
|
96
|
-
begin
|
94
|
+
if respond_to?(attr.name)
|
97
95
|
attr_value = public_send(attr.name)
|
98
|
-
|
96
|
+
else
|
99
97
|
next
|
100
98
|
end
|
101
99
|
|
@@ -7,7 +7,7 @@ module Enumerize
|
|
7
7
|
_enumerize_module.dependent_eval do
|
8
8
|
if self < ::ActiveRecord::Base
|
9
9
|
if options[:scope]
|
10
|
-
|
10
|
+
_define_activerecord_scope_methods!(name, options)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -15,7 +15,7 @@ module Enumerize
|
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
-
def
|
18
|
+
def _define_activerecord_scope_methods!(name, options)
|
19
19
|
scope_name = options[:scope] == true ? "with_#{name}" : options[:scope]
|
20
20
|
|
21
21
|
define_singleton_method scope_name do |*values|
|
@@ -7,7 +7,7 @@ module Enumerize
|
|
7
7
|
_enumerize_module.dependent_eval do
|
8
8
|
if self < ::Mongoid::Document
|
9
9
|
if options[:scope]
|
10
|
-
|
10
|
+
_define_mongoid_scope_methods!(name, options)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -15,7 +15,7 @@ module Enumerize
|
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
-
def
|
18
|
+
def _define_mongoid_scope_methods!(name, options)
|
19
19
|
scope_name = options[:scope] == true ? "with_#{name}" : options[:scope]
|
20
20
|
|
21
21
|
define_singleton_method scope_name do |*values|
|
data/lib/enumerize/set.rb
CHANGED
data/lib/enumerize/version.rb
CHANGED
data/test/activerecord_test.rb
CHANGED
@@ -190,6 +190,13 @@ describe Enumerize::ActiveRecordSupport do
|
|
190
190
|
interests.must_equal %w(music dancing)
|
191
191
|
end
|
192
192
|
|
193
|
+
it 'stores multiple value passed passed to new' do
|
194
|
+
user = User.new(interests: [:music, :dancing])
|
195
|
+
user.save!
|
196
|
+
user.interests.must_equal %w(music dancing)
|
197
|
+
User.find(user.id).interests.must_equal %w(music dancing)
|
198
|
+
end
|
199
|
+
|
193
200
|
it 'returns invalid multiple value for validation' do
|
194
201
|
user = User.new
|
195
202
|
user.interests << :music
|
data/test/set_test.rb
CHANGED
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enumerize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Nartimov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -32,12 +32,10 @@ extensions: []
|
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
34
|
- ".gitignore"
|
35
|
-
- ".ruby-version"
|
36
35
|
- ".travis.yml"
|
37
36
|
- CHANGELOG.md
|
38
37
|
- Gemfile
|
39
38
|
- Gemfile.mongo_mapper
|
40
|
-
- Gemfile.rails32
|
41
39
|
- Gemfile.rails40
|
42
40
|
- MIT-LICENSE
|
43
41
|
- README.md
|
@@ -48,7 +46,6 @@ files:
|
|
48
46
|
- lib/enumerize/attribute.rb
|
49
47
|
- lib/enumerize/attribute_map.rb
|
50
48
|
- lib/enumerize/base.rb
|
51
|
-
- lib/enumerize/form_helper.rb
|
52
49
|
- lib/enumerize/hooks/formtastic.rb
|
53
50
|
- lib/enumerize/hooks/simple_form.rb
|
54
51
|
- lib/enumerize/hooks/uniqueness.rb
|
@@ -103,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
100
|
version: '0'
|
104
101
|
requirements: []
|
105
102
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.
|
103
|
+
rubygems_version: 2.4.7
|
107
104
|
signing_key:
|
108
105
|
specification_version: 4
|
109
106
|
summary: Enumerated attributes with I18n and ActiveRecord/Mongoid/MongoMapper support
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.1.5
|
data/Gemfile.rails32
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gemspec
|
4
|
-
|
5
|
-
gem 'rake'
|
6
|
-
gem 'minitest', '~> 4.1'
|
7
|
-
gem 'rspec', :require => false
|
8
|
-
|
9
|
-
gem 'rails', '~> 3.2.0', :require => false
|
10
|
-
gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
|
11
|
-
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
12
|
-
|
13
|
-
platforms :rbx do
|
14
|
-
gem 'rubysl', '~> 2.0'
|
15
|
-
gem 'psych'
|
16
|
-
gem 'rubinius-developer_tools'
|
17
|
-
gem 'rubysl-test-unit'
|
18
|
-
end
|
19
|
-
|
20
|
-
gem 'mongoid'
|
21
|
-
gem 'mongo_mapper'
|
22
|
-
gem 'simple_form'
|
23
|
-
gem 'formtastic'
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# backport of https://github.com/rails/rails/commit/3be9e8a0c2187744b6c9879ca2836cef5ebed693
|
2
|
-
if defined?(ActionView::Helpers::InstanceTag)
|
3
|
-
ActionView::Helpers::InstanceTag.singleton_class.class_eval do
|
4
|
-
remove_method :check_box_checked?
|
5
|
-
|
6
|
-
def check_box_checked?(value, checked_value)
|
7
|
-
case value
|
8
|
-
when TrueClass, FalseClass
|
9
|
-
value
|
10
|
-
when NilClass
|
11
|
-
false
|
12
|
-
when Integer
|
13
|
-
value != 0
|
14
|
-
when String
|
15
|
-
value == checked_value
|
16
|
-
else
|
17
|
-
if value.respond_to?(:include?)
|
18
|
-
value.include?(checked_value)
|
19
|
-
else
|
20
|
-
value.to_i != 0
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|