clean-bitmask-attribute 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.1
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{clean-bitmask-attribute}
|
8
|
+
s.version = "2.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Pavel Chipiga", "Bruce Williams"]
|
12
|
+
s.date = %q{2010-08-26}
|
13
|
+
s.email = %q{pavel.chipiga@gmail.com}
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"LICENSE",
|
16
|
+
"README.markdown"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".document",
|
20
|
+
".gitignore",
|
21
|
+
"LICENSE",
|
22
|
+
"README.markdown",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"clean-bitmask-attribute.gemspec",
|
26
|
+
"lib/bitmask-attribute.rb",
|
27
|
+
"lib/bitmask_attribute.rb",
|
28
|
+
"lib/bitmask_attribute/attribute.rb",
|
29
|
+
"lib/bitmask_attribute/core_ext/blank.rb",
|
30
|
+
"lib/bitmask_attribute/core_ext/hash_with_indifferent_access.rb",
|
31
|
+
"lib/bitmask_attribute/value_proxy.rb",
|
32
|
+
"rails/init.rb",
|
33
|
+
"test/bitmask_attribute_test.rb",
|
34
|
+
"test/clean_bitmask_attribute_test.rb",
|
35
|
+
"test/clean_test_helper.rb",
|
36
|
+
"test/test_helper.rb"
|
37
|
+
]
|
38
|
+
s.homepage = %q{http://github.com/chipiga/bitmask-attribute/tree/clean}
|
39
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.rubygems_version = %q{1.3.7}
|
42
|
+
s.summary = %q{Simple bitmask attribute support for any class}
|
43
|
+
s.test_files = [
|
44
|
+
"test/bitmask_attribute_test.rb",
|
45
|
+
"test/clean_bitmask_attribute_test.rb",
|
46
|
+
"test/clean_test_helper.rb",
|
47
|
+
"test/test_helper.rb"
|
48
|
+
]
|
49
|
+
|
50
|
+
if s.respond_to? :specification_version then
|
51
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
52
|
+
s.specification_version = 3
|
53
|
+
|
54
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
55
|
+
s.add_development_dependency(%q<activerecord>, [">= 0"])
|
56
|
+
s.add_development_dependency(%q<sqlite3-ruby>, [">= 0"])
|
57
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<activerecord>, [">= 0"])
|
60
|
+
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
61
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
62
|
+
end
|
63
|
+
else
|
64
|
+
s.add_dependency(%q<activerecord>, [">= 0"])
|
65
|
+
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
66
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
@@ -17,7 +17,7 @@ module BitmaskAttribute
|
|
17
17
|
%w(push << delete replace reject! select!).each do |override|
|
18
18
|
class_eval(<<-EOEVAL)
|
19
19
|
def #{override}(*args)
|
20
|
-
|
20
|
+
super.tap do
|
21
21
|
updated!
|
22
22
|
end
|
23
23
|
end
|
@@ -60,7 +60,7 @@ module BitmaskAttribute
|
|
60
60
|
def extract_values
|
61
61
|
stored = [@record.send(:read_attribute, @attribute) || 0, 0].max
|
62
62
|
@mapping.inject([]) do |values, (value, bitmask)|
|
63
|
-
|
63
|
+
values.tap do
|
64
64
|
values << value.to_sym if (stored & bitmask > 0)
|
65
65
|
end
|
66
66
|
end
|
data/lib/bitmask_attribute.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'bitmask_attribute/value_proxy'
|
2
2
|
require 'bitmask_attribute/attribute'
|
3
3
|
require 'bitmask_attribute/core_ext/hash_with_indifferent_access' unless defined?(HashWithIndifferentAccess)
|
4
|
-
require 'bitmask_attribute/core_ext/returning' unless Object.respond_to?(:returning)
|
5
4
|
require 'bitmask_attribute/core_ext/blank' unless Object.respond_to?(:blank?)
|
6
5
|
|
7
6
|
module BitmaskAttribute
|
@@ -35,7 +34,7 @@ module BitmaskAttribute
|
|
35
34
|
end
|
36
35
|
|
37
36
|
def generate_bitmasks_on(model)
|
38
|
-
model.bitmasks[attribute] =
|
37
|
+
model.bitmasks[attribute] = HashWithIndifferentAccess.new.tap do |mapping|
|
39
38
|
values.each_with_index do |value, index|
|
40
39
|
mapping[value] = 0b1 << index
|
41
40
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clean-bitmask-attribute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 2.0.
|
9
|
+
- 1
|
10
|
+
version: 2.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pavel Chipiga
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-
|
19
|
+
date: 2010-08-26 00:00:00 +03:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -77,12 +77,12 @@ files:
|
|
77
77
|
- README.markdown
|
78
78
|
- Rakefile
|
79
79
|
- VERSION
|
80
|
+
- clean-bitmask-attribute.gemspec
|
80
81
|
- lib/bitmask-attribute.rb
|
81
82
|
- lib/bitmask_attribute.rb
|
82
83
|
- lib/bitmask_attribute/attribute.rb
|
83
84
|
- lib/bitmask_attribute/core_ext/blank.rb
|
84
85
|
- lib/bitmask_attribute/core_ext/hash_with_indifferent_access.rb
|
85
|
-
- lib/bitmask_attribute/core_ext/returning.rb
|
86
86
|
- lib/bitmask_attribute/value_proxy.rb
|
87
87
|
- rails/init.rb
|
88
88
|
- test/bitmask_attribute_test.rb
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# Extracted from Active Support
|
2
|
-
class Object
|
3
|
-
# Returns +value+ after yielding +value+ to the block. This simplifies the
|
4
|
-
# process of constructing an object, performing work on the object, and then
|
5
|
-
# returning the object from a method. It is a Ruby-ized realization of the K
|
6
|
-
# combinator, courtesy of Mikael Brockman.
|
7
|
-
#
|
8
|
-
# ==== Examples
|
9
|
-
#
|
10
|
-
# # Without returning
|
11
|
-
# def foo
|
12
|
-
# values = []
|
13
|
-
# values << "bar"
|
14
|
-
# values << "baz"
|
15
|
-
# return values
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
# foo # => ['bar', 'baz']
|
19
|
-
#
|
20
|
-
# # returning with a local variable
|
21
|
-
# def foo
|
22
|
-
# returning values = [] do
|
23
|
-
# values << 'bar'
|
24
|
-
# values << 'baz'
|
25
|
-
# end
|
26
|
-
# end
|
27
|
-
#
|
28
|
-
# foo # => ['bar', 'baz']
|
29
|
-
#
|
30
|
-
# # returning with a block argument
|
31
|
-
# def foo
|
32
|
-
# returning [] do |values|
|
33
|
-
# values << 'bar'
|
34
|
-
# values << 'baz'
|
35
|
-
# end
|
36
|
-
# end
|
37
|
-
#
|
38
|
-
# foo # => ['bar', 'baz']
|
39
|
-
def returning(value)
|
40
|
-
yield(value)
|
41
|
-
value
|
42
|
-
end
|
43
|
-
end
|