simple_enum 1.6.5 → 1.6.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA512:
3
- metadata.gz: 891cf333ea0c52d94a7a8d40a2a861f3197ffa23c1f74cc0b127ef136e6df86f1f66d7db8fa94ce88669954a5eb6c551957a2c1c69c17aadf2b608f728104120
4
- data.tar.gz: 6ac9b3af113c20669f840f748303a36182e25f94bd41565b13dda5fe3d70aeecd86b215393ad0ca36c6500963ed95e08e32a80453907501f33b4166549db6a66
5
- SHA1:
6
- metadata.gz: bd0a0e232a1fc335dff5f5f94c6ec8bf91c9d993
7
- data.tar.gz: c6b7b1bdeb9bfee01cef4fc85f34172465528178
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4e5699f6a6006961ea0474ccaf7c711e71308c14
4
+ data.tar.gz: 2773209fbca30a18661973ff3bd69a83fdc75a63
5
+ SHA512:
6
+ metadata.gz: 42ffff4b1ded83914ac64f886d3bf3cca7fd7feea2e2ba7e395067baefb3ad981e930efe3a135c8e9b785499dc1e672493ccc939944ef3a6cf1ec2a4a679e2b6
7
+ data.tar.gz: 6b064e2a9af7137cf9c9fc1d46d12139d6ffd4b3919c8f85378781a1771c869bd7c33d99f1a5a1f380c7e2ad6fe8ebe2fc5649f4b8d3e82695c5b32ade4f2825
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ pkg
5
5
  *.rbc
6
6
  .*.sw?
7
7
  tmp
8
+ Gemfile.lock
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Lukas Westermann (Zurich, Switzerland)
1
+ Copyright (c) 2013 Lukas Westermann (Zurich, Switzerland)
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -124,7 +124,8 @@ useful when creating queries, displaying option elements or similar:
124
124
 
125
125
  class User < ActiveRecord::Base
126
126
  as_enum :gender, [:male, :female]
127
- validates_as_enum :gender
127
+ validates :gender, :as_enum => true
128
+ # OR validates_as_enum :gender
128
129
  end
129
130
 
130
131
  All common options like <tt>:if</tt>, <tt>:unless</tt>, <tt>:allow_nil</tt> and <tt>:message</tt> are supported, because it just works within
@@ -277,6 +278,8 @@ or <em>b)</em> a custom method to convert an object to a symbolized form named +
277
278
  * @johnthethird - feature for <tt>_for_select</tt> to return the values
278
279
  * @sinsiliux - ruby 1.9 fixes and removed AR dependency
279
280
  * @sled - mongoid support
281
+ * @abrom - <tt>find_by_...</tt> method
282
+ * @mhuggins - translations fixes
280
283
  * and all others: https://github.com/lwe/simple_enum/graphs/contributors thanks
281
284
 
282
285
  == Licence & Copyright
@@ -1,5 +1,5 @@
1
1
  module SimpleEnum
2
2
 
3
3
  # +SimpleEnum+ version string.
4
- VERSION = "1.6.5"
4
+ VERSION = "1.6.7"
5
5
  end
data/lib/simple_enum.rb CHANGED
@@ -215,6 +215,11 @@ module SimpleEnum
215
215
  self.class.human_enum_name(attr_name, self.send(enum_cd)) unless self.send(enum_cd).nil?
216
216
  end
217
217
 
218
+ # generate find_by enum singleton
219
+ (class << self; self end).send(:define_method, "find_by_#{enum_cd}") do |*args|
220
+ send("find_by_#{options[:column]}", args)
221
+ end
222
+
218
223
  class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
219
224
  class_attribute #{enum_attr.inspect}, :instance_writer => false, :instance_reader => false
220
225
 
data/locales/en.yml CHANGED
@@ -3,8 +3,8 @@ en:
3
3
  activerecord:
4
4
  errors:
5
5
  messages:
6
- invalid_enum: invalid option supplied.
7
- mongoid:
6
+ invalid_enum: invalid option supplied
7
+ mongoid:
8
8
  errors:
9
9
  messages:
10
- invalid_enum: invalid option supplied.
10
+ invalid_enum: invalid option supplied
data/simple_enum.gemspec CHANGED
@@ -1,6 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "simple_enum/version"
2
+ require File.expand_path('../lib/simple_enum/version', __FILE__)
4
3
 
5
4
  Gem::Specification.new do |s|
6
5
  s.name = "simple_enum"
@@ -16,16 +15,16 @@ Gem::Specification.new do |s|
16
15
  s.email = ["lukas.westermann@gmail.com"]
