bitfields 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +14 -2
- data/VERSION +1 -1
- data/bitfields.gemspec +1 -1
- data/lib/bitfields.rb +7 -1
- data/spec/spec_helper.rb +9 -1
- metadata +2 -2
data/Rakefile
CHANGED
@@ -1,7 +1,19 @@
|
|
1
|
-
task :default => :spec
|
2
1
|
require 'spec/rake/spectask'
|
3
2
|
Spec::Rake::SpecTask.new {|t| t.spec_opts = ['--color']}
|
4
3
|
|
4
|
+
task :default do
|
5
|
+
# test with 2.x
|
6
|
+
puts `VERSION='~>2' rake spec`
|
7
|
+
|
8
|
+
# gem 'activerecord', '>=3' did not work for me, but just require gets the right version...
|
9
|
+
require 'active_record'
|
10
|
+
if ActiveRecord::VERSION::MAJOR >= 3
|
11
|
+
puts `rake spec`
|
12
|
+
else
|
13
|
+
'install rails 3 to get full test coverage...'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
5
17
|
begin
|
6
18
|
require 'jeweler'
|
7
19
|
project_name = 'bitfields'
|
@@ -16,4 +28,4 @@ begin
|
|
16
28
|
Jeweler::GemcutterTasks.new
|
17
29
|
rescue LoadError
|
18
30
|
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler"
|
19
|
-
end
|
31
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/bitfields.gemspec
CHANGED
data/lib/bitfields.rb
CHANGED
@@ -19,6 +19,12 @@ module Bitfields
|
|
19
19
|
bitfields
|
20
20
|
end
|
21
21
|
|
22
|
+
# AR 3+ -> :scope, below :named_scope
|
23
|
+
def self.ar_scoping_method
|
24
|
+
return :scope if defined?(ActiveRecord::VERSION::MAJOR) and ActiveRecord::VERSION::MAJOR >= 3
|
25
|
+
:named_scope
|
26
|
+
end
|
27
|
+
|
22
28
|
module ClassMethods
|
23
29
|
def bitfield(column, options)
|
24
30
|
# prepare ...
|
@@ -37,7 +43,7 @@ module Bitfields
|
|
37
43
|
define_method("#{bit_name}?"){ bitfield_value(bit_name) }
|
38
44
|
define_method("#{bit_name}="){|value| set_bitfield_value(bit_name, value) }
|
39
45
|
if options[:scopes] != false
|
40
|
-
scoping_method =
|
46
|
+
scoping_method = Bitfields.ar_scoping_method
|
41
47
|
send scoping_method, bit_name, :conditions => bitfield_sql(bit_name => true)
|
42
48
|
send scoping_method, "not_#{bit_name}", :conditions => bitfield_sql(bit_name => false)
|
43
49
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
if ENV['VERSION']
|
3
|
+
gem 'activerecord', ENV['VERSION']
|
4
|
+
gem 'activesupport', ENV['VERSION']
|
5
|
+
end
|
2
6
|
$LOAD_PATH << 'lib'
|
3
7
|
require 'bitfields'
|
4
|
-
|
8
|
+
|
9
|
+
require 'active_record'
|
10
|
+
puts "Using ActiveRecord #{ActiveRecord::VERSION::STRING}"
|
11
|
+
|
12
|
+
require 'spec/database'
|