ar-enums 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.3.4
data/ar-enums.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ar-enums}
8
- s.version = "0.3.3"
8
+ s.version = "0.3.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Emmanuel Nicolau"]
12
- s.date = %q{2010-08-12}
12
+ s.date = %q{2010-09-03}
13
13
  s.description = %q{Provides a simple way for defining enumerations in ActiveRecord models}
14
14
  s.email = %q{emmanicolau@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
44
44
  s.homepage = %q{http://github.com/eeng/ar-enums}
45
45
  s.rdoc_options = ["--charset=UTF-8"]
46
46
  s.require_paths = ["lib"]
47
- s.rubygems_version = %q{1.3.6}
47
+ s.rubygems_version = %q{1.3.7}
48
48
  s.summary = %q{Enumerations for ActiveRecord models}
49
49
  s.test_files = [
50
50
  "spec/enum_definition_spec.rb",
@@ -59,7 +59,7 @@ Gem::Specification.new do |s|
59
59
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
60
60
  s.specification_version = 3
61
61
 
62
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
62
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
63
63
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
64
64
  else
65
65
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
data/lib/enum.rb CHANGED
@@ -44,6 +44,10 @@ module ActiveRecord
44
44
  all.detect { |enum| enum == name_or_id }
45
45
  end
46
46
 
47
+ def self.find_all_by_id ids
48
+ all.select { |enum| ids.include? enum.id }
49
+ end
50
+
47
51
  private
48
52
  def self.define_enums_getter enums
49
53
  cattr_accessor :all
data/spec/enum_spec.rb CHANGED
@@ -15,6 +15,7 @@ describe "Enum" do
15
15
  enumeration do
16
16
  red :rgb => 0xF00
17
17
  green :rgb => 0x0F0
18
+ blue :rgb => 0x00F
18
19
  end
19
20
  end
20
21
 
@@ -39,4 +40,12 @@ describe "Enum" do
39
40
  Color[2].should be_enum_with(:name => 'green')
40
41
  end
41
42
  end
43
+
44
+ context "finders" do
45
+ it "find_all_by_id" do
46
+ Color.find_all_by_id([1, 2, 3, 4]).should == Color.all
47
+ Color.find_all_by_id([1, 3]).should == [:red, :blue]
48
+ Color.find_all_by_id([]).should == []
49
+ end
50
+ end
42
51
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar-enums
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 27
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 3
8
- - 3
9
- version: 0.3.3
9
+ - 4
10
+ version: 0.3.4
10
11
  platform: ruby
11
12
  authors:
12
13
  - Emmanuel Nicolau
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-08-12 00:00:00 -03:00
18
+ date: 2010-09-03 00:00:00 -03:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rspec
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 13
27
30
  segments:
28
31
  - 1
29
32
  - 2
@@ -74,23 +77,27 @@ rdoc_options:
74
77
  require_paths:
75
78
  - lib
76
79
  required_ruby_version: !ruby/object:Gem::Requirement
80
+ none: false
77
81
  requirements:
78
82
  - - ">="
79
83
  - !ruby/object:Gem::Version
84
+ hash: 3
80
85
  segments:
81
86
  - 0
82
87
  version: "0"
83
88
  required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
84
90
  requirements:
85
91
  - - ">="
86
92
  - !ruby/object:Gem::Version
93
+ hash: 3
87
94
  segments:
88
95
  - 0
89
96
  version: "0"
90
97
  requirements: []
91
98
 
92
99
  rubyforge_project:
93
- rubygems_version: 1.3.6
100
+ rubygems_version: 1.3.7
94
101
  signing_key:
95
102
  specification_version: 3
96
103
  summary: Enumerations for ActiveRecord models