bit-packer 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -3
- data/Gemfile.lock +7 -13
- data/Rakefile +3 -10
- data/VERSION +1 -1
- data/bit-packer.gemspec +14 -17
- data/lib/bit-packer.rb +25 -2
- metadata +42 -61
data/Gemfile
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
# Add dependencies required to use your gem here.
|
3
3
|
# Example:
|
4
|
-
gem "lookup-hash", ">= 0.2.0"
|
5
4
|
|
6
5
|
# Add dependencies to develop your gem here.
|
7
6
|
# Include everything needed to run rake, tests, features, etc.
|
8
7
|
group :development do
|
9
|
-
gem "bundler", "
|
10
|
-
gem "jeweler", "
|
8
|
+
gem "bundler", ">= 1.0.0"
|
9
|
+
gem "jeweler", ">= 1.5.2"
|
11
10
|
gem "riot", ">= 0.12.1"
|
12
11
|
end
|
data/Gemfile.lock
CHANGED
@@ -2,25 +2,19 @@ GEM
|
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
4
|
git (1.2.5)
|
5
|
-
|
6
|
-
|
7
|
-
bundler (~> 1.0.0)
|
5
|
+
jeweler (1.6.4)
|
6
|
+
bundler (~> 1.0)
|
8
7
|
git (>= 1.2.5)
|
9
8
|
rake
|
10
|
-
|
11
|
-
|
12
|
-
rake (0.8.7)
|
13
|
-
riot (0.12.1)
|
9
|
+
rake (0.9.2)
|
10
|
+
riot (0.12.4)
|
14
11
|
rr
|
15
|
-
|
16
|
-
rr (1.0.2)
|
17
|
-
term-ansicolor (1.0.5)
|
12
|
+
rr (1.0.4)
|
18
13
|
|
19
14
|
PLATFORMS
|
20
15
|
ruby
|
21
16
|
|
22
17
|
DEPENDENCIES
|
23
|
-
bundler (
|
24
|
-
jeweler (
|
25
|
-
lookup-hash (>= 0.2.0)
|
18
|
+
bundler (>= 1.0.0)
|
19
|
+
jeweler (>= 1.5.2)
|
26
20
|
riot (>= 0.12.1)
|
data/Rakefile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'rubygems'
|
3
3
|
require 'bundler'
|
4
|
+
|
4
5
|
begin
|
5
6
|
Bundler.setup(:default, :development)
|
6
7
|
rescue Bundler::BundlerError => e
|
@@ -8,9 +9,10 @@ rescue Bundler::BundlerError => e
|
|
8
9
|
$stderr.puts "Run `bundle install` to install missing gems"
|
9
10
|
exit e.status_code
|
10
11
|
end
|
11
|
-
require 'rake'
|
12
12
|
|
13
|
+
require 'rake'
|
13
14
|
require 'jeweler'
|
15
|
+
|
14
16
|
Jeweler::Tasks.new do |gem|
|
15
17
|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
16
18
|
gem.name = "bit-packer"
|
@@ -26,12 +28,3 @@ Jeweler::Tasks.new do |gem|
|
|
26
28
|
end
|
27
29
|
Jeweler::RubygemsDotOrgTasks.new
|
28
30
|
|
29
|
-
require 'rake/rdoctask'
|
30
|
-
Rake::RDocTask.new do |rdoc|
|
31
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
32
|
-
|
33
|
-
rdoc.rdoc_dir = 'rdoc'
|
34
|
-
rdoc.title = "hash-utils #{version}"
|
35
|
-
rdoc.rdoc_files.include('README*')
|
36
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
37
|
-
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/bit-packer.gemspec
CHANGED
@@ -4,13 +4,13 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.1.
|
7
|
+
s.name = "bit-packer"
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Martin
|
12
|
-
s.date =
|
13
|
-
s.email =
|
11
|
+
s.authors = ["Martin Koz\u{e1}k"]
|
12
|
+
s.date = "2011-09-08"
|
13
|
+
s.email = "martinkozak@martinkozak.net"
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE.txt",
|
16
16
|
"README.md"
|
@@ -27,30 +27,27 @@ Gem::Specification.new do |s|
|
|
27
27
|
"lib/bit-packer.rb",
|
28
28
|
"test"
|
29
29
|
]
|
30
|
-
s.homepage =
|
30
|
+
s.homepage = "http://github.com/martinkozak/bit-packer"
|
31
31
|
s.licenses = ["MIT"]
|
32
32
|
s.require_paths = ["lib"]
|
33
|
-
s.rubygems_version =
|
34
|
-
s.summary =
|
33
|
+
s.rubygems_version = "1.8.10"
|
34
|
+
s.summary = "Provides easy declarative way of analyzing the packed bit arrays."
|
35
35
|
|
36
36
|
if s.respond_to? :specification_version then
|
37
37
|
s.specification_version = 3
|
38
38
|
|
39
39
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
40
|
-
s.
|
41
|
-
s.add_development_dependency(%q<
|
42
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
40
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
41
|
+
s.add_development_dependency(%q<jeweler>, [">= 1.5.2"])
|
43
42
|
s.add_development_dependency(%q<riot>, [">= 0.12.1"])
|
44
43
|
else
|
45
|
-
s.add_dependency(%q<
|
46
|
-
s.add_dependency(%q<
|
47
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
44
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
45
|
+
s.add_dependency(%q<jeweler>, [">= 1.5.2"])
|
48
46
|
s.add_dependency(%q<riot>, [">= 0.12.1"])
|
49
47
|
end
|
50
48
|
else
|
51
|
-
s.add_dependency(%q<
|
52
|
-
s.add_dependency(%q<
|
53
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
49
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
50
|
+
s.add_dependency(%q<jeweler>, [">= 1.5.2"])
|
54
51
|
s.add_dependency(%q<riot>, [">= 0.12.1"])
|
55
52
|
end
|
56
53
|
end
|
data/lib/bit-packer.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# (c) 2011 Martin Kozák (martinkozak@martinkozak.net)
|
3
3
|
|
4
|
-
require "
|
4
|
+
require "set"
|
5
5
|
|
6
6
|
class BitPacker
|
7
7
|
|
@@ -9,7 +9,7 @@ class BitPacker
|
|
9
9
|
# Holds types index.
|
10
10
|
#
|
11
11
|
|
12
|
-
TYPES =
|
12
|
+
TYPES = Set::new [
|
13
13
|
:number,
|
14
14
|
:boolean
|
15
15
|
]
|
@@ -204,6 +204,29 @@ class BitPacker
|
|
204
204
|
end
|
205
205
|
|
206
206
|
alias :to_int :to_i
|
207
|
+
|
208
|
+
##
|
209
|
+
# Returns size in bits.
|
210
|
+
#
|
211
|
+
# @return [Integer] size in bits
|
212
|
+
# @since 0.1.1
|
213
|
+
#
|
214
|
+
|
215
|
+
def bitsize
|
216
|
+
@length
|
217
|
+
end
|
218
|
+
|
219
|
+
##
|
220
|
+
# Returns size in bytes. It means number of bits rounded to number
|
221
|
+
# of bytes according to {BYTESIZE}.
|
222
|
+
#
|
223
|
+
# @return [Integer] size in bytes
|
224
|
+
# @since 0.1.1
|
225
|
+
#
|
226
|
+
|
227
|
+
def bytesize
|
228
|
+
(@length.to_f / 8).ceil
|
229
|
+
end
|
207
230
|
|
208
231
|
|
209
232
|
protected
|
metadata
CHANGED
@@ -1,72 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: bit-packer
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
4
5
|
prerelease:
|
5
|
-
version: 0.1.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
-
|
7
|
+
authors:
|
8
|
+
- Martin Kozák
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
17
|
-
name: lookup-hash
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
-
none: false
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.2.0
|
24
|
-
type: :runtime
|
25
|
-
prerelease: false
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-09-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
28
15
|
name: bundler
|
29
|
-
requirement: &
|
16
|
+
requirement: &13431160 !ruby/object:Gem::Requirement
|
30
17
|
none: false
|
31
|
-
requirements:
|
32
|
-
- -
|
33
|
-
- !ruby/object:Gem::Version
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 1.0.0
|
35
22
|
type: :development
|
36
23
|
prerelease: false
|
37
|
-
version_requirements: *
|
38
|
-
- !ruby/object:Gem::Dependency
|
24
|
+
version_requirements: *13431160
|
25
|
+
- !ruby/object:Gem::Dependency
|
39
26
|
name: jeweler
|
40
|
-
requirement: &
|
27
|
+
requirement: &13430500 !ruby/object:Gem::Requirement
|
41
28
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
45
32
|
version: 1.5.2
|
46
33
|
type: :development
|
47
34
|
prerelease: false
|
48
|
-
version_requirements: *
|
49
|
-
- !ruby/object:Gem::Dependency
|
35
|
+
version_requirements: *13430500
|
36
|
+
- !ruby/object:Gem::Dependency
|
50
37
|
name: riot
|
51
|
-
requirement: &
|
38
|
+
requirement: &13429900 !ruby/object:Gem::Requirement
|
52
39
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
56
43
|
version: 0.12.1
|
57
44
|
type: :development
|
58
45
|
prerelease: false
|
59
|
-
version_requirements: *
|
46
|
+
version_requirements: *13429900
|
60
47
|
description:
|
61
48
|
email: martinkozak@martinkozak.net
|
62
49
|
executables: []
|
63
|
-
|
64
50
|
extensions: []
|
65
|
-
|
66
|
-
extra_rdoc_files:
|
51
|
+
extra_rdoc_files:
|
67
52
|
- LICENSE.txt
|
68
53
|
- README.md
|
69
|
-
files:
|
54
|
+
files:
|
70
55
|
- .document
|
71
56
|
- Gemfile
|
72
57
|
- Gemfile.lock
|
@@ -77,36 +62,32 @@ files:
|
|
77
62
|
- bit-packer.gemspec
|
78
63
|
- lib/bit-packer.rb
|
79
64
|
- test
|
80
|
-
has_rdoc: true
|
81
65
|
homepage: http://github.com/martinkozak/bit-packer
|
82
|
-
licenses:
|
66
|
+
licenses:
|
83
67
|
- MIT
|
84
68
|
post_install_message:
|
85
69
|
rdoc_options: []
|
86
|
-
|
87
|
-
require_paths:
|
70
|
+
require_paths:
|
88
71
|
- lib
|
89
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
73
|
none: false
|
91
|
-
requirements:
|
92
|
-
- -
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
|
95
|
-
segments:
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
segments:
|
96
79
|
- 0
|
97
|
-
|
98
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
hash: -2223285121936680072
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
82
|
none: false
|
100
|
-
requirements:
|
101
|
-
- -
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version:
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
104
87
|
requirements: []
|
105
|
-
|
106
88
|
rubyforge_project:
|
107
|
-
rubygems_version: 1.
|
89
|
+
rubygems_version: 1.8.10
|
108
90
|
signing_key:
|
109
91
|
specification_version: 3
|
110
92
|
summary: Provides easy declarative way of analyzing the packed bit arrays.
|
111
93
|
test_files: []
|
112
|
-
|