packable 1.3.12 → 1.3.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 565dd12968af7bacf9fedcf6edb3f43fdc1500a25867d2626b031694adb242ef
4
- data.tar.gz: 8ae7505c199e0204c8b1194a52f225106c4a99ba5b180c0eaee67da64b8c9538
3
+ metadata.gz: b1bd805026140ccad5845e20b2ff64e243e2f8884fdb3cb640d98d7e8019e0a5
4
+ data.tar.gz: cfa942ab0edee1ea3e527672dfc5a4a378a575b583995df1867afa2693c524d3
5
5
  SHA512:
6
- metadata.gz: 274ab4abb2713ac407add79c445f26034389510bb42e063100a4a492dcfb4d211a0c521610c3067c1fd97cee9736be57d56eddd4d107319d8e3fbcdd03c14c07
7
- data.tar.gz: c13095f379613b7206986711cca286152eca8520394121d3fb79d79beab3dd198998bf610290bb0ae0e4a9192cc1c99bc021383fcb1c9136c916e7e3d2ee1560
6
+ metadata.gz: 4b3252d9dc47e15c925a33551f6e5fca3b146ebb8a872310e3e0e10c9172695da7f31eae7e605ef048079dba1485ff55bc9b20a28868f710ee2be4f732e3c8c4
7
+ data.tar.gz: 12fc57813c4d17964bd9ee74a9a61bdcf6fcdeab1bf7761e4695af184b15241093a0a1632a12b1801fcd4cb247814de18c0e8700117115aa18d64dc253a14dd0
@@ -53,7 +53,6 @@ That's it! Simply <tt>require 'packable'</tt> in your code to use it.
53
53
  == Compatibility
54
54
 
55
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
56
 
58
57
  = Documentation
59
58
 
@@ -164,7 +163,7 @@ This is to insure compatibility with the usual behavior of IO objects:
164
163
 
165
164
  We "cheated" in the previous example; instead of writing <tt>io.packed.write(...)</tt> we used the shorter form.
166
165
  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. 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.
166
+ less the usual +write+ method is called.
168
167
 
169
168
  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
169
  Note that reading one value only will return that value directly, not an array containing that value:
@@ -53,21 +53,17 @@ module Packable
53
53
  end
54
54
 
55
55
  def each_with_packing(*options, &block)
56
- return each_without_packing(*options, &block) if options.empty? || (Integer === options.first) || (String === options.first)
56
+ return each_without_packing(*options, &block) if options.empty? || (Integer === options.first) || (String === options.first) || tty?
57
57
  return Enumerator.new(self, :each_with_packing, *options) unless block_given?
58
58
  yield read(*options) until eof?
59
59
  end
60
60
 
61
61
  def write_with_packing(*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
62
+ (arg.length <= 1 || tty?) ? write_without_packing(*arg) : pack_and_write(*arg)
67
63
  end
68
64
 
69
65
  def read_with_packing(*arg)
70
- return read_without_packing(*arg) if arg.empty? || arg.first.nil? || arg.first.is_a?(Numeric)
66
+ return read_without_packing(*arg) if arg.empty? || arg.first.nil? || arg.first.is_a?(Numeric) || tty?
71
67
  values = Packable::Packers.to_class_option_list(*arg).map do |klass, options, original|
72
68
  if options[:read_packed]
73
69
  options[:read_packed].call(self)
@@ -1,3 +1,3 @@
1
1
  module Packable
2
- VERSION = "1.3.12"
2
+ VERSION = "1.3.13"
3
3
  end
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.12
4
+ version: 1.3.13
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: 2020-05-06 00:00:00.000000000 Z
11
+ date: 2020-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backports