bitfields 0.2.2 → 0.3.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/Readme.md CHANGED
@@ -1,4 +1,4 @@
1
- Save migrations and columns by storing multiple booleans in a single integer.
1
+ Save migrations and columns by storing multiple booleans in a single integer.<br/>
2
2
  e.g. true-false-false = 1, false-true-false = 2, true-false-true = 5 (1,2,4,8,..)
3
3
 
4
4
  class User < ActiveRecord::Base
@@ -21,7 +21,7 @@ e.g. true-false-false = 1, false-true-false = 2, true-false-true = 5 (1,2,4,8,.
21
21
 
22
22
  Install
23
23
  =======
24
- As Gem: ` sudo gem install bitfields `
24
+ As Gem: ` sudo gem install bitfields `<br/>
25
25
  Or as Rails plugin: ` rails plugin install git://github.com/grosser/bitfields.git `
26
26
 
27
27
  ### Migration
@@ -40,6 +40,7 @@ Delete the shop when a user is no longer a seller
40
40
 
41
41
  TIPS
42
42
  ====
43
+ - [Upgrading] in version 0.2.2 the first field(when not given as hash) used bit 2 -> add a bogus field in first position
43
44
  - Never do: "#{bitfield_sql(...)} AND #{bitfield_sql(...)}", merge both into one hash
44
45
  - bit_operator is faster in most cases, use :query_mode => :in_list sparingly
45
46
  - Standard mysql integer is 4 byte -> 32 bitfields
@@ -56,6 +57,6 @@ Authors
56
57
  ### [Contributors](http://github.com/grosser/bitfields/contributors)
57
58
  - [Hellekin O. Wolf](https://github.com/hellekin)
58
59
 
59
- [Michael Grosser](http://grosser.it)
60
- michael@grosser.it
60
+ [Michael Grosser](http://grosser.it)<br/>
61
+ michael@grosser.it<br/>
61
62
  Hereby placed under public domain, do what you want, just do not hold me accountable...
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.3.0
data/bitfields.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bitfields}
8
- s.version = "0.2.2"
8
+ s.version = "0.3.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-02-04}
12
+ s.date = %q{2011-02-22}
13
13
  s.email = %q{grosser.michael@gmail.com}
14
14
  s.files = [
15
15
  "Rakefile",
data/lib/bitfields.rb CHANGED
@@ -32,7 +32,7 @@ module Bitfields
32
32
  # prepare ...
33
33
  column = column.to_sym
34
34
  options = (args.last.is_a?(Hash) ? args.pop.dup : {}) # since we will modify them...
35
- args.each_with_index{|field,i| options[2**(i+1)] = field } # add fields given in normal args to options
35
+ args.each_with_index{|field,i| options[2**i] = field } # add fields given in normal args to options
36
36
 
37
37
  # extract options
38
38
  self.bitfields ||= {}
@@ -39,7 +39,7 @@ end
39
39
  class WithoutThePowerOfTwo < ActiveRecord::Base
40
40
  set_table_name 'users'
41
41
  include Bitfields
42
- bitfield :bits, :seller, :insane, :query_mode => :bit_operator
42
+ bitfield :bits, :seller, :insane, :stupid, :query_mode => :bit_operator
43
43
  end
44
44
 
45
45
  class WithoutThePowerOfTwoWithoutOptions < ActiveRecord::Base
@@ -234,6 +234,11 @@ describe Bitfields do
234
234
  end
235
235
 
236
236
  describe 'without the power of two' do
237
+ it 'uses correct bits' do
238
+ u = WithoutThePowerOfTwo.create!(:seller => false, :insane => true, :stupid => true)
239
+ u.bits.should == 6
240
+ end
241
+
237
242
  it 'has all fields' do
238
243
  u = WithoutThePowerOfTwo.create!(:seller => false, :insane => true)
239
244
  u.seller.should == false
@@ -345,4 +350,4 @@ describe Bitfields do
345
350
  InheritedUser.bitfield_column(:seller).should == :bits
346
351
  end
347
352
  end
348
- end
353
+ end
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 2
10
- version: 0.2.2
8
+ - 3
9
+ - 0
10
+ version: 0.3.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-02-04 00:00:00 +01:00
18
+ date: 2011-02-22 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21