packable 1.3.10 → 1.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3153716400e2f39421e6eba85ceb0d83a665f4efe1088503953b3c90a69c4781
4
- data.tar.gz: 736319d061f9bed0306f16a27c3391aa8675645970fd046809c21a238d7cb0a4
3
+ metadata.gz: 565dd12968af7bacf9fedcf6edb3f43fdc1500a25867d2626b031694adb242ef
4
+ data.tar.gz: 8ae7505c199e0204c8b1194a52f225106c4a99ba5b180c0eaee67da64b8c9538
5
5
  SHA512:
6
- metadata.gz: 3e626328601bc4f5aa2a7e933b4e3e8bf894bff2afc0a99b37a0efbc7a3b599f7dc5c96de18502ef38bfefb4989e3093518951d80b61c6cc538572afe4a32323
7
- data.tar.gz: f6e56d03ffc9b20bb739d478c925852022fd834e365a30c4c6eeacaebd238fdc02811af04451fcbade176af528a5d99f339b45d263b4a6ca0c76631ff4b8c181
6
+ metadata.gz: 274ab4abb2713ac407add79c445f26034389510bb42e063100a4a492dcfb4d211a0c521610c3067c1fd97cee9736be57d56eddd4d107319d8e3fbcdd03c14c07
7
+ data.tar.gz: c13095f379613b7206986711cca286152eca8520394121d3fb79d79beab3dd198998bf610290bb0ae0e4a9192cc1c99bc021383fcb1c9136c916e7e3d2ee1560
@@ -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
- String.packers.set :flv_signature, :bytes => 3, :fill => "FLV"
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
- (arg.length <= 1) ? write_without_packing(*arg) : pack_and_write(*arg)
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)
@@ -1,3 +1,3 @@
1
1
  module Packable
2
- VERSION = "1.3.10"
2
+ VERSION = "1.3.12"
3
3
  end
@@ -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.10
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: 2018-09-20 00:00:00.000000000 Z
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: '0'
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
- rubyforge_project:
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