mandrews-has-bit-field 1.0.1 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +21 -8
- data/has-bit-field.gemspec +3 -3
- data/lib/has-bit-field/version.rb +1 -1
- data/lib/has-bit-field.rb +5 -5
- data/test/has-bit-field_test.rb +2 -2
- data/test/test_helper.rb +1 -1
- metadata +10 -11
- /data/{rails/init.rb → init.rb} +0 -0
data/Gemfile.lock
CHANGED
@@ -1,20 +1,33 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
has-bit-field (1.
|
4
|
+
mandrews-has-bit-field (1.1.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
8
8
|
specs:
|
9
|
-
|
10
|
-
activesupport (=
|
11
|
-
|
12
|
-
|
9
|
+
activemodel (3.1.1)
|
10
|
+
activesupport (= 3.1.1)
|
11
|
+
builder (~> 3.0.0)
|
12
|
+
i18n (~> 0.6)
|
13
|
+
activerecord (3.1.1)
|
14
|
+
activemodel (= 3.1.1)
|
15
|
+
activesupport (= 3.1.1)
|
16
|
+
arel (~> 2.2.1)
|
17
|
+
tzinfo (~> 0.3.29)
|
18
|
+
activesupport (3.1.1)
|
19
|
+
multi_json (~> 1.0)
|
20
|
+
arel (2.2.1)
|
21
|
+
builder (3.0.0)
|
22
|
+
i18n (0.6.0)
|
23
|
+
multi_json (1.0.3)
|
24
|
+
sqlite3 (1.3.4)
|
25
|
+
tzinfo (0.3.30)
|
13
26
|
|
14
27
|
PLATFORMS
|
15
28
|
ruby
|
16
29
|
|
17
30
|
DEPENDENCIES
|
18
|
-
activerecord (~>
|
19
|
-
has-bit-field!
|
20
|
-
sqlite3
|
31
|
+
activerecord (~> 3.0)
|
32
|
+
mandrews-has-bit-field!
|
33
|
+
sqlite3
|
data/has-bit-field.gemspec
CHANGED
@@ -12,9 +12,9 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.summary = "Provides an easy way to work with bit fields in active record"
|
13
13
|
s.description = "Provides an easy way to work with bit fields in active record"
|
14
14
|
|
15
|
-
s.rubyforge_project = "has-bit-field"
|
16
|
-
s.add_development_dependency "sqlite3
|
17
|
-
s.add_development_dependency "activerecord", "~>
|
15
|
+
s.rubyforge_project = "mandrews-has-bit-field"
|
16
|
+
s.add_development_dependency "sqlite3"
|
17
|
+
s.add_development_dependency "activerecord", "~> 3.0"
|
18
18
|
|
19
19
|
s.files = `git ls-files`.split("\n")
|
20
20
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/lib/has-bit-field.rb
CHANGED
@@ -36,16 +36,16 @@ module HasBitField
|
|
36
36
|
#{field} != #{field}_was
|
37
37
|
end
|
38
38
|
}
|
39
|
-
if(respond_to?(:
|
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
|
-
|
43
|
-
|
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)
|
44
44
|
}
|
45
45
|
else
|
46
46
|
class_eval %{
|
47
|
-
|
48
|
-
|
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)
|
49
49
|
}
|
50
50
|
end
|
51
51
|
end
|
data/test/has-bit-field_test.rb
CHANGED
@@ -178,7 +178,7 @@ class HasBitFieldTest < Test::Unit::TestCase
|
|
178
178
|
s.chops_trees = true
|
179
179
|
assert s.chops_trees?
|
180
180
|
assert s.valid?
|
181
|
-
assert
|
181
|
+
assert s.errors[:chops_trees].blank?
|
182
182
|
assert s.save
|
183
183
|
end
|
184
184
|
|
@@ -202,7 +202,7 @@ class HasBitFieldTest < Test::Unit::TestCase
|
|
202
202
|
s.plays_piano = true
|
203
203
|
assert s.plays_piano?
|
204
204
|
assert s.valid?
|
205
|
-
assert
|
205
|
+
assert s.errors[:plays_piano].blank?
|
206
206
|
assert s.save
|
207
207
|
end
|
208
208
|
|
data/test/test_helper.rb
CHANGED
@@ -7,7 +7,7 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
7
7
|
|
8
8
|
require 'test/unit'
|
9
9
|
require 'active_record'
|
10
|
-
require File.join(File.dirname(__FILE__), "../
|
10
|
+
require File.join(File.dirname(__FILE__), "../init")
|
11
11
|
require 'has-bit-field'
|
12
12
|
|
13
13
|
#ActiveRecord::Base.logger = Logger.new($stdout)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mandrews-has-bit-field
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 1
|
10
|
+
version: 1.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Paul Barry
|
@@ -16,11 +16,11 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-10-24 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
|
-
name: sqlite3
|
23
|
+
name: sqlite3
|
24
24
|
prerelease: false
|
25
25
|
requirement: &id001 !ruby/object:Gem::Requirement
|
26
26
|
none: false
|
@@ -41,12 +41,11 @@ dependencies:
|
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
hash:
|
44
|
+
hash: 7
|
45
45
|
segments:
|
46
|
-
- 2
|
47
46
|
- 3
|
48
|
-
-
|
49
|
-
version:
|
47
|
+
- 0
|
48
|
+
version: "3.0"
|
50
49
|
type: :development
|
51
50
|
version_requirements: *id002
|
52
51
|
description: Provides an easy way to work with bit fields in active record
|
@@ -68,9 +67,9 @@ files:
|
|
68
67
|
- README.md
|
69
68
|
- Rakefile
|
70
69
|
- has-bit-field.gemspec
|
70
|
+
- init.rb
|
71
71
|
- lib/has-bit-field.rb
|
72
72
|
- lib/has-bit-field/version.rb
|
73
|
-
- rails/init.rb
|
74
73
|
- test/has-bit-field_test.rb
|
75
74
|
- test/test_helper.rb
|
76
75
|
has_rdoc: true
|
@@ -102,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
101
|
version: "0"
|
103
102
|
requirements: []
|
104
103
|
|
105
|
-
rubyforge_project: has-bit-field
|
104
|
+
rubyforge_project: mandrews-has-bit-field
|
106
105
|
rubygems_version: 1.4.2
|
107
106
|
signing_key:
|
108
107
|
specification_version: 3
|
/data/{rails/init.rb → init.rb}
RENAMED
File without changes
|