mandrews-has-bit-field 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +3 -1
- data/has-bit-field.gemspec +1 -0
- data/lib/has-bit-field/version.rb +1 -1
- data/lib/has-bit-field.rb +4 -4
- data/test/has-bit-field_test.rb +14 -14
- metadata +65 -60
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mandrews-has-bit-field (1.1.
|
4
|
+
mandrews-has-bit-field (1.1.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
@@ -21,6 +21,7 @@ GEM
|
|
21
21
|
builder (3.0.0)
|
22
22
|
i18n (0.6.0)
|
23
23
|
multi_json (1.0.3)
|
24
|
+
rake (10.0.2)
|
24
25
|
sqlite3 (1.3.4)
|
25
26
|
tzinfo (0.3.30)
|
26
27
|
|
@@ -30,4 +31,5 @@ PLATFORMS
|
|
30
31
|
DEPENDENCIES
|
31
32
|
activerecord (~> 3.0)
|
32
33
|
mandrews-has-bit-field!
|
34
|
+
rake
|
33
35
|
sqlite3
|
data/has-bit-field.gemspec
CHANGED
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.rubyforge_project = "mandrews-has-bit-field"
|
16
16
|
s.add_development_dependency "sqlite3"
|
17
17
|
s.add_development_dependency "activerecord", "~> 3.0"
|
18
|
+
s.add_development_dependency "rake"
|
18
19
|
|
19
20
|
s.files = `git ls-files`.split("\n")
|
20
21
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/lib/has-bit-field.rb
CHANGED
@@ -39,13 +39,13 @@ module HasBitField
|
|
39
39
|
if(respond_to?(:scope))
|
40
40
|
if table_exists? && columns_hash.has_key?(bit_field_attribute.to_s) && columns_hash[bit_field_attribute.to_s].null
|
41
41
|
class_eval %{
|
42
|
-
scope :#{field}, where("#{table_name}.#{bit_field_attribute} IS NOT NULL AND (#{table_name}.#{bit_field_attribute} & ?) != 0", #{field}_bit)
|
43
|
-
scope :not_#{field}, where("#{table_name}.#{bit_field_attribute} IS NULL OR (#{table_name}.#{bit_field_attribute} & ?) = 0", #{field}_bit)
|
42
|
+
scope :#{field}, lambda { where("#{table_name}.#{bit_field_attribute} IS NOT NULL AND (#{table_name}.#{bit_field_attribute} & ?) != 0", #{field}_bit) }
|
43
|
+
scope :not_#{field}, lambda { where("#{table_name}.#{bit_field_attribute} IS NULL OR (#{table_name}.#{bit_field_attribute} & ?) = 0", #{field}_bit) }
|
44
44
|
}
|
45
45
|
else
|
46
46
|
class_eval %{
|
47
|
-
scope :#{field}, where("(#{table_name}.#{bit_field_attribute} & ?) != 0", #{field}_bit)
|
48
|
-
scope :not_#{field}, where("(#{table_name}.#{bit_field_attribute} & ?) = 0", #{field}_bit)
|
47
|
+
scope :#{field}, lambda { where("(#{table_name}.#{bit_field_attribute} & ?) != 0", #{field}_bit) }
|
48
|
+
scope :not_#{field}, lambda { where("(#{table_name}.#{bit_field_attribute} & ?) = 0", #{field}_bit) }
|
49
49
|
}
|
50
50
|
end
|
51
51
|
end
|
data/test/has-bit-field_test.rb
CHANGED
@@ -103,17 +103,17 @@ class HasBitFieldTest < Test::Unit::TestCase
|
|
103
103
|
|
104
104
|
c = Person.create! :bit_field => 0
|
105
105
|
|
106
|
-
assert_equal [b], Person.likes_ice_cream.
|
107
|
-
assert_equal [a,c], Person.not_likes_ice_cream.
|
106
|
+
assert_equal [b], Person.likes_ice_cream.order("id").to_a
|
107
|
+
assert_equal [a,c], Person.not_likes_ice_cream.order(:id).to_a
|
108
108
|
|
109
|
-
assert_equal [a], Person.plays_golf.
|
110
|
-
assert_equal [b,c], Person.not_plays_golf.
|
109
|
+
assert_equal [a], Person.plays_golf.order(:id).to_a
|
110
|
+
assert_equal [b,c], Person.not_plays_golf.order(:id).to_a
|
111
111
|
|
112
|
-
assert_equal [b], Person.watches_tv.
|
113
|
-
assert_equal [a,c], Person.not_watches_tv.
|
112
|
+
assert_equal [b], Person.watches_tv.order(:id).to_a
|
113
|
+
assert_equal [a,c], Person.not_watches_tv.order(:id).to_a
|
114
114
|
|
115
|
-
assert_equal [a], Person.reads_books.
|
116
|
-
assert_equal [b,c], Person.not_reads_books.
|
115
|
+
assert_equal [a], Person.reads_books.order(:id).to_a
|
116
|
+
assert_equal [b,c], Person.not_reads_books.order(:id).to_a
|
117
117
|
end
|
118
118
|
|
119
119
|
def test_named_scopes_on_non_nullable_column
|
@@ -132,14 +132,14 @@ class HasBitFieldTest < Test::Unit::TestCase
|
|
132
132
|
|
133
133
|
c = Skill.create! :plays_piano => true, :chops_trees => true
|
134
134
|
|
135
|
-
assert_equal [a,b,c], Skill.plays_piano.
|
136
|
-
assert_equal [], Skill.not_plays_piano.
|
135
|
+
assert_equal [a,b,c], Skill.plays_piano.order(:id).to_a
|
136
|
+
assert_equal [], Skill.not_plays_piano.order(:id).to_a
|
137
137
|
|
138
|
-
assert_equal [a], Skill.mops_floors.
|
139
|
-
assert_equal [b,c], Skill.not_mops_floors.
|
138
|
+
assert_equal [a], Skill.mops_floors.order(:id).to_a
|
139
|
+
assert_equal [b,c], Skill.not_mops_floors.order(:id).to_a
|
140
140
|
|
141
|
-
assert_equal [b], Skill.makes_soup.
|
142
|
-
assert_equal [a,c], Skill.not_makes_soup.
|
141
|
+
assert_equal [b], Skill.makes_soup.order(:id).to_a
|
142
|
+
assert_equal [a,c], Skill.not_makes_soup.order(:id).to_a
|
143
143
|
end
|
144
144
|
|
145
145
|
def test_dirty_attributes
|
metadata
CHANGED
@@ -1,63 +1,72 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: mandrews-has-bit-field
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.2
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
- 1
|
10
|
-
version: 1.1.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Paul Barry
|
14
9
|
- Michael Andrews
|
15
10
|
autorequire:
|
16
11
|
bindir: bin
|
17
12
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
dependencies:
|
22
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2013-05-09 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
23
16
|
name: sqlite3
|
24
|
-
|
25
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
26
18
|
none: false
|
27
|
-
requirements:
|
28
|
-
- -
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
|
31
|
-
segments:
|
32
|
-
- 0
|
33
|
-
version: "0"
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
34
23
|
type: :development
|
35
|
-
|
36
|
-
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
37
32
|
name: activerecord
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ~>
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '3.0'
|
39
|
+
type: :development
|
38
40
|
prerelease: false
|
39
|
-
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
42
|
none: false
|
41
|
-
requirements:
|
43
|
+
requirements:
|
42
44
|
- - ~>
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '3.0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
49
55
|
type: :development
|
50
|
-
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
51
63
|
description: Provides an easy way to work with bit fields in active record
|
52
|
-
email:
|
64
|
+
email:
|
53
65
|
- mail@paulbarry.com
|
54
66
|
executables: []
|
55
|
-
|
56
67
|
extensions: []
|
57
|
-
|
58
68
|
extra_rdoc_files: []
|
59
|
-
|
60
|
-
files:
|
69
|
+
files:
|
61
70
|
- .document
|
62
71
|
- .gitignore
|
63
72
|
- .rvmrc
|
@@ -72,40 +81,36 @@ files:
|
|
72
81
|
- lib/has-bit-field/version.rb
|
73
82
|
- test/has-bit-field_test.rb
|
74
83
|
- test/test_helper.rb
|
75
|
-
has_rdoc: true
|
76
84
|
homepage: http://github.com/mandrews/has-bit-field
|
77
85
|
licenses: []
|
78
|
-
|
79
86
|
post_install_message:
|
80
87
|
rdoc_options: []
|
81
|
-
|
82
|
-
require_paths:
|
88
|
+
require_paths:
|
83
89
|
- lib
|
84
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
91
|
none: false
|
86
|
-
requirements:
|
87
|
-
- -
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
|
90
|
-
segments:
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
segments:
|
91
97
|
- 0
|
92
|
-
|
93
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
hash: 4413358208785628949
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
100
|
none: false
|
95
|
-
requirements:
|
96
|
-
- -
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
|
99
|
-
segments:
|
101
|
+
requirements:
|
102
|
+
- - ! '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
segments:
|
100
106
|
- 0
|
101
|
-
|
107
|
+
hash: 4413358208785628949
|
102
108
|
requirements: []
|
103
|
-
|
104
109
|
rubyforge_project: mandrews-has-bit-field
|
105
|
-
rubygems_version: 1.
|
110
|
+
rubygems_version: 1.8.24
|
106
111
|
signing_key:
|
107
112
|
specification_version: 3
|
108
113
|
summary: Provides an easy way to work with bit fields in active record
|
109
|
-
test_files:
|
114
|
+
test_files:
|
110
115
|
- test/has-bit-field_test.rb
|
111
116
|
- test/test_helper.rb
|