17
16
  s.homepage = "http://lwe.github.com/simple_enum/"
18
17
 
19
- s.files = `git ls-files`.split("\n")
20
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
- s.require_path = 'lib'
18
+ s.files = %w{.gitignore Rakefile Gemfile README.rdoc LICENSE simple_enum.gemspec} + Dir['**/*.{rb,yml}']
19
+ s.test_files = s.files.grep(%r{^(test|spec|locales)/})
20
+ s.require_paths = %w{lib}
22
21
 
23
22
  s.license = 'MIT'
24
23
 
25
24
  s.add_dependency "activesupport", '>= 3.0.0'
26
25
 
27
26
  s.add_development_dependency 'rake', '>= 0.9.2'
28
- s.add_development_dependency 'minitest', '>= 2.3.0'
27
+ s.add_development_dependency 'minitest', '~> 2.0'
29
28
  s.add_development_dependency 'activerecord', '>= 3.0.0'
30
29
  s.add_development_dependency 'mongoid', '~> 2.0'
31
30
  end
@@ -188,7 +188,7 @@ class SimpleEnumTest < MiniTest::Unit::TestCase
188
188
 
189
189
  computer = validated_comp.new
190
190
  assert !computer.save, "save should return false"
191
- assert_equal "invalid option supplied.", computer.errors[:manufacturer].first
191
+ assert_equal "invalid option supplied", computer.errors[:manufacturer].first
192
192
  assert_equal "y u no os?", computer.errors[:operating_system].first
193
193
  end
194
194
 
data/test/test_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # Setup environment for both tests and IRB interactive console
2
2
  #
3
- $KCODE = 'u' unless RUBY_VERSION =~ /^1\.9/ # to make parameterize work...
3
+ $KCODE = 'u' if RUBY_VERSION =~ /^1\.8/ # to make parameterize work...
4
4
 
5
5
  require 'rubygems'
6
6
  require 'bundler/setup'
metadata CHANGED
@@ -1,96 +1,108 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: simple_enum
3
- version: !ruby/object:Gem::Version
4
- version: 1.6.5
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.6.7
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Lukas Westermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
-
12
- date: 2013-05-27 00:00:00 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- version_requirements: &id001 !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 3.0.0
11
+ date: 2013-10-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
20
14
  name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0
21
20
  type: :runtime
22
- requirement: *id001
23
21
  prerelease: false
24
- - !ruby/object:Gem::Dependency
25
- version_requirements: &id002 !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 0.9.2
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
27
+ - !ruby/object:Gem::Dependency
30
28
  name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.2
31
34
  type: :development
32
- requirement: *id002
33
35
  prerelease: false
34
- - !ruby/object:Gem::Dependency
35
- version_requirements: &id003 !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: 2.3.0
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.2
41
+ - !ruby/object:Gem::Dependency
40
42
  name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
41
48
  type: :development
42
- requirement: *id003
43
49
  prerelease: false
44
- - !ruby/object:Gem::Dependency
45
- version_requirements: &id004 !ruby/object:Gem::Requirement
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: 3.0.0
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
50
56
  name: activerecord
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0
51
62
  type: :development
52
- requirement: *id004
53
63
  prerelease: false
54
- - !ruby/object:Gem::Dependency
55
- version_requirements: &id005 !ruby/object:Gem::Requirement
56
- requirements:
57
- - - ~>
58
- - !ruby/object:Gem::Version
59
- version: "2.0"
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0
69
+ - !ruby/object:Gem::Dependency
60
70
  name: mongoid
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
61
76
  type: :development
62
- requirement: *id005
63
77
  prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
64
83
  description: Provides enum-like fields for ActiveRecord, ActiveModel and Mongoid models.
65
- email:
84
+ email:
66
85
  - lukas.westermann@gmail.com
67
86
  executables: []
68
-
69
87
  extensions: []
70
-
71
88
  extra_rdoc_files: []
72
-
73
- files:
89
+ files:
74
90
  - .gitignore
75
- - .travis.yml
91
+ - Rakefile
76
92
  - Gemfile
77
- - Gemfile.lock
78
- - LICENCE
79
93
  - README.rdoc
80
- - Rakefile
81
- - lib/simple_enum.rb
94
+ - LICENSE
95
+ - simple_enum.gemspec
82
96
  - lib/simple_enum/enum_hash.rb
83
97
  - lib/simple_enum/mongoid.rb
84
98
  - lib/simple_enum/validation.rb
