Hello community, here is the log from the commit of package rubygem-bindata for openSUSE:Factory checked in at 2018-07-18 22:48:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-bindata (Old) and /work/SRC/openSUSE:Factory/.rubygem-bindata.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-bindata" Wed Jul 18 22:48:35 2018 rev:3 rq:620989 version:2.4.3 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-bindata/rubygem-bindata.changes 2018-02-10 17:59:46.292647549 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-bindata.new/rubygem-bindata.changes 2018-07-18 22:48:43.227999279 +0200 @@ -1,0 +2,10 @@ +Tue Mar 20 10:05:11 UTC 2018 - [email protected] + +- updated to version 2.4.3 + see installed ChangeLog.rdoc + + == Version 2.4.3 (2018-03-10) + + * Add Uint8Arrays. Requested by masarakki. + +------------------------------------------------------------------- Old: ---- bindata-2.4.2.gem New: ---- bindata-2.4.3.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-bindata.spec ++++++ --- /var/tmp/diff_new_pack.h9Qps1/_old 2018-07-18 22:48:43.703997701 +0200 +++ /var/tmp/diff_new_pack.h9Qps1/_new 2018-07-18 22:48:43.707997687 +0200 @@ -24,7 +24,7 @@ # Name: rubygem-bindata -Version: 2.4.2 +Version: 2.4.3 Release: 0 %define mod_name bindata %define mod_full_name %{mod_name}-%{version} ++++++ bindata-2.4.2.gem -> bindata-2.4.3.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ChangeLog.rdoc new/ChangeLog.rdoc --- old/ChangeLog.rdoc 2018-01-31 07:48:42.000000000 +0100 +++ new/ChangeLog.rdoc 2018-03-09 17:32:08.000000000 +0100 @@ -1,5 +1,9 @@ = BinData Changelog +== Version 2.4.3 (2018-03-10) + +* Add Uint8Arrays. Requested by masarakki. + == Version 2.4.2 (2018-01-31) * Allow boolean values as parameters. Requested by Patrik Wenger. 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/uint8_array.rb new/lib/bindata/uint8_array.rb --- old/lib/bindata/uint8_array.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/bindata/uint8_array.rb 2018-03-09 17:32:08.000000000 +0100 @@ -0,0 +1,62 @@ +require "bindata/base_primitive" + +module BinData + # Uint8Array is a specialised type of array that only contains + # bytes (Uint8). It is a faster and more memory efficient version + # of `BinData::Array.new(:type => :uint8)`. + # + # require 'bindata' + # + # obj = BinData::Uint8Array.new(initial_length: 5) + # obj.read("abcdefg") #=> [97, 98, 99, 100, 101] + # obj[2] #=> 99 + # obj.collect { |x| x.chr }.join #=> "abcde" + # + # == Parameters + # + # Parameters may be provided at initialisation to control the behaviour of + # an object. These params are: + # + # <tt>:initial_length</tt>:: The initial length of the array. + # <tt>:read_until</tt>:: May only have a value of `:eof`. This parameter + # instructs the array to read as much data from + # the stream as possible. + class Uint8Array < BinData::BasePrimitive + optional_parameters :initial_length, :read_until + mutually_exclusive_parameters :initial_length, :read_until + arg_processor :uint8_array + + #--------------- + private + + def value_to_binary_string(val) + val.pack("C*") + end + + def read_and_return_value(io) + if has_parameter?(:initial_length) + data = io.readbytes(eval_parameter(:initial_length)) + else + data = io.read_all_bytes + end + + data.unpack("C*") + end + + def sensible_default + [] + end + end + + class Uint8ArrayArgProcessor < BaseArgProcessor + def sanitize_parameters!(obj_class, params) #:nodoc: + # ensure one of :initial_length and :read_until exists + unless params.has_at_least_one_of?(:initial_length, :read_until) + params[:initial_length] = 0 + end + + msg = "Parameter :read_until must have a value of :eof" + params.sanitize(:read_until) { |val| raise ArgumentError, msg unless val == :eof } + end + end +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 2018-01-31 07:48:42.000000000 +0100 +++ new/lib/bindata/version.rb 2018-03-09 17:32:08.000000000 +0100 @@ -1,3 +1,3 @@ module BinData - VERSION = "2.4.2" + VERSION = "2.4.3" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/bindata.rb new/lib/bindata.rb --- old/lib/bindata.rb 2018-01-31 07:48:42.000000000 +0100 +++ new/lib/bindata.rb 2018-03-09 17:32:08.000000000 +0100 @@ -26,6 +26,7 @@ require 'bindata/stringz' require 'bindata/struct' require 'bindata/trace' +require 'bindata/uint8_array' require 'bindata/virtual' require 'bindata/alignment' require 'bindata/warnings' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2018-01-31 07:48:42.000000000 +0100 +++ new/metadata 2018-03-09 17:32:08.000000000 +0100 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: bindata version: !ruby/object:Gem::Version - version: 2.4.2 + version: 2.4.3 platform: ruby authors: - Dion Mendel autorequire: bindir: bin cert_chain: [] -date: 2018-01-31 00:00:00.000000000 Z +date: 2018-03-09 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rake @@ -111,6 +111,7 @@ - lib/bindata/stringz.rb - lib/bindata/struct.rb - lib/bindata/trace.rb +- lib/bindata/uint8_array.rb - lib/bindata/version.rb - lib/bindata/virtual.rb - lib/bindata/warnings.rb @@ -139,6 +140,7 @@ - test/struct_test.rb - test/system_test.rb - test/test_helper.rb +- test/uint8_array_test.rb - test/virtual_test.rb - test/warnings_test.rb homepage: http://github.com/dmendel/bindata diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/uint8_array_test.rb new/test/uint8_array_test.rb --- old/test/uint8_array_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/test/uint8_array_test.rb 2018-03-09 17:32:08.000000000 +0100 @@ -0,0 +1,44 @@ +#!/usr/bin/env ruby + +require File.expand_path(File.join(File.dirname(__FILE__), "test_helper")) + +describe BinData::Uint8Array, "when initialising" do + it "with mutually exclusive parameters :initial_length and :read_until" do + params = {initial_length: 5, read_until: :eof} + lambda { BinData::Uint8Array.new(params) }.must_raise ArgumentError + end + + it "with :read_until" do + params = {read_until: :not_eof} + lambda { BinData::Uint8Array.new(params) }.must_raise ArgumentError + end + + it "with no parameters" do + arr = BinData::Uint8Array.new + arr.num_bytes.must_equal 0 + end +end + +describe BinData::Uint8Array, "with :read_until" do + it "reads until :eof" do + arr = BinData::Uint8Array.new(read_until: :eof) + arr.read("\xff\xfe\xfd\xfc") + arr.must_equal([255, 254, 253, 252]) + end +end + +describe BinData::Uint8Array, "with :initial_length" do + it "reads" do + arr = BinData::Uint8Array.new(initial_length: 3) + arr.read("\xff\xfe\xfd\xfc") + arr.must_equal([255, 254, 253]) + end +end + +describe BinData::Uint8Array, "when assigning" do + it "copies data" do + arr = BinData::Uint8Array.new + arr.assign([1, 2, 3]) + arr.must_equal([1, 2, 3]) + end +end
