packable 1.3.6 → 1.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/README.rdoc +3 -1
- data/lib/packable/extensions/io.rb +1 -1
- data/lib/packable/version.rb +1 -1
- data/packable.gemspec +3 -0
- data/test/packing_doc_test.rb +1 -1
- data/test/packing_test.rb +14 -8
- data/test/test_helper.rb +3 -3
- metadata +50 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24e7953c276fcc3632223b24365e6c324a5f5b7b
|
4
|
+
data.tar.gz: 2739c2b63bd6fbab2a79db3c35b3a41ae4753dc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b06119ec61a835e6ff5d5db4da1de60311561e943c58985d725bf9c839da505a9b45406e96fc879c78ca45bab711d0484c9db24e0500a171251edfba51f9587
|
7
|
+
data.tar.gz: e3184c73de7c225ed121362f679c709baac4cb88b5f15297f89250361dfec4052e2eb06537c3780ad4c46fef69f073252cab9c1ad6094b1944165f5ddd18836c
|
data/.gitignore
CHANGED
data/README.rdoc
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
*Note*: SciRuby are taking over maintenance for this library: https://github.com/SciRuby/packable
|
2
|
+
|
1
3
|
= Packable Library - Intro
|
2
4
|
|
3
5
|
If you need to do read and write binary data, there is of course <tt>Array::pack</tt> and <tt>String::unpack</tt>.
|
@@ -243,4 +245,4 @@ A final note to say that packers are inherited in some way. For instance one cou
|
|
243
245
|
|
244
246
|
packable is licensed under the terms of the MIT License, see the included LICENSE file.
|
245
247
|
|
246
|
-
Author:: Marc-André Lafortune
|
248
|
+
Author:: Marc-André Lafortune
|
@@ -63,7 +63,7 @@ module Packable
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def read_with_packing(*arg)
|
66
|
-
return read_without_packing(*arg) if (arg.length == 0) || (arg.first.is_a?(Numeric) && (arg.length == 1))
|
66
|
+
return read_without_packing(*arg) if (arg.length == 0) || arg.first.nil? || (arg.first.is_a?(Numeric) && (arg.length == 1))
|
67
67
|
values = Packable::Packers.to_class_option_list(*arg).map do |klass, options, original|
|
68
68
|
if options[:read_packed]
|
69
69
|
options[:read_packed].call(self)
|
data/lib/packable/version.rb
CHANGED
data/packable.gemspec
CHANGED
@@ -17,4 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
gem.add_runtime_dependency 'backports'
|
20
|
+
gem.add_development_dependency 'minitest'
|
21
|
+
gem.add_development_dependency 'shoulda'
|
22
|
+
gem.add_development_dependency 'mocha'
|
20
23
|
end
|
data/test/packing_doc_test.rb
CHANGED
data/test/packing_test.rb
CHANGED
@@ -12,7 +12,7 @@ class XYZ
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
class TestingPack < Test
|
15
|
+
class TestingPack < Minitest::Test
|
16
16
|
|
17
17
|
context "Original form" do
|
18
18
|
should "pack like before" do
|
@@ -48,7 +48,7 @@ class TestingPack < Test::Unit::TestCase
|
|
48
48
|
assert_equal (1<<24)-1, -1.pack(:bytes => 3).unpack(Integer, :bytes => 3, :signed => false)
|
49
49
|
assert_equal -1, -1.pack(:bytes => 3).unpack(Integer, :bytes => 3, :signed => true)
|
50
50
|
assert_equal 42, 42.pack('L').unpack(Integer, :bytes => 4, :endian => :native)
|
51
|
-
|
51
|
+
assert_raises(ArgumentError){ 42.pack(:endian => "Geronimo")}
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_bignum
|
@@ -59,7 +59,7 @@ class TestingPack < Test::Unit::TestCase
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_float
|
62
|
-
|
62
|
+
assert_raises(ArgumentError){ Math::PI.pack(:endian => "Geronimo")}
|
63
63
|
assert_equal Math::PI, Math::PI.pack(:precision => :double, :endian => :native).unpack(Float, :precision => :double, :endian => :native)
|
64
64
|
# Issue #1
|
65
65
|
assert_equal Math::PI.pack(:precision => :double), Math::PI.pack('G')
|
@@ -76,17 +76,23 @@ class TestingPack < Test::Unit::TestCase
|
|
76
76
|
assert_equal "!", io.read
|
77
77
|
end
|
78
78
|
|
79
|
+
def test_io_read_nil
|
80
|
+
# library was failing to call read_without_packing when invoked with nil.
|
81
|
+
io = StringIO.new("should read(nil)")
|
82
|
+
assert_equal "should read(nil)", io.read(nil)
|
83
|
+
end
|
84
|
+
|
79
85
|
should "do basic type checking" do
|
80
|
-
|
86
|
+
assert_raises(TypeError) {"".unpack(42, :short)}
|
81
87
|
end
|
82
88
|
|
83
89
|
context "Reading beyond the eof" do
|
84
90
|
should "raises an EOFError when reading" do
|
85
91
|
["", "x"].each do |s|
|
86
92
|
io = StringIO.new(s)
|
87
|
-
|
88
|
-
|
89
|
-
|
93
|
+
assert_raises(EOFError) {io.read(:double)}
|
94
|
+
assert_raises(EOFError) {io.read(:short)}
|
95
|
+
assert_raises(EOFError) {io.read(String, :bytes => 4)}
|
90
96
|
end
|
91
97
|
end
|
92
98
|
|
@@ -119,7 +125,7 @@ class TestingPack < Test::Unit::TestCase
|
|
119
125
|
|
120
126
|
should "be accessible only from that class and descendants" do
|
121
127
|
assert_equal "Hello", "World".pack(:specific_writer)
|
122
|
-
|
128
|
+
assert_raises RuntimeError do
|
123
129
|
6.pack(:specific_writer)
|
124
130
|
end
|
125
131
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,27 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: packable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc-André Lafortune
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backports
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: shoulda
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mocha
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
25
67
|
- !ruby/object:Gem::Version
|
26
68
|
version: '0'
|
27
69
|
description: If you need to do read and write binary data, there is of course <Array::pack
|
@@ -33,7 +75,7 @@ executables: []
|
|
33
75
|
extensions: []
|
34
76
|
extra_rdoc_files: []
|
35
77
|
files:
|
36
|
-
- .gitignore
|
78
|
+
- ".gitignore"
|
37
79
|
- CHANGELOG.rdoc
|
38
80
|
- Gemfile
|
39
81
|
- LICENSE.txt
|
@@ -63,17 +105,17 @@ require_paths:
|
|
63
105
|
- lib
|
64
106
|
required_ruby_version: !ruby/object:Gem::Requirement
|
65
107
|
requirements:
|
66
|
-
- -
|
108
|
+
- - ">="
|
67
109
|
- !ruby/object:Gem::Version
|
68
110
|
version: '0'
|
69
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
112
|
requirements:
|
71
|
-
- -
|
113
|
+
- - ">="
|
72
114
|
- !ruby/object:Gem::Version
|
73
115
|
version: '0'
|
74
116
|
requirements: []
|
75
117
|
rubyforge_project:
|
76
|
-
rubygems_version: 2.
|
118
|
+
rubygems_version: 2.2.2
|
77
119
|
signing_key:
|
78
120
|
specification_version: 4
|
79
121
|
summary: Extensive packing and unpacking capabilities
|