bitmask 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -8,3 +8,5 @@ Rake::TestTask.new do |t|
8
8
  t.test_files = FileList['test/*test.rb']
9
9
  t.verbose = true
10
10
  end
11
+
12
+ task :default => :test
@@ -58,11 +58,11 @@ class Bitmask
58
58
  end
59
59
 
60
60
  def to_a
61
- @masks.keys.sort { |a,b| @masks[a] <=> @masks[b] }.collect { |k| [k, get(k)] }
61
+ @masks.keys.select { |k| get k }
62
62
  end
63
63
 
64
64
  def each(&blk)
65
- to_a.each(&blk)
65
+ to_h.each(&blk)
66
66
  end
67
67
 
68
68
  def to_h
@@ -1,3 +1,3 @@
1
1
  class Bitmask
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -37,14 +37,17 @@ class BitmaskTest < Test::Unit::TestCase
37
37
 
38
38
  def test_to_a
39
39
  bitmask = Bitmask.new TEST_MASKS, :phone => true, :name => true, :email => true
40
- assert_equal([
41
- [:phone, true ],
42
- [:name, true ],
43
- [:gender, false],
44
- [:email, true ],
45
- [:birthday, false],
46
- [:location, false]
47
- ], bitmask.to_a)
40
+ assert_equal([:phone, :name, :email], bitmask.to_a)
41
+ end
42
+
43
+ def test_each
44
+ bitmask = Bitmask.new TEST_MASKS, :phone => true, :name => true, :email => true
45
+ results = {}
46
+ bitmask.each do |k, v|
47
+ results[k] = v
48
+ end
49
+
50
+ assert_equal({:phone => true, :name => true, :email => true, :gender => false, :birthday => false, :location => false}, results)
48
51
  end
49
52
 
50
53
  def test_defaults
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitmask
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-01 00:00:00.000000000 Z
12
+ date: 2012-11-16 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Represents a set of boolean values as an Integer
15
15
  email:
@@ -48,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
48
  version: '0'
49
49
  requirements: []
50
50
  rubyforge_project:
51
- rubygems_version: 1.8.10
51
+ rubygems_version: 1.8.24
52
52
  signing_key:
53
53
  specification_version: 3
54
54
  summary: Bitmask represents a set of boolean values as an Integer using bitwise arithmetic. This