bitfields 0.3.0 → 0.4.0
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/Gemfile +9 -0
- data/Gemfile.lock +47 -0
- data/Rakefile +6 -7
- data/VERSION +1 -1
- data/bitfields.gemspec +5 -8
- data/lib/bitfields.rb +5 -2
- data/spec/bitfields_spec.rb +9 -5
- metadata +9 -9
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activemodel (3.1.0.rc4)
|
5
|
+
activesupport (= 3.1.0.rc4)
|
6
|
+
bcrypt-ruby (~> 2.1.4)
|
7
|
+
builder (~> 3.0.0)
|
8
|
+
i18n (~> 0.6)
|
9
|
+
activerecord (3.1.0.rc4)
|
10
|
+
activemodel (= 3.1.0.rc4)
|
11
|
+
activesupport (= 3.1.0.rc4)
|
12
|
+
arel (~> 2.1.1)
|
13
|
+
tzinfo (~> 0.3.27)
|
14
|
+
activesupport (3.1.0.rc4)
|
15
|
+
multi_json (~> 1.0)
|
16
|
+
arel (2.1.1)
|
17
|
+
bcrypt-ruby (2.1.4)
|
18
|
+
builder (3.0.0)
|
19
|
+
diff-lcs (1.1.2)
|
20
|
+
git (1.2.5)
|
21
|
+
i18n (0.6.0)
|
22
|
+
jeweler (1.6.2)
|
23
|
+
bundler (~> 1.0)
|
24
|
+
git (>= 1.2.5)
|
25
|
+
rake
|
26
|
+
multi_json (1.0.3)
|
27
|
+
rake (0.9.2)
|
28
|
+
rspec (2.6.0)
|
29
|
+
rspec-core (~> 2.6.0)
|
30
|
+
rspec-expectations (~> 2.6.0)
|
31
|
+
rspec-mocks (~> 2.6.0)
|
32
|
+
rspec-core (2.6.4)
|
33
|
+
rspec-expectations (2.6.0)
|
34
|
+
diff-lcs (~> 1.1.2)
|
35
|
+
rspec-mocks (2.6.0)
|
36
|
+
sqlite3 (1.3.3)
|
37
|
+
tzinfo (0.3.28)
|
38
|
+
|
39
|
+
PLATFORMS
|
40
|
+
ruby
|
41
|
+
|
42
|
+
DEPENDENCIES
|
43
|
+
activerecord
|
44
|
+
jeweler
|
45
|
+
rake
|
46
|
+
rspec (~> 2)
|
47
|
+
sqlite3
|
data/Rakefile
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
t.rspec_opts = '--backtrace --color'
|
1
|
+
task :default do
|
2
|
+
sh "rspec spec"
|
4
3
|
end
|
5
4
|
|
6
|
-
task :
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
task :all do
|
6
|
+
sh "AR=2.3.12 bundle && bundle exec rake"
|
7
|
+
sh "AR=3.0.8 bundle && bundle exec rake"
|
8
|
+
sh "AR=3.1.0.rc4 bundle && bundle exec rake"
|
10
9
|
end
|
11
10
|
|
12
11
|
begin
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/bitfields.gemspec
CHANGED
@@ -5,13 +5,15 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bitfields}
|
8
|
-
s.version = "0.
|
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 = ["Michael Grosser"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-06-21}
|
13
13
|
s.email = %q{grosser.michael@gmail.com}
|
14
14
|
s.files = [
|
15
|
+
"Gemfile",
|
16
|
+
"Gemfile.lock",
|
15
17
|
"Rakefile",
|
16
18
|
"Readme.md",
|
17
19
|
"VERSION",
|
@@ -24,13 +26,8 @@ Gem::Specification.new do |s|
|
|
24
26
|
]
|
25
27
|
s.homepage = %q{http://github.com/grosser/bitfields}
|
26
28
|
s.require_paths = ["lib"]
|
27
|
-
s.rubygems_version = %q{1.
|
29
|
+
s.rubygems_version = %q{1.6.2}
|
28
30
|
s.summary = %q{Save migrations and columns by storing multiple booleans in a single integer.}
|
29
|
-
s.test_files = [
|
30
|
-
"spec/bitfields_spec.rb",
|
31
|
-
"spec/database.rb",
|
32
|
-
"spec/spec_helper.rb"
|
33
|
-
]
|
34
31
|
|
35
32
|
if s.respond_to? :specification_version then
|
36
33
|
s.specification_version = 3
|
data/lib/bitfields.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'active_support'
|
2
|
+
require 'active_support/version'
|
2
3
|
|
3
4
|
module Bitfields
|
4
5
|
VERSION = File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
|
@@ -6,7 +7,9 @@ module Bitfields
|
|
6
7
|
class DuplicateBitNameError < ArgumentError; end
|
7
8
|
|
8
9
|
def self.included(base)
|
9
|
-
|
10
|
+
class << base
|
11
|
+
attr_accessor :bitfields, :bitfield_options
|
12
|
+
end
|
10
13
|
base.extend Bitfields::ClassMethods
|
11
14
|
end
|
12
15
|
|
@@ -119,7 +122,7 @@ module Bitfields
|
|
119
122
|
|
120
123
|
module InstanceMethods
|
121
124
|
def bitfield_values(column)
|
122
|
-
Hash[bitfields[column.to_sym].map{|bit_name, bit| [bit_name, bitfield_value(bit_name)]}]
|
125
|
+
Hash[self.class.bitfields[column.to_sym].map{|bit_name, bit| [bit_name, bitfield_value(bit_name)]}]
|
123
126
|
end
|
124
127
|
|
125
128
|
private
|
data/spec/bitfields_spec.rb
CHANGED
@@ -338,15 +338,19 @@ describe Bitfields do
|
|
338
338
|
User.respond_to?(:seller).should == true
|
339
339
|
OverwrittenUser.respond_to?(:seller).should == true
|
340
340
|
end
|
341
|
+
end
|
342
|
+
|
343
|
+
describe 'inheritance' do
|
344
|
+
it "knows overwritten values and normal" do
|
345
|
+
User.bitfields.should == {:bits=>{:seller=>1, :insane=>2, :stupid=>4}}
|
346
|
+
OverwrittenUser.bitfields.should == {:bits=>{:seller_inherited=>1}}
|
347
|
+
end
|
341
348
|
|
342
|
-
|
343
|
-
pending
|
349
|
+
xit "knows inherited values when overwriting" do
|
344
350
|
OverwrittenUser.bitfield_column(:seller).should == :bits
|
345
351
|
end
|
346
|
-
end
|
347
352
|
|
348
|
-
|
349
|
-
it "knows inherited values" do
|
353
|
+
xit "knows inherited values without overwriting" do
|
350
354
|
InheritedUser.bitfield_column(:seller).should == :bits
|
351
355
|
end
|
352
356
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitfields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 4
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Grosser
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-06-21 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -28,6 +28,8 @@ extensions: []
|
|
28
28
|
extra_rdoc_files: []
|
29
29
|
|
30
30
|
files:
|
31
|
+
- Gemfile
|
32
|
+
- Gemfile.lock
|
31
33
|
- Rakefile
|
32
34
|
- Readme.md
|
33
35
|
- VERSION
|
@@ -67,11 +69,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
69
|
requirements: []
|
68
70
|
|
69
71
|
rubyforge_project:
|
70
|
-
rubygems_version: 1.
|
72
|
+
rubygems_version: 1.6.2
|
71
73
|
signing_key:
|
72
74
|
specification_version: 3
|
73
75
|
summary: Save migrations and columns by storing multiple booleans in a single integer.
|
74
|
-
test_files:
|
75
|
-
|
76
|
-
- spec/database.rb
|
77
|
-
- spec/spec_helper.rb
|
76
|
+
test_files: []
|
77
|
+
|