Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package rubygem-bindata for openSUSE:Factory 
checked in at 2022-10-12 18:25:03
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-bindata (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-bindata.new.2275 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-bindata"

Wed Oct 12 18:25:03 2022 rev:8 rq:1010048 version:2.4.12

Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-bindata/rubygem-bindata.changes  
2021-06-25 15:02:03.972204877 +0200
+++ 
/work/SRC/openSUSE:Factory/.rubygem-bindata.new.2275/rubygem-bindata.changes    
    2022-10-12 18:26:48.937970407 +0200
@@ -1,0 +2,15 @@
+Mon Oct 10 12:59:42 UTC 2022 - Stephan Kulow <co...@suse.com>
+
+updated to version 2.4.12
+ see installed ChangeLog.rdoc
+
+  == Version 2.4.12 (2022-10-03)
+  
+  * Do not include DelayedIO objects when :onlyif is false.
+  
+  == Version 2.4.11 (2022-09-27)
+  
+  * Make DelayedIO work with :onlyif.  Reported by Spencer McIntyre.
+  
+
+-------------------------------------------------------------------

Old:
----
  bindata-2.4.10.gem

New:
----
  bindata-2.4.12.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-bindata.spec ++++++
--- /var/tmp/diff_new_pack.YRkSj5/_old  2022-10-12 18:26:49.341971296 +0200
+++ /var/tmp/diff_new_pack.YRkSj5/_new  2022-10-12 18:26:49.349971314 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package rubygem-bindata
 #
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -24,7 +24,7 @@
 #
 
 Name:           rubygem-bindata
-Version:        2.4.10
+Version:        2.4.12
 Release:        0
 %define mod_name bindata
 %define mod_full_name %{mod_name}-%{version}

++++++ bindata-2.4.10.gem -> bindata-2.4.12.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ChangeLog.rdoc new/ChangeLog.rdoc
--- old/ChangeLog.rdoc  2021-05-18 05:40:55.000000000 +0200
+++ new/ChangeLog.rdoc  2022-10-03 07:38:43.000000000 +0200
@@ -1,5 +1,13 @@
 = BinData Changelog
 
+== Version 2.4.12 (2022-10-03)
+
+* Do not include DelayedIO objects when :onlyif is false.
+
+== Version 2.4.11 (2022-09-27)
+
+* Make DelayedIO work with :onlyif.  Reported by Spencer McIntyre.
+
 == Version 2.4.10 (2021-05-18)
 
 * Improve speed of dynamic object creation.  Reported by Charlie Ablett.
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/bindata/delayed_io.rb 
new/lib/bindata/delayed_io.rb
--- old/lib/bindata/delayed_io.rb       2021-05-18 05:40:55.000000000 +0200
+++ new/lib/bindata/delayed_io.rb       2022-10-03 07:38:43.000000000 +0200
@@ -116,9 +116,14 @@
       0
     end
 
+    def include_obj?
+      ! has_parameter?(:onlyif) || eval_parameter(:onlyif)
+    end
+
     # DelayedIO objects aren't read when #read is called.
     # The reading is delayed until this method is called.
     def read_now!
+      return unless include_obj?
       raise IOError, "read from where?" unless @read_io
 
       @read_io.seekbytes(abs_offset - @read_io.offset)
@@ -130,7 +135,9 @@
     # DelayedIO objects aren't written when #write is called.
     # The writing is delayed until this method is called.
     def write_now!
+      return unless include_obj?
       raise IOError, "write to where?" unless @write_io
+
       @write_io.seekbytes(abs_offset - @write_io.offset)
       @type.do_write(@write_io)
     end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/bindata/struct.rb new/lib/bindata/struct.rb
--- old/lib/bindata/struct.rb   2021-05-18 05:40:55.000000000 +0200
+++ new/lib/bindata/struct.rb   2022-10-03 07:38:43.000000000 +0200
@@ -1,4 +1,5 @@
 require 'bindata/base'
+require 'bindata/delayed_io'
 
 module BinData
 
@@ -136,12 +137,12 @@
 
     def do_read(io) #:nodoc:
       instantiate_all_objs
-      @field_objs.each { |f| f.do_read(io) if include_obj?(f) }
+      @field_objs.each { |f| f.do_read(io) if include_obj_for_io?(f) }
     end
 
     def do_write(io) #:nodoc
       instantiate_all_objs
-      @field_objs.each { |f| f.do_write(io) if include_obj?(f) }
+      @field_objs.each { |f| f.do_write(io) if include_obj_for_io?(f) }
     end
 
     def do_num_bytes #:nodoc:
@@ -263,6 +264,12 @@
       end
     end
 
+    def include_obj_for_io?(obj)
+      # Used by #do_read and #do_write, to ensure the stream is passed to
+      # DelayedIO objects for delayed processing.
+      include_obj?(obj) || DelayedIO === obj
+    end
+
     def include_obj?(obj)
       !obj.has_parameter?(:onlyif) || obj.eval_parameter(:onlyif)
     end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/bindata/version.rb new/lib/bindata/version.rb
--- old/lib/bindata/version.rb  2021-05-18 05:40:55.000000000 +0200
+++ new/lib/bindata/version.rb  2022-10-03 07:38:43.000000000 +0200
@@ -1,3 +1,3 @@
 module BinData
-  VERSION = "2.4.10"
+  VERSION = "2.4.12"
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2021-05-18 05:40:55.000000000 +0200
+++ new/metadata        2022-10-03 07:38:43.000000000 +0200
@@ -1,14 +1,14 @@
 --- !ruby/object:Gem::Specification
 name: bindata
 version: !ruby/object:Gem::Version
-  version: 2.4.10
+  version: 2.4.12
 platform: ruby
 authors:
 - Dion Mendel
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2021-05-18 00:00:00.000000000 Z
+date: 2022-10-03 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: rake
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/delayed_io_test.rb new/test/delayed_io_test.rb
--- old/test/delayed_io_test.rb 2021-05-18 05:40:55.000000000 +0200
+++ new/test/delayed_io_test.rb 2022-10-03 07:38:43.000000000 +0200
@@ -184,6 +184,51 @@
   end
 end
 
+describe BinData::DelayedIO, "inside a Record with onlyif" do
+  class DelayedIOOnlyIfRecord < BinData::Record
+    endian :little
+
+    uint8 :flag
+    delayed_io :my_int1, read_abs_offset: 4, onlyif: -> { flag != 0 } do
+      uint16 initial_value: 6
+    end
+    delayed_io :my_int2, read_abs_offset: 2, onlyif: -> { flag == 0 } do
+      uint16 initial_value: 7
+    end
+  end
+
+  it "reads" do
+    obj = DelayedIOOnlyIfRecord.read "\x01\x00\x03\x0012345"
+    obj.num_bytes.must_equal 1
+    obj.snapshot.must_equal({flag: 1, my_int1: 6})
+  end
+
+  it "reads explicitly when flag is set" do
+    obj = DelayedIOOnlyIfRecord.read "\x01\xff\x01\x00\x02\x00"
+    obj.my_int1.read_now!
+    obj.my_int2.read_now!
+    obj.num_bytes.must_equal 1
+    obj.snapshot.must_equal({flag: 1, my_int1: 2})
+  end
+
+  it "reads explicitly when flag is not set" do
+    obj = DelayedIOOnlyIfRecord.read "\x00\xff\x01\x00\x02\x00"
+    obj.my_int1.read_now!
+    obj.my_int2.read_now!
+    obj.num_bytes.must_equal 1
+    obj.snapshot.must_equal({flag: 0, my_int2: 1})
+  end
+
+  it "writes" do
+    obj = DelayedIOOnlyIfRecord.new(flag:1, my_int1: 3, my_int2: 4)
+    io = StringIO.new
+    obj.write(io)
+    obj.my_int1.write_now!
+    obj.my_int2.write_now!
+    io.value.must_equal "\x01\x00\x00\x00\x03\x00"
+  end
+end
+
 describe BinData::DelayedIO, "with auto_call" do
   class AutoCallDelayedIORecord < BinData::Record
     auto_call_delayed_io

Reply via email to