has_enum 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,14 +1,14 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "rails", "~> 3.0.0"
3
+ gem "rails", "~> 3.0.3"
4
4
 
5
5
  # Add dependencies to develop your gem here.
6
6
  # Include everything needed to run rake, tests, features, etc.
7
7
  group :development do
8
- gem "rspec", "~> 2.2.0"
9
- gem "rails", "~> 3.0.0"
10
- gem "bundler", "~> 1.0.0"
11
- gem "jeweler", "~> 1.5.1"
8
+ gem "rspec", ">= 2.2.0"
9
+ gem "rails", "~> 3.0.3"
10
+ gem "bundler", ">= 1.0.0"
11
+ gem "jeweler", ">= 1.5.1"
12
12
  gem "sqlite3-ruby", "~> 1.3.2"
13
13
  gem "rcov", ">= 0"
14
14
  end
@@ -2,47 +2,46 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  abstract (1.0.0)
5
- actionmailer (3.0.1)
6
- actionpack (= 3.0.1)
7
- mail (~> 2.2.5)
8
- actionpack (3.0.1)
9
- activemodel (= 3.0.1)
10
- activesupport (= 3.0.1)
5
+ actionmailer (3.0.3)
6
+ actionpack (= 3.0.3)
7
+ mail (~> 2.2.9)
8
+ actionpack (3.0.3)
9
+ activemodel (= 3.0.3)
10
+ activesupport (= 3.0.3)
11
11
  builder (~> 2.1.2)
12
12
  erubis (~> 2.6.6)
13
- i18n (~> 0.4.1)
13
+ i18n (~> 0.4)
14
14
  rack (~> 1.2.1)
15
- rack-mount (~> 0.6.12)
16
- rack-test (~> 0.5.4)
15
+ rack-mount (~> 0.6.13)
16
+ rack-test (~> 0.5.6)
17
17
  tzinfo (~> 0.3.23)
18
- activemodel (3.0.1)
19
- activesupport (= 3.0.1)
18
+ activemodel (3.0.3)
19
+ activesupport (= 3.0.3)
20
20
  builder (~> 2.1.2)
21
- i18n (~> 0.4.1)
22
- activerecord (3.0.1)
23
- activemodel (= 3.0.1)
24
- activesupport (= 3.0.1)
25
- arel (~> 1.0.0)
21
+ i18n (~> 0.4)
22
+ activerecord (3.0.3)
23
+ activemodel (= 3.0.3)
24
+ activesupport (= 3.0.3)
25
+ arel (~> 2.0.2)
26
26
  tzinfo (~> 0.3.23)
27
- activeresource (3.0.1)
28
- activemodel (= 3.0.1)
29
- activesupport (= 3.0.1)
30
- activesupport (3.0.1)
31
- arel (1.0.1)
32
- activesupport (~> 3.0.0)
27
+ activeresource (3.0.3)
28
+ activemodel (= 3.0.3)
29
+ activesupport (= 3.0.3)
30
+ activesupport (3.0.3)
31
+ arel (2.0.6)
33
32
  builder (2.1.2)
34
33
  diff-lcs (1.1.2)
35
34
  erubis (2.6.6)
36
35
  abstract (>= 1.0.0)
37
36
  git (1.2.5)
38
- i18n (0.4.2)
39
- jeweler (1.5.1)
37
+ i18n (0.5.0)
38
+ jeweler (1.5.2)
40
39
  bundler (~> 1.0.0)
41
40
  git (>= 1.2.5)
42
41
  rake
43
- mail (2.2.9.1)
42
+ mail (2.2.12)
44
43
  activesupport (>= 2.3.6)
45
- i18n (>= 0.4.1)
44
+ i18n (>= 0.4.0)
46
45
  mime-types (~> 1.16)
47
46
  treetop (~> 1.4.8)
48
47
  mime-types (1.16)
@@ -52,31 +51,31 @@ GEM
52
51
  rack (>= 1.0.0)
53
52
  rack-test (0.5.6)
54
53
  rack (>= 1.0)
55
- rails (3.0.1)
56
- actionmailer (= 3.0.1)
57
- actionpack (= 3.0.1)
58
- activerecord (= 3.0.1)
59
- activeresource (= 3.0.1)
60
- activesupport (= 3.0.1)
61
- bundler (~> 1.0.0)
62
- railties (= 3.0.1)
63
- railties (3.0.1)
64
- actionpack (= 3.0.1)
65
- activesupport (= 3.0.1)
66
- rake (>= 0.8.4)
67
- thor (~> 0.14.0)
54
+ rails (3.0.3)
55
+ actionmailer (= 3.0.3)
56
+ actionpack (= 3.0.3)
57
+ activerecord (= 3.0.3)
58
+ activeresource (= 3.0.3)
59
+ activesupport (= 3.0.3)
60
+ bundler (~> 1.0)
61
+ railties (= 3.0.3)
62
+ railties (3.0.3)
63
+ actionpack (= 3.0.3)
64
+ activesupport (= 3.0.3)
65
+ rake (>= 0.8.7)
66
+ thor (~> 0.14.4)
68
67
  rake (0.8.7)
