bitindex 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.md +24 -0
- data/README.md +4 -3
- data/lib/bitindex/reader.rb +3 -1
- data/lib/bitindex/version.rb +1 -1
- data/spec/common_spec.rb +6 -6
- data/spec/reader_spec.rb +23 -23
- data/spec/spec_helper.rb +1 -1
- data/spec/writer_spec.rb +2 -2
- metadata +40 -53
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ef27d514a2cc215f7ab77f90b8adf67e7ac557e0
|
4
|
+
data.tar.gz: 375777c7cb2887ba4c7e12fc41a59ac849757c84
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a74eff1e2518e69f392c2ba31a3ba3e344971a706e1d1f69a2d72f12ab95e6de4313df7381e8527d8d176dff0934547973d97874676a306ae4f6ae6160f8a295
|
7
|
+
data.tar.gz: 07a37ab311b2f394f22de51d9affb59a596aabec7ee509ee6a004c2a69ed79242993e0a8e7464e769b3acc5b8143cdded9c6e1230441939fc6b37abf1c4503e0
|
data/LICENSE.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
4
|
+
distribute this software, either in source code form or as a compiled
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
6
|
+
means.
|
7
|
+
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
9
|
+
of this software dedicate any and all copyright interest in the
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
11
|
+
of the public at large and to the detriment of our heirs and
|
12
|
+
successors. We intend this dedication to be an overt act of
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
14
|
+
software under copyright law.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
For more information, please refer to <http://unlicense.org/>
|
data/README.md
CHANGED
@@ -11,9 +11,10 @@ w = Bitindex::Writer.new file, size_in_bytes
|
|
11
11
|
w.write [1,2,3,8000]
|
12
12
|
|
13
13
|
r = Bitindex::Reader.new file
|
14
|
-
r.
|
15
|
-
r.
|
16
|
-
r.
|
14
|
+
r.set? 1 # true
|
15
|
+
r.set? 8000 # true
|
16
|
+
r.set? 8001 # false
|
17
|
+
r.set? 2**32 # false
|
17
18
|
r.all_set(0..10) # [1,2,3]
|
18
19
|
|
19
20
|
```
|
data/lib/bitindex/reader.rb
CHANGED
@@ -13,7 +13,7 @@ module Bitindex
|
|
13
13
|
@ltor = !(opts[:ltor] == false)
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def set? value
|
17
17
|
result = false
|
18
18
|
File.open(self.filepath, 'rb') do |io|
|
19
19
|
idx = byte_pos value
|
@@ -24,6 +24,8 @@ module Bitindex
|
|
24
24
|
end
|
25
25
|
result
|
26
26
|
end
|
27
|
+
alias :is_set? :set?
|
28
|
+
|
27
29
|
|
28
30
|
def all_set array
|
29
31
|
arr = []
|
data/lib/bitindex/version.rb
CHANGED
data/spec/common_spec.rb
CHANGED
@@ -54,20 +54,20 @@ describe Bitindex::Common do
|
|
54
54
|
|
55
55
|
describe '.bit_set?' do
|
56
56
|
it 'should determine if a bit within a byte is set' do
|
57
|
-
(0..15).each {|n| @test.bit_set?(0x00, n).should
|
58
|
-
(0..15).each {|n| @test.bit_set?(0xff, n).should
|
57
|
+
(0..15).each {|n| @test.bit_set?(0x00, n).should == false }
|
58
|
+
(0..15).each {|n| @test.bit_set?(0xff, n).should == true }
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'finds set bit left to right' do
|
62
62
|
byte = 0xf0 # 11110000
|
63
|
-
(0..3).each {|n| @test.bit_set?(byte, n).should
|
64
|
-
(4..7).each {|n| @test.bit_set?(byte, n).should
|
63
|
+
(0..3).each {|n| @test.bit_set?(byte, n).should == true }
|
64
|
+
(4..7).each {|n| @test.bit_set?(byte, n).should == false }
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'finds set bit right to left' do
|
68
68
|
byte = 0xf0 # 11110000
|
69
|
-
(0..3).each {|n| @test.bit_set?(byte, n, false).should
|
70
|
-
(4..7).each {|n| @test.bit_set?(byte, n, false).should
|
69
|
+
(0..3).each {|n| @test.bit_set?(byte, n, false).should == false }
|
70
|
+
(4..7).each {|n| @test.bit_set?(byte, n, false).should == true }
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
data/spec/reader_spec.rb
CHANGED
@@ -20,16 +20,16 @@ describe Bitindex::Reader do
|
|
20
20
|
FileUtils.touch filepath
|
21
21
|
|
22
22
|
r = Bitindex::Reader.new filepath
|
23
|
-
r.ltor.should
|
23
|
+
r.ltor.should == true
|
24
24
|
|
25
25
|
r = Bitindex::Reader.new filepath, { ltor: false }
|
26
|
-
r.ltor.should
|
26
|
+
r.ltor.should == false
|
27
27
|
|
28
28
|
FileUtils.rm filepath
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
describe '.
|
32
|
+
describe '.set?' do
|
33
33
|
it 'can read values in a single byte file' do
|
34
34
|
|
35
35
|
filepath = 'reader.bit'
|
@@ -38,21 +38,21 @@ describe Bitindex::Reader do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
r = Bitindex::Reader.new filepath
|
41
|
-
r.
|
42
|
-
r.
|
43
|
-
r.
|
44
|
-
r.
|
45
|
-
r.
|
46
|
-
r.
|
41
|
+
r.set?(0).should == true
|
42
|
+
r.set?(1).should == false
|
43
|
+
r.set?(3).should == false
|
44
|
+
r.set?(4).should == true
|
45
|
+
r.set?(5).should == false
|
46
|
+
r.set?(7).should == false
|
47
47
|
|
48
48
|
|
49
49
|
r = Bitindex::Reader.new filepath, { ltor: false }
|
50
|
-
r.
|
51
|
-
r.
|
52
|
-
r.
|
53
|
-
r.
|
54
|
-
r.
|
55
|
-
r.
|
50
|
+
r.set?(0).should == false
|
51
|
+
r.set?(1).should == false
|
52
|
+
r.set?(3).should == true
|
53
|
+
r.set?(4).should == false
|
54
|
+
r.set?(5).should == false
|
55
|
+
r.set?(7).should == true
|
56
56
|
|
57
57
|
FileUtils.rm filepath
|
58
58
|
end
|
@@ -69,16 +69,16 @@ describe Bitindex::Reader do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
r = Bitindex::Reader.new filepath
|
72
|
-
r.is_set?(0).should
|
73
|
-
r.is_set?(8).should
|
74
|
-
r.is_set?(16).should
|
75
|
-
r.is_set?(24).should
|
72
|
+
r.is_set?(0).should == true
|
73
|
+
r.is_set?(8).should == false
|
74
|
+
r.is_set?(16).should == true
|
75
|
+
r.is_set?(24).should == false
|
76
76
|
|
77
77
|
r = Bitindex::Reader.new filepath, { ltor: false }
|
78
|
-
r.is_set?(0).should
|
79
|
-
r.is_set?(8).should
|
80
|
-
r.is_set?(16).should
|
81
|
-
r.is_set?(24).should
|
78
|
+
r.is_set?(0).should == true
|
79
|
+
r.is_set?(8).should == false
|
80
|
+
r.is_set?(16).should == false
|
81
|
+
r.is_set?(24).should == false
|
82
82
|
|
83
83
|
FileUtils.rm filepath
|
84
84
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/writer_spec.rb
CHANGED
@@ -14,10 +14,10 @@ describe Bitindex::Writer do
|
|
14
14
|
|
15
15
|
it 'can set "left to right" as an option' do
|
16
16
|
w = Bitindex::Writer.new 'file.bit', 10
|
17
|
-
w.ltor.should
|
17
|
+
w.ltor.should == true
|
18
18
|
|
19
19
|
w = Bitindex::Writer.new 'file.bit', 10, { ltor: false }
|
20
|
-
w.ltor.should
|
20
|
+
w.ltor.should == false
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
metadata
CHANGED
@@ -1,87 +1,74 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitindex
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
version: 0.0.3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
6
|
+
authors:
|
12
7
|
- Galen Palmer
|
13
8
|
autorequire:
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2014-06-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: rspec
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
segments:
|
28
|
-
- 2
|
29
|
-
- 10
|
30
|
-
version: "2.10"
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.10'
|
31
20
|
type: :development
|
32
|
-
|
33
|
-
|
34
|
-
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.10'
|
27
|
+
description: This library contains a Writer and Reader interface to create files where
|
28
|
+
the position of a bit within the file indicates a true or false value.
|
29
|
+
email:
|
35
30
|
- palmergs@gmail.com
|
36
31
|
executables: []
|
37
|
-
|
38
32
|
extensions: []
|
39
|
-
|
40
33
|
extra_rdoc_files: []
|
41
|
-
|
42
|
-
|
34
|
+
files:
|
35
|
+
- LICENSE.md
|
36
|
+
- README.md
|
43
37
|
- Rakefile
|
38
|
+
- lib/bitindex.rb
|
44
39
|
- lib/bitindex/common.rb
|
45
40
|
- lib/bitindex/reader.rb
|
46
41
|
- lib/bitindex/version.rb
|
47
42
|
- lib/bitindex/writer.rb
|
48
|
-
- lib/bitindex.rb
|
49
43
|
- spec/common_spec.rb
|
50
44
|
- spec/reader_spec.rb
|
51
45
|
- spec/spec_helper.rb
|
52
46
|
- spec/writer_spec.rb
|
53
|
-
- README.md
|
54
|
-
has_rdoc: true
|
55
47
|
homepage: https://github.com/palmergs/bitindex
|
56
48
|
licenses: []
|
57
|
-
|
49
|
+
metadata: {}
|
58
50
|
post_install_message:
|
59
51
|
rdoc_options: []
|
60
|
-
|
61
|
-
require_paths:
|
52
|
+
require_paths:
|
62
53
|
- lib
|
63
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
65
56
|
- - ">="
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
72
61
|
- - ">="
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
|
75
|
-
- 0
|
76
|
-
version: "0"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
77
64
|
requirements: []
|
78
|
-
|
79
65
|
rubyforge_project: bitindex
|
80
|
-
rubygems_version:
|
66
|
+
rubygems_version: 2.2.2
|
81
67
|
signing_key:
|
82
|
-
specification_version:
|
83
|
-
summary: Build a file where, given an integer value, the bit at that position indicates
|
84
|
-
|
68
|
+
specification_version: 4
|
69
|
+
summary: Build a file where, given an integer value, the bit at that position indicates
|
70
|
+
true or false.
|
71
|
+
test_files:
|
85
72
|
- spec/common_spec.rb
|
86
73
|
- spec/reader_spec.rb
|
87
74
|
- spec/spec_helper.rb
|