85
99
  - lib/simple_enum/version.rb
86
- - locales/en.yml
87
- - simple_enum.gemspec
100
+ - lib/simple_enum.rb
88
101
  - test/array_conversions_test.rb
89
102
  - test/class_methods_test.rb
90
103
  - test/dirty_attributes_test.rb
91
104
  - test/enum_hash_test.rb
92
105
  - test/finders_test.rb
93
- - test/locales.yml
94
106
  - test/mongoid_test.rb
95
107
  - test/object_backed_test.rb
96
108
  - test/orm/active_record.rb
@@ -101,40 +113,38 @@ files:
101
113
  - test/simple_enum_test.rb
102
114
  - test/test_helper.rb
103
115
  - test/without_shortcuts_test.rb
116
+ - locales/en.yml
117
+ - test/locales.yml
104
118
  homepage: http://lwe.github.com/simple_enum/
105
- licenses:
119
+ licenses:
106
120
  - MIT
107
121
  metadata: {}
108
-
109
122
  post_install_message:
110
123
  rdoc_options: []
111
-
112
- require_paths:
124
+ require_paths:
113
125
  - lib
114
- required_ruby_version: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - '>='
129
+ - !ruby/object:Gem::Version
118
130
  version: 1.8.7
119
- required_rubygems_version: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - '>='
134
+ - !ruby/object:Gem::Version
123
135
  version: 1.3.6
124
136
  requirements: []
125
-
126
137
  rubyforge_project:
127
- rubygems_version: 2.0.2
138
+ rubygems_version: 2.0.3
128
139
  signing_key:
129
140
  specification_version: 4
130
141
  summary: Simple enum-like field support for models.
131
- test_files:
142
+ test_files:
132
143
  - test/array_conversions_test.rb
133
144
  - test/class_methods_test.rb
134
145
  - test/dirty_attributes_test.rb
135
146
  - test/enum_hash_test.rb
136
147
  - test/finders_test.rb
137
- - test/locales.yml
138
148
  - test/mongoid_test.rb
139
149
  - test/object_backed_test.rb
140
150
  - test/orm/active_record.rb
@@ -145,3 +155,5 @@ test_files:
145
155
  - test/simple_enum_test.rb
146
156
  - test/test_helper.rb
147
157
  - test/without_shortcuts_test.rb
158
+ - locales/en.yml
159
+ - test/locales.yml
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: ruby
2
- services: mongodb
3
- rvm:
4
- - 1.8.7
5
- - 1.9.3
6
- - jruby-19mode
data/Gemfile.lock DELETED
@@ -1,57 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- simple_enum (1.6.5)
5
- activesupport (>= 3.0.0)
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- activemodel (3.2.8)
11
- activesupport (= 3.2.8)
12
- builder (~> 3.0.0)
13
- activerecord (3.2.8)
14
- activemodel (= 3.2.8)
15
- activesupport (= 3.2.8)
16
- arel (~> 3.0.2)
17
- tzinfo (~> 0.3.29)
18
- activerecord-jdbc-adapter (1.2.2)
19
- activerecord-jdbcsqlite3-adapter (1.2.2)
20
- activerecord-jdbc-adapter (~> 1.2.2)
21
- jdbc-sqlite3 (~> 3.7.2)
22
- activesupport (3.2.8)
23
- i18n (~> 0.6)
24
- multi_json (~> 1.0)
25
- arel (3.0.2)
26
- bson (1.6.4)
27
- bson (1.6.4-java)
28
- bson_ext (1.6.4)
29
- bson (~> 1.6.4)
30
- builder (3.0.0)
31
- i18n (0.6.0)
32
- jdbc-sqlite3 (3.7.2)
33
- minitest (3.3.0)
34
- mongo (1.6.2)
35
- bson (~> 1.6.2)
36
- mongoid (2.4.12)
37
- activemodel (~> 3.1)
38
- mongo (<= 1.6.2)
39
- tzinfo (~> 0.3.22)
40
- multi_json (1.3.6)
41
- rake (0.9.2.2)
42
- sqlite3 (1.3.6)
43
- tzinfo (0.3.33)
44
-
45
- PLATFORMS
46
- java
47
- ruby
48
-
49
- DEPENDENCIES
50
- activerecord (>= 3.0.0)
51
- activerecord-jdbcsqlite3-adapter
52
- bson_ext
53
- minitest (>= 2.3.0)
54
- mongoid (~> 2.0)
55
- rake (>= 0.9.2)
56
- simple_enum!
57
- sqlite3