69
68
  rcov (0.9.9)
70
- rspec (2.2.0)
71
- rspec-core (~> 2.2)
72
- rspec-expectations (~> 2.2)
73
- rspec-mocks (~> 2.2)
74
- rspec-core (2.2.1)
75
- rspec-expectations (2.2.0)
69
+ rspec (2.3.0)
70
+ rspec-core (~> 2.3.0)
71
+ rspec-expectations (~> 2.3.0)
72
+ rspec-mocks (~> 2.3.0)
73
+ rspec-core (2.3.1)
74
+ rspec-expectations (2.3.0)
76
75
  diff-lcs (~> 1.1.2)
77
- rspec-mocks (2.2.0)
76
+ rspec-mocks (2.3.0)
78
77
  sqlite3-ruby (1.3.2)
79
- thor (0.14.4)
78
+ thor (0.14.6)
80
79
  treetop (1.4.9)
81
80
  polyglot (>= 0.3.1)
82
81
  tzinfo (0.3.23)
@@ -85,9 +84,9 @@ PLATFORMS
85
84
  ruby
86
85
 
87
86
  DEPENDENCIES
88
- bundler (~> 1.0.0)
89
- jeweler (~> 1.5.1)
90
- rails (~> 3.0.0)
87
+ bundler (>= 1.0.0)
88
+ jeweler (>= 1.5.1)
89
+ rails (~> 3.0.3)
91
90
  rcov
92
- rspec (~> 2.2.0)
91
+ rspec (>= 2.2.0)
93
92
  sqlite3-ruby (~> 1.3.2)
data/README.md CHANGED
@@ -9,7 +9,7 @@ This gem has been designed for Rails 3 only.
9
9
  ### Install gem
10
10
 
11
11
  Insert
12
- gem 'has_enum' :git => 'git://github.com/openteam/has_enum.git'
12
+ gem 'has_enum'
13
13
  in your Rails 3 Gemfile. Then do
14
14
  $ bundle install
15
15
 
@@ -22,6 +22,10 @@ Here's example model:
22
22
  has_enum :size , %w( small medium large ) , :query_methods => false
23
23
  has_enum :status , [:pending, :failed, :done]
24
24
  end
