ar-enums 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +60 -0
- data/Rakefile +6 -44
- data/ar_enums.gemspec +25 -0
- data/autotest/discover.rb +1 -0
- data/lib/{enum.rb → ar_enums/enum.rb} +4 -0
- data/lib/{enum_block.rb → ar_enums/enum_block.rb} +0 -0
- data/lib/{enum_definition.rb → ar_enums/enum_definition.rb} +0 -0
- data/lib/{enum_field.rb → ar_enums/enum_field.rb} +0 -0
- data/lib/{factory.rb → ar_enums/factory.rb} +1 -1
- data/lib/{metaprogramming_extensions.rb → ar_enums/metaprogramming_extensions.rb} +0 -0
- data/lib/{options_helper.rb → ar_enums/options_helper.rb} +0 -0
- data/lib/ar_enums/version.rb +3 -0
- data/lib/{ar-enums.rb → ar_enums.rb} +1 -1
- data/spec/{enum_definition_spec.rb → ar_enums/enum_definition_spec.rb} +1 -1
- data/spec/{enum_spec.rb → ar_enums/enum_spec.rb} +16 -1
- data/spec/{factory_spec.rb → ar_enums/factory_spec.rb} +1 -1
- data/spec/spec_helper.rb +7 -9
- metadata +91 -41
- data/.document +0 -5
- data/VERSION +0 -1
- data/ar-enums.gemspec +0 -71
- data/spec/spec.opts +0 -3
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm 1.9.2
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ar-enums (0.3.5)
|
5
|
+
activerecord
|
6
|
+
rake
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activemodel (3.0.3)
|
12
|
+
activesupport (= 3.0.3)
|
13
|
+
builder (~> 2.1.2)
|
14
|
+
i18n (~> 0.4)
|
15
|
+
activerecord (3.0.3)
|
16
|
+
activemodel (= 3.0.3)
|
17
|
+
activesupport (= 3.0.3)
|
18
|
+
arel (~> 2.0.2)
|
19
|
+
tzinfo (~> 0.3.23)
|
20
|
+
activesupport (3.0.3)
|
21
|
+
archive-tar-minitar (0.5.2)
|
22
|
+
arel (2.0.7)
|
23
|
+
builder (2.1.2)
|
24
|
+
columnize (0.3.2)
|
25
|
+
diff-lcs (1.1.2)
|
26
|
+
i18n (0.5.0)
|
27
|
+
linecache19 (0.5.11)
|
28
|
+
ruby_core_source (>= 0.1.4)
|
29
|
+
rake (0.8.7)
|
30
|
+
rspec (2.4.0)
|
31
|
+
rspec-core (~> 2.4.0)
|
32
|
+
rspec-expectations (~> 2.4.0)
|
33
|
+
rspec-mocks (~> 2.4.0)
|
34
|
+
rspec-core (2.4.0)
|
35
|
+
rspec-expectations (2.4.0)
|
36
|
+
diff-lcs (~> 1.1.2)
|
37
|
+
rspec-mocks (2.4.0)
|
38
|
+
ruby-debug-base19 (0.11.24)
|
39
|
+
columnize (>= 0.3.1)
|
40
|
+
linecache19 (>= 0.5.11)
|
41
|
+
ruby_core_source (>= 0.1.4)
|
42
|
+
ruby-debug19 (0.11.6)
|
43
|
+
columnize (>= 0.3.1)
|
44
|
+
linecache19 (>= 0.5.11)
|
45
|
+
ruby-debug-base19 (>= 0.11.19)
|
46
|
+
ruby_core_source (0.1.4)
|
47
|
+
archive-tar-minitar (>= 0.5.2)
|
48
|
+
sqlite3 (1.3.3)
|
49
|
+
sqlite3-ruby (1.3.3)
|
50
|
+
sqlite3 (>= 1.3.3)
|
51
|
+
tzinfo (0.3.24)
|
52
|
+
|
53
|
+
PLATFORMS
|
54
|
+
ruby
|
55
|
+
|
56
|
+
DEPENDENCIES
|
57
|
+
ar-enums!
|
58
|
+
rspec
|
59
|
+
ruby-debug19
|
60
|
+
sqlite3-ruby
|
data/Rakefile
CHANGED
@@ -1,45 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.setup
|
3
|
+
Bundler::GemHelper.install_tasks
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
gem.name = "ar-enums"
|
8
|
-
gem.summary = %Q{Enumerations for ActiveRecord models}
|
9
|
-
gem.description = %Q{Provides a simple way for defining enumerations in ActiveRecord models}
|
10
|
-
gem.email = "emmanicolau@gmail.com"
|
11
|
-
gem.homepage = "http://github.com/eeng/ar-enums"
|
12
|
-
gem.authors = ["Emmanuel Nicolau"]
|
13
|
-
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
-
end
|
16
|
-
Jeweler::GemcutterTasks.new
|
17
|
-
rescue LoadError
|
18
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
|
-
end
|
20
|
-
|
21
|
-
require 'spec/rake/spectask'
|
22
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
23
|
-
spec.libs << 'lib' << 'spec'
|
24
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
25
|
-
end
|
26
|
-
|
27
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
28
|
-
spec.libs << 'lib' << 'spec'
|
29
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
30
|
-
spec.rcov = true
|
31
|
-
end
|
32
|
-
|
33
|
-
task :spec => :check_dependencies
|
34
|
-
|
35
|
-
task :default => :spec
|
36
|
-
|
37
|
-
require 'rake/rdoctask'
|
38
|
-
Rake::RDocTask.new do |rdoc|
|
39
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
|
-
|
41
|
-
rdoc.rdoc_dir = 'rdoc'
|
42
|
-
rdoc.title = "ar-enums #{version}"
|
43
|
-
rdoc.rdoc_files.include('README*')
|
44
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
45
|
-
end
|
5
|
+
require "rspec/core/rake_task"
|
6
|
+
RSpec::Core::RakeTask.new :spec
|
7
|
+
task :default => :spec
|
data/ar_enums.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "ar_enums/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "ar-enums"
|
7
|
+
s.version = ArEnums::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Emmanuel Nicolau"]
|
10
|
+
s.email = ["emmanicolau@gmail.com"]
|
11
|
+
s.summary = %q{Provides a simple way for defining enumerations in ActiveRecord models}
|
12
|
+
|
13
|
+
s.rubyforge_project = "ar-enums"
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_development_dependency "rspec"
|
21
|
+
s.add_development_dependency "ruby-debug19"
|
22
|
+
s.add_development_dependency "sqlite3-ruby"
|
23
|
+
s.add_dependency "activerecord"
|
24
|
+
s.add_dependency "rake"
|
25
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Autotest.add_discovery { "rspec2" }
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__)
|
1
|
+
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
2
2
|
|
3
3
|
describe "Enum" do
|
4
4
|
it "should provide :to_sym method returning name as symbols" do
|
@@ -48,4 +48,19 @@ describe "Enum" do
|
|
48
48
|
Color.find_all_by_id([]).should == []
|
49
49
|
end
|
50
50
|
end
|
51
|
+
|
52
|
+
it "in? should check if == to any" do
|
53
|
+
define_model_class 'Color', 'ActiveRecord::Enum' do
|
54
|
+
enumeration do
|
55
|
+
red :rgb => 0xF00
|
56
|
+
green :rgb => 0x0F0
|
57
|
+
blue :rgb => 0x00F
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
Color[:red].should be_in :red, :blue
|
62
|
+
Color[:red].should be_in :green, :red, :blue
|
63
|
+
Color[:red].should be_in Color[:red]
|
64
|
+
Color[:red].should_not be_in :blue
|
65
|
+
end
|
51
66
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,25 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require '
|
4
|
-
require 'ar-enums'
|
5
|
-
require 'spec'
|
6
|
-
require 'spec/autorun'
|
1
|
+
require 'rspec'
|
2
|
+
require 'ruby-debug'
|
3
|
+
require 'ar_enums'
|
7
4
|
|
8
|
-
|
5
|
+
RSpec.configure do |config|
|
9
6
|
config.before :suite do
|
10
7
|
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
|
11
8
|
load(File.dirname(__FILE__) + "/schema.rb")
|
12
9
|
end
|
13
10
|
|
14
11
|
def define_model_class(name = "TestClass", parent_class_name = "ActiveRecord::Base", &block)
|
15
|
-
|
12
|
+
ActiveSupport::Dependencies.send :remove_const, name rescue nil
|
16
13
|
eval("class #{name} < #{parent_class_name}; end", TOPLEVEL_BINDING)
|
17
14
|
klass = eval(name, TOPLEVEL_BINDING)
|
18
15
|
klass.class_eval(&block) if block_given?
|
19
16
|
end
|
20
17
|
end
|
21
18
|
|
22
|
-
|
19
|
+
RSpec::Matchers.define :be_enum_with do |expected_attrs|
|
23
20
|
match do |enum|
|
24
21
|
enum.should be_a(ActiveRecord::Enum)
|
25
22
|
expected_attrs.each do |atrib, expected_value|
|
@@ -27,3 +24,4 @@ Spec::Matchers.define :be_enum_with do |expected_attrs|
|
|
27
24
|
end
|
28
25
|
end
|
29
26
|
end
|
27
|
+
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ar-enums
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 27
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
8
|
+
- 5
|
9
|
+
version: 0.3.5
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Emmanuel Nicolau
|
@@ -15,65 +14,117 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date:
|
17
|
+
date: 2011-01-21 00:00:00 -03:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: rspec
|
23
|
-
prerelease: false
|
24
22
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
23
|
none: false
|
26
24
|
requirements:
|
27
25
|
- - ">="
|
28
26
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 13
|
30
27
|
segments:
|
31
|
-
-
|
32
|
-
|
33
|
-
- 9
|
34
|
-
version: 1.2.9
|
28
|
+
- 0
|
29
|
+
version: "0"
|
35
30
|
type: :development
|
31
|
+
prerelease: false
|
36
32
|
version_requirements: *id001
|
37
|
-
|
38
|
-
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: ruby-debug19
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 0
|
42
|
+
version: "0"
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: sqlite3-ruby
|
48
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
version: "0"
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *id003
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: activerecord
|
61
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
type: :runtime
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: *id004
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: rake
|
74
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
version: "0"
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: *id005
|
85
|
+
description:
|
86
|
+
email:
|
87
|
+
- emmanicolau@gmail.com
|
39
88
|
executables: []
|
40
89
|
|
41
90
|
extensions: []
|
42
91
|
|
43
|
-
extra_rdoc_files:
|
44
|
-
|
45
|
-
- README.rdoc
|
92
|
+
extra_rdoc_files: []
|
93
|
+
|
46
94
|
files:
|
47
95
|
- .autotest
|
48
|
-
- .document
|
49
96
|
- .gitignore
|
97
|
+
- .rspec
|
98
|
+
- .rvmrc
|
99
|
+
- Gemfile
|
100
|
+
- Gemfile.lock
|
50
101
|
- LICENSE
|
51
102
|
- README.rdoc
|
52
103
|
- Rakefile
|
53
|
-
-
|
54
|
-
-
|
104
|
+
- ar_enums.gemspec
|
105
|
+
- autotest/discover.rb
|
55
106
|
- examples/internal_enums.rb
|
56
|
-
- lib/
|
57
|
-
- lib/enum.rb
|
58
|
-
- lib/enum_block.rb
|
59
|
-
- lib/enum_definition.rb
|
60
|
-
- lib/enum_field.rb
|
61
|
-
- lib/factory.rb
|
62
|
-
- lib/metaprogramming_extensions.rb
|
63
|
-
- lib/options_helper.rb
|
64
|
-
-
|
65
|
-
- spec/
|
66
|
-
- spec/
|
107
|
+
- lib/ar_enums.rb
|
108
|
+
- lib/ar_enums/enum.rb
|
109
|
+
- lib/ar_enums/enum_block.rb
|
110
|
+
- lib/ar_enums/enum_definition.rb
|
111
|
+
- lib/ar_enums/enum_field.rb
|
112
|
+
- lib/ar_enums/factory.rb
|
113
|
+
- lib/ar_enums/metaprogramming_extensions.rb
|
114
|
+
- lib/ar_enums/options_helper.rb
|
115
|
+
- lib/ar_enums/version.rb
|
116
|
+
- spec/ar_enums/enum_definition_spec.rb
|
117
|
+
- spec/ar_enums/enum_spec.rb
|
118
|
+
- spec/ar_enums/factory_spec.rb
|
67
119
|
- spec/schema.rb
|
68
|
-
- spec/spec.opts
|
69
120
|
- spec/spec_helper.rb
|
70
121
|
has_rdoc: true
|
71
|
-
homepage:
|
122
|
+
homepage:
|
72
123
|
licenses: []
|
73
124
|
|
74
125
|
post_install_message:
|
75
|
-
rdoc_options:
|
76
|
-
|
126
|
+
rdoc_options: []
|
127
|
+
|
77
128
|
require_paths:
|
78
129
|
- lib
|
79
130
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -81,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
132
|
requirements:
|
82
133
|
- - ">="
|
83
134
|
- !ruby/object:Gem::Version
|
84
|
-
hash:
|
135
|
+
hash: 268053231401669126
|
85
136
|
segments:
|
86
137
|
- 0
|
87
138
|
version: "0"
|
@@ -90,21 +141,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
141
|
requirements:
|
91
142
|
- - ">="
|
92
143
|
- !ruby/object:Gem::Version
|
93
|
-
hash:
|
144
|
+
hash: 268053231401669126
|
94
145
|
segments:
|
95
146
|
- 0
|
96
147
|
version: "0"
|
97
148
|
requirements: []
|
98
149
|
|
99
|
-
rubyforge_project:
|
150
|
+
rubyforge_project: ar-enums
|
100
151
|
rubygems_version: 1.3.7
|
101
152
|
signing_key:
|
102
153
|
specification_version: 3
|
103
|
-
summary:
|
154
|
+
summary: Provides a simple way for defining enumerations in ActiveRecord models
|
104
155
|
test_files:
|
105
|
-
- spec/enum_definition_spec.rb
|
106
|
-
- spec/enum_spec.rb
|
107
|
-
- spec/factory_spec.rb
|
156
|
+
- spec/ar_enums/enum_definition_spec.rb
|
157
|
+
- spec/ar_enums/enum_spec.rb
|
158
|
+
- spec/ar_enums/factory_spec.rb
|
108
159
|
- spec/schema.rb
|
109
160
|
- spec/spec_helper.rb
|
110
|
-
- examples/internal_enums.rb
|
data/.document
DELETED
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.3.4
|
data/ar-enums.gemspec
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{ar-enums}
|
8
|
-
s.version = "0.3.4"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Emmanuel Nicolau"]
|
12
|
-
s.date = %q{2010-09-03}
|
13
|
-
s.description = %q{Provides a simple way for defining enumerations in ActiveRecord models}
|
14
|
-
s.email = %q{emmanicolau@gmail.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".autotest",
|
21
|
-
".document",
|
22
|
-
".gitignore",
|
23
|
-
"LICENSE",
|
24
|
-
"README.rdoc",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"ar-enums.gemspec",
|
28
|
-
"examples/internal_enums.rb",
|
29
|
-
"lib/ar-enums.rb",
|
30
|
-
"lib/enum.rb",
|
31
|
-
"lib/enum_block.rb",
|
32
|
-
"lib/enum_definition.rb",
|
33
|
-
"lib/enum_field.rb",
|
34
|
-
"lib/factory.rb",
|
35
|
-
"lib/metaprogramming_extensions.rb",
|
36
|
-
"lib/options_helper.rb",
|
37
|
-
"spec/enum_definition_spec.rb",
|
38
|
-
"spec/enum_spec.rb",
|
39
|
-
"spec/factory_spec.rb",
|
40
|
-
"spec/schema.rb",
|
41
|
-
"spec/spec.opts",
|
42
|
-
"spec/spec_helper.rb"
|
43
|
-
]
|
44
|
-
s.homepage = %q{http://github.com/eeng/ar-enums}
|
45
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
46
|
-
s.require_paths = ["lib"]
|
47
|
-
s.rubygems_version = %q{1.3.7}
|
48
|
-
s.summary = %q{Enumerations for ActiveRecord models}
|
49
|
-
s.test_files = [
|
50
|
-
"spec/enum_definition_spec.rb",
|
51
|
-
"spec/enum_spec.rb",
|
52
|
-
"spec/factory_spec.rb",
|
53
|
-
"spec/schema.rb",
|
54
|
-
"spec/spec_helper.rb",
|
55
|
-
"examples/internal_enums.rb"
|
56
|
-
]
|
57
|
-
|
58
|
-
if s.respond_to? :specification_version then
|
59
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
60
|
-
s.specification_version = 3
|
61
|
-
|
62
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
63
|
-
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
64
|
-
else
|
65
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
66
|
-
end
|
67
|
-
else
|
68
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
data/spec/spec.opts
DELETED