packable 1.3.10 → 1.3.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +4 -4
- data/lib/packable/extensions/io.rb +5 -1
- data/lib/packable/version.rb +1 -1
- data/packable.gemspec +2 -0
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 565dd12968af7bacf9fedcf6edb3f43fdc1500a25867d2626b031694adb242ef
|
4
|
+
data.tar.gz: 8ae7505c199e0204c8b1194a52f225106c4a99ba5b180c0eaee67da64b8c9538
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 274ab4abb2713ac407add79c445f26034389510bb42e063100a4a492dcfb4d211a0c521610c3067c1fd97cee9736be57d56eddd4d107319d8e3fbcdd03c14c07
|
7
|
+
data.tar.gz: c13095f379613b7206986711cca286152eca8520394121d3fb79d79beab3dd198998bf610290bb0ae0e4a9192cc1c99bc021383fcb1c9136c916e7e3d2ee1560
|
data/README.rdoc
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
*Note*: SciRuby are taking over maintenance for this library: https://github.com/SciRuby/packable
|
2
|
-
|
3
1
|
= Packable Library - Intro
|
4
2
|
|
5
3
|
If you need to do read and write binary data, there is of course <tt>Array::pack</tt> and <tt>String::unpack</tt>.
|
@@ -26,6 +24,7 @@ The method +each+ also accepts packing options:
|
|
26
24
|
StringIO.new("\000\001\000\002\000\003").each(:short).to_a ===> [1,2,3]
|
27
25
|
=== Custom classes
|
28
26
|
It's easy to make you own classes (un)packable. All the previous goodies are thus available:
|
27
|
+
|
29
28
|
File.open("great_flick.flv") do |f|
|
30
29
|
head = f.read(FLV::Header)
|
31
30
|
f.each(FLV::Tag) do |tag|
|
@@ -54,6 +53,7 @@ That's it! Simply <tt>require 'packable'</tt> in your code to use it.
|
|
54
53
|
== Compatibility
|
55
54
|
|
56
55
|
Designed to work with ruby 1.8 & 1.9.
|
56
|
+
If using with ruby 2.5 and higher be sure not to pass `Hash` and `Symbol` arguments to `write` unless you want it to be packed.
|
57
57
|
|
58
58
|
= Documentation
|
59
59
|
|
@@ -97,7 +97,7 @@ When unpacking, it is necessary to specify the class in addition to any option,
|
|
97
97
|
|
98
98
|
It's easy to add shortcuts for easier (un)packing:
|
99
99
|
|
100
|
-
|
100
|
+
String.packers.set :flv_signature, :bytes => 3, :fill => "FLV"
|
101
101
|
|
102
102
|
"x".pack(:flv_signature) ===> "xFL"
|
103
103
|
|
@@ -164,7 +164,7 @@ This is to insure compatibility with the usual behavior of IO objects:
|
|
164
164
|
|
165
165
|
We "cheated" in the previous example; instead of writing <tt>io.packed.write(...)</tt> we used the shorter form.
|
166
166
|
This works because we're passing more than one argument; for only one argument we must call <tt>io.packed.write(66)</tt>
|
167
|
-
less the usual +write+ method is called.
|
167
|
+
less the usual +write+ method is called. Ruby 2.5+ allows more than 1 argument, so monkeypatching was clearly a bad idea. We distinguish between packed or not by checking for Hashes/Symbol or classes including Packable for now.
|
168
168
|
|
169
169
|
Since the standard library desn't define the <tt>>></tt> operator for IO objects, we are free to use either <tt>io.packed</tt> or <tt>io</tt> directly.
|
170
170
|
Note that reading one value only will return that value directly, not an array containing that value:
|
@@ -59,7 +59,11 @@ module Packable
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def write_with_packing(*arg)
|
62
|
-
|
62
|
+
if arg.length > 1 && arg.any? { |a| a.is_a?(Hash) || a.is_a?(Symbol) || a.is_a?(Packable) }
|
63
|
+
pack_and_write(*arg)
|
64
|
+
else
|
65
|
+
write_without_packing(*arg)
|
66
|
+
end
|
63
67
|
end
|
64
68
|
|
65
69
|
def read_with_packing(*arg)
|
data/lib/packable/version.rb
CHANGED
data/packable.gemspec
CHANGED
@@ -6,6 +6,7 @@ require 'packable/version'
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.name = "packable"
|
8
8
|
gem.version = Packable::VERSION
|
9
|
+
gem.homepage = "https://github.com/marcandre/packable"
|
9
10
|
gem.authors = ["Marc-André Lafortune"]
|
10
11
|
gem.email = ["github@marc-andre.ca"]
|
11
12
|
gem.description = %q{If you need to do read and write binary data, there is of course <Array::pack and String::unpack\n The packable library makes (un)packing nicer, smarter and more powerful.\n}
|
@@ -16,6 +17,7 @@ Gem::Specification.new do |gem|
|
|
16
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
19
|
gem.require_paths = ["lib"]
|
20
|
+
gem.required_ruby_version = '>= 1.8.7'
|
19
21
|
gem.add_runtime_dependency 'backports'
|
20
22
|
gem.add_development_dependency 'minitest'
|
21
23
|
gem.add_development_dependency 'shoulda'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.12
|
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: 2020-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backports
|
@@ -107,15 +107,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 1.8.7
|
111
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
113
|
- - ">="
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
|
-
|
118
|
-
rubygems_version: 2.7.7
|
117
|
+
rubygems_version: 3.1.2
|
119
118
|
signing_key:
|
120
119
|
specification_version: 4
|
121
120
|
summary: Extensive packing and unpacking capabilities
|