25
+ Query methods are available by default. For example, query methods for color enum this methods will be available:
26
+ color_green?
27
+ color_red?
28
+ color_blue?
25
29
  See [sample usage in specs](https://github.com/openteam/has_enum/blob/master/spec/has_enum_spec.rb).
26
30
 
27
31
  ### Views
@@ -67,4 +71,4 @@ View specs are still failing. I'm working on it.
67
71
  ## Copyright
68
72
 
69
73
  Copyright (c) 2010 Andreas Korth, Konstantin Shabanov. See LICENSE.txt for
70
- further details.
74
+ further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
1
+ 0.4.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{has_enum}
8
- s.version = "0.3.4"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andreas Korth", "Konstantin Shabanov"]
12
- s.date = %q{2010-12-10}
12
+ s.date = %q{2010-12-23}
13
13
  s.email = %q{kes.eclipse@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE.txt",
@@ -50,28 +50,28 @@ Gem::Specification.new do |s|
50
50
  s.specification_version = 3
51
51
 
52
52
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
- s.add_runtime_dependency(%q<rails>, ["~> 3.0.0"])
54
- s.add_development_dependency(%q<rspec>, ["~> 2.2.0"])
55
- s.add_development_dependency(%q<rails>, ["~> 3.0.0"])
56
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
57
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
53
+ s.add_runtime_dependency(%q<rails>, ["~> 3.0.3"])
54
+ s.add_development_dependency(%q<rspec>, [">= 2.2.0"])
55
+ s.add_development_dependency(%q<rails>, ["~> 3.0.3"])
56
+ s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
57
+ s.add_development_dependency(%q<jeweler>, [">= 1.5.1"])
58
58
  s.add_development_dependency(%q<sqlite3-ruby>, ["~> 1.3.2"])
59
59
  s.add_development_dependency(%q<rcov>, [">= 0"])
60
60
  else
61
- s.add_dependency(%q<rails>, ["~> 3.0.0"])
62
- s.add_dependency(%q<rspec>, ["~> 2.2.0"])
63
- s.add_dependency(%q<rails>, ["~> 3.0.0"])
64
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
65
- s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
61
+ s.add_dependency(%q<rails>, ["~> 3.0.3"])
62
+ s.add_dependency(%q<rspec>, [">= 2.2.0"])
63
+ s.add_dependency(%q<rails>, ["~> 3.0.3"])
64
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
65
+ s.add_dependency(%q<jeweler>, [">= 1.5.1"])
66
66
  s.add_dependency(%q<sqlite3-ruby>, ["~> 1.3.2"])
67
67
  s.add_dependency(%q<rcov>, [">= 0"])
68
68
  end
69
69
  else
70
- s.add_dependency(%q<rails>, ["~> 3.0.0"])
71
- s.add_dependency(%q<rspec>, ["~> 2.2.0"])
72
- s.add_dependency(%q<rails>, ["~> 3.0.0"])
73
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
74
- s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
70
+ s.add_dependency(%q<rails>, ["~> 3.0.3"])
71
+ s.add_dependency(%q<rspec>, [">= 2.2.0"])
72
+ s.add_dependency(%q<rails>, ["~> 3.0.3"])
73
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
74
+ s.add_dependency(%q<jeweler>, [">= 1.5.1"])
75
75
  s.add_dependency(%q<sqlite3-ruby>, ["~> 1.3.2"])
76
76
  s.add_dependency(%q<rcov>, [">= 0"])
77
77
  end
@@ -16,7 +16,7 @@ module HasEnum
16
16
 
17
17
  if options[:query_methods] != false
18
18
  values.each do |val|
19
- define_method(:"#{val}?") { self.send(attribute) == val }
19
+ define_method(:"#{attribute}_#{val}?") { self.send(attribute) == val }
20
20
  end
21
21
  end
22
22
 
@@ -38,7 +38,7 @@ module HasEnum
38
38
  define_method "human_#{attribute}" do
39
39
  begin
40
40
  return nil unless self.send(attribute)
41
- key = "activerecord.attributes.#{self.class.name.underscore}.#{attribute}_enum.#{self.send(attribute)}"
41
+ key = "activerecord.attributes.#{self.class.model_name.i18n_key}.#{attribute}_enum.#{self.send(attribute)}"
42
42
  translation = I18n.translate(key, :raise => true)
43
43
  rescue I18n::MissingTranslationData
44
44
  self.send(attribute).humanize
@@ -49,7 +49,7 @@ module HasEnum
49
49
  def values_for_select_tag(enum)
50
50
  values = enum(enum)
51
51
  begin
52
- translation = I18n.translate("activerecord.attributes.#{self.name.underscore}.#{enum}_enum", :raise => true)
52
+ translation = I18n.translate("activerecord.attributes.#{self.model_name.i18n_key}.#{enum}_enum", :raise => true)
53
53
  values.map { |value| [translation[value.to_sym], value] }
54
54
  rescue I18n::MissingTranslationData
55
55
  values.map { |value| [value.humanize, value] }
@@ -44,10 +44,10 @@ describe HasEnum::ActiveRecord do
44
44
  it "should define a query method for each enum value" do
45
45
  @model.color = 'green'
46
46
  @model.category = 'stuff'
47
- @model.should be_stuff
48
- @model.should be_green
49
- @model.should_not be_red
50
- @model.should_not be_blue
47
+ @model.should be_category_stuff
48
+ @model.should be_color_green
49
+ @model.should_not be_color_red
50
+ @model.should_not be_color_blue
51
51
  end
52
52
  end
53
53
 
@@ -74,7 +74,7 @@ describe HasEnum::ActiveRecord do
74
74
 
75
75
  it "should define query methods for enum values" do
76
76
  @model.status = :pending
77
- @model.should be_pending
77
+ @model.should be_status_pending
78
78
  end
79
79
 
80
80
  it "should accept nil value for the attribute" do
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 3
8
7
  - 4
9
- version: 0.3.4
8
+ - 0
9
+ version: 0.4.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Andreas Korth
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-10 00:00:00 +06:00
18
+ date: 2010-12-23 00:00:00 +06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -28,8 +28,8 @@ dependencies:
28
28
  segments:
29
29
  - 3
30
30
  - 0
31
- - 0
32
- version: 3.0.0
31
+ - 3
32
+ version: 3.0.3
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: *id001
@@ -38,7 +38,7 @@ dependencies:
38
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
- - - ~>
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  segments:
44
44
  - 2
@@ -58,8 +58,8 @@ dependencies:
58
58
  segments:
59
59
  - 3
60
60
  - 0
61
- - 0
62
- version: 3.0.0
61
+ - 3
62
+ version: 3.0.3
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: *id003
@@ -68,7 +68,7 @@ dependencies:
68
68
  requirement: &id004 !ruby/object:Gem::Requirement
69
69
  none: false
70
70
  requirements:
71
- - - ~>
71
+ - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  segments:
74
74
  - 1
@@ -83,7 +83,7 @@ dependencies:
83
83
  requirement: &id005 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
- - - ~>
86
+ - - ">="
87
87
  - !ruby/object:Gem::Version
88
88
  segments:
89
89
  - 1
@@ -161,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
161
  requirements:
162
162
  - - ">="
163
163
  - !ruby/object:Gem::Version
164
- hash: -4461255227335299909
164
+ hash: 3267787670941739246
165
165
  segments:
166
166
  - 0
167
167
  version: "0"