bindata 2.4.3 → 2.4.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bindata might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ChangeLog.rdoc +6 -0
- data/README.md +0 -1
- data/lib/bindata.rb +3 -11
- data/lib/bindata/bits.rb +11 -7
- data/lib/bindata/int.rb +11 -6
- data/lib/bindata/io.rb +1 -1
- data/lib/bindata/registry.rb +9 -3
- data/lib/bindata/version.rb +1 -1
- data/test/registry_test.rb +8 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc513e5824615b4b143e4a733bd6e8290bdfa831ab111267475a167f31125bb1
|
4
|
+
data.tar.gz: 93b4a5203a1d641dd1af806b769f92f8daf50644e9815d01fa2dbfec9f30bc8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88c701264083edfa92d193c33d394f7cb4bdc2f12722089ff27bb296bad28665f8e28a63158c98a8a45a189c68ce4792c027615ac0c9f1c61cacee1e02e817cc
|
7
|
+
data.tar.gz: dd1f06f1b17cbc005ca5399d86b62cfe420787d8a2f820d24f589f30dd58af99ed539eb5d5873f90b3877f986093a3bc5f176dcb7aaaeea176381809272b20ff
|
data/ChangeLog.rdoc
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
= BinData Changelog
|
2
2
|
|
3
|
+
== Version 2.4.4 (2018-10-03)
|
4
|
+
|
5
|
+
* Display a hint when endian is omitted. Requested by Tails.
|
6
|
+
* Add thread safety to Integer/BitField creation. Requested by jbpeirce.
|
7
|
+
* Ensure windows sockets are unseekable. Thanks to Brent Cook.
|
8
|
+
|
3
9
|
== Version 2.4.3 (2018-03-10)
|
4
10
|
|
5
11
|
* Add Uint8Arrays. Requested by masarakki.
|
data/README.md
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
[![Version ](http://img.shields.io/gem/v/bindata.svg) ](https://rubygems.org/gems/bindata)
|
4
4
|
[![Travis CI ](http://img.shields.io/travis/dmendel/bindata/master.svg) ](https://travis-ci.org/dmendel/bindata)
|
5
|
-
[![Quality ](http://img.shields.io/codeclimate/github/dmendel/bindata.svg)](https://codeclimate.com/github/dmendel/bindata)
|
6
5
|
[![Coverage ](http://img.shields.io/coveralls/dmendel/bindata.svg) ](https://coveralls.io/r/dmendel/bindata)
|
7
6
|
|
8
7
|
Do you ever find yourself writing code like this?
|
data/lib/bindata.rb
CHANGED
@@ -1,13 +1,5 @@
|
|
1
1
|
# BinData -- Binary data manipulator.
|
2
|
-
# Copyright (c) 2007 -
|
3
|
-
|
4
|
-
if RUBY_VERSION <= "1.9"
|
5
|
-
fail "BinData requires ruby >= 1.9.3. Use BinData version 1.8.x instead"
|
6
|
-
end
|
7
|
-
|
8
|
-
if RUBY_VERSION == "2.1.0" and RUBY_PATCHLEVEL == "0"
|
9
|
-
fail "Ruby 2.1.0p0 has a bug that causes BinData to fail. Upgrade your ruby version"
|
10
|
-
end
|
2
|
+
# Copyright (c) 2007 - 2018 Dion Mendel.
|
11
3
|
|
12
4
|
require 'bindata/version'
|
13
5
|
require 'bindata/array'
|
@@ -36,10 +28,10 @@ require 'bindata/warnings'
|
|
36
28
|
# A declarative way to read and write structured binary data.
|
37
29
|
#
|
38
30
|
# A full reference manual is available online at
|
39
|
-
#
|
31
|
+
# https://github.com/dmendel/bindata/wiki
|
40
32
|
#
|
41
33
|
# == License
|
42
34
|
#
|
43
35
|
# BinData is released under the same license as Ruby.
|
44
36
|
#
|
45
|
-
# Copyright (c) 2007 -
|
37
|
+
# Copyright (c) 2007 - 2018 Dion Mendel.
|
data/lib/bindata/bits.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'thread'
|
1
2
|
require 'bindata/base_primitive'
|
2
3
|
|
3
4
|
module BinData
|
@@ -5,15 +6,18 @@ module BinData
|
|
5
6
|
# The integer is defined by endian and number of bits.
|
6
7
|
|
7
8
|
module BitField #:nodoc: all
|
9
|
+
@@mutex = Mutex.new
|
10
|
+
|
8
11
|
class << self
|
9
12
|
def define_class(name, nbits, endian, signed = :unsigned)
|
10
|
-
|
11
|
-
BinData.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
@@mutex.synchronize do
|
14
|
+
unless BinData.const_defined?(name)
|
15
|
+
new_class = Class.new(BinData::BasePrimitive)
|
16
|
+
BitField.define_methods(new_class, nbits, endian.to_sym, signed.to_sym)
|
17
|
+
RegisteredClasses.register(name, new_class)
|
18
|
+
|
19
|
+
BinData.const_set(name, new_class)
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
BinData.const_get(name)
|
data/lib/bindata/int.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'thread'
|
1
2
|
require 'bindata/base_primitive'
|
2
3
|
|
3
4
|
module BinData
|
@@ -5,14 +6,18 @@ module BinData
|
|
5
6
|
# is defined by endian, signedness and number of bytes.
|
6
7
|
|
7
8
|
module Int #:nodoc: all
|
9
|
+
@@mutex = Mutex.new
|
10
|
+
|
8
11
|
class << self
|
9
12
|
def define_class(name, nbits, endian, signed)
|
10
|
-
|
11
|
-
BinData.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
@@mutex.synchronize do
|
14
|
+
unless BinData.const_defined?(name)
|
15
|
+
new_class = Class.new(BinData::BasePrimitive)
|
16
|
+
Int.define_methods(new_class, nbits, endian.to_sym, signed.to_sym)
|
17
|
+
RegisteredClasses.register(name, new_class)
|
18
|
+
|
19
|
+
BinData.const_set(name, new_class)
|
20
|
+
end
|
16
21
|
end
|
17
22
|
|
18
23
|
BinData.const_get(name)
|
data/lib/bindata/io.rb
CHANGED
data/lib/bindata/registry.rb
CHANGED
@@ -24,7 +24,7 @@ module BinData
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def register(name, class_to_register)
|
27
|
-
return if class_to_register.nil?
|
27
|
+
return if name.nil? || class_to_register.nil?
|
28
28
|
|
29
29
|
formatted_name = underscore_name(name)
|
30
30
|
warn_if_name_is_already_registered(formatted_name, class_to_register)
|
@@ -37,8 +37,14 @@ module BinData
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def lookup(name, hints = {})
|
40
|
-
|
41
|
-
|
40
|
+
the_class = @registry[normalize_name(name, hints)]
|
41
|
+
if the_class
|
42
|
+
the_class
|
43
|
+
elsif @registry[normalize_name(name, hints.merge(endian: :big))]
|
44
|
+
raise(UnRegisteredTypeError, "#{name}, do you need to specify endian?")
|
45
|
+
else
|
46
|
+
raise(UnRegisteredTypeError, name)
|
47
|
+
end
|
42
48
|
end
|
43
49
|
|
44
50
|
# Convert CamelCase +name+ to underscore style.
|
data/lib/bindata/version.rb
CHANGED
data/test/registry_test.rb
CHANGED
@@ -71,6 +71,14 @@ describe BinData::Registry, "with numerics" do
|
|
71
71
|
}.must_raise BinData::UnRegisteredTypeError
|
72
72
|
end
|
73
73
|
|
74
|
+
it "provides a nice error message when endian is omitted" do
|
75
|
+
begin
|
76
|
+
r.lookup("int24")
|
77
|
+
rescue BinData::UnRegisteredTypeError => e
|
78
|
+
e.message.must_equal "int24, do you need to specify endian?"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
74
82
|
it "does not lookup non byte based integers" do
|
75
83
|
lambda {
|
76
84
|
r.lookup("int3")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bindata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dion Mendel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03
|
11
|
+
date: 2018-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
165
|
version: '0'
|
166
166
|
requirements: []
|
167
167
|
rubyforge_project: bindata
|
168
|
-
rubygems_version: 2.6
|
168
|
+
rubygems_version: 2.7.6
|
169
169
|
signing_key:
|
170
170
|
specification_version: 4
|
171
171
|
summary: A declarative way to read and write binary file formats
|