Hello community, here is the log from the commit of package rubygem-sexp_processor for openSUSE:Factory checked in at 2017-04-20 20:58:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-sexp_processor (Old) and /work/SRC/openSUSE:Factory/.rubygem-sexp_processor.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-sexp_processor" Thu Apr 20 20:58:19 2017 rev:26 rq:489039 version:4.9.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-sexp_processor/rubygem-sexp_processor.changes 2017-04-11 09:31:43.526975264 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-sexp_processor.new/rubygem-sexp_processor.changes 2017-04-20 20:58:21.497107670 +0200 @@ -1,0 +2,20 @@ +Fri Apr 14 04:36:15 UTC 2017 - co...@suse.com + +- updated to version 4.9.0 + see installed History.txt + + === 4.9.0 / 2017-04-13 + + * 9 minor enhancements: + + * Added Sexp.depth + * Added Sexp.sexp_type= + * Cache Sexp.line_max. Massively speeds up large flay runs. + * Cleaned up SexpProcessor.process handling of result node type. + * Extend pt_testcase for ruby 2.4 tests. + * Extended Sexp.method_missing to only print on every invocation if $VERBOSE=1 + * Extended Sexp.method_missing to warn if the expected sub-sexp is not found. + * Rewrote Sexp.mass to be MUCH faster. Helps tremendously with flay on large files. + * Warn that Sexp#method_missing was tripped if $DEBUG. + +------------------------------------------------------------------- Old: ---- sexp_processor-4.8.0.gem New: ---- sexp_processor-4.9.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-sexp_processor.spec ++++++ --- /var/tmp/diff_new_pack.Q1SB3T/_old 2017-04-20 20:58:22.732932898 +0200 +++ /var/tmp/diff_new_pack.Q1SB3T/_new 2017-04-20 20:58:22.736932332 +0200 @@ -24,7 +24,7 @@ # Name: rubygem-sexp_processor -Version: 4.8.0 +Version: 4.9.0 Release: 0 %define mod_name sexp_processor %define mod_full_name %{mod_name}-%{version} ++++++ sexp_processor-4.8.0.gem -> sexp_processor-4.9.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/History.txt new/History.txt --- old/History.txt 2017-02-01 21:04:33.000000000 +0100 +++ new/History.txt 2017-04-14 01:56:57.000000000 +0200 @@ -1,3 +1,17 @@ +=== 4.9.0 / 2017-04-13 + +* 9 minor enhancements: + + * Added Sexp.depth + * Added Sexp.sexp_type= + * Cache Sexp.line_max. Massively speeds up large flay runs. + * Cleaned up SexpProcessor.process handling of result node type. + * Extend pt_testcase for ruby 2.4 tests. + * Extended Sexp.method_missing to only print on every invocation if $VERBOSE=1 + * Extended Sexp.method_missing to warn if the expected sub-sexp is not found. + * Rewrote Sexp.mass to be MUCH faster. Helps tremendously with flay on large files. + * Warn that Sexp#method_missing was tripped if $DEBUG. + === 4.8.0 / 2017-02-01 * 2 minor enhancements: Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ Binary files old/checksums.yaml.gz.sig and new/checksums.yaml.gz.sig differ Binary files old/data.tar.gz.sig and new/data.tar.gz.sig differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pt_testcase.rb new/lib/pt_testcase.rb --- old/lib/pt_testcase.rb 2017-02-01 21:04:33.000000000 +0100 +++ new/lib/pt_testcase.rb 2017-04-14 01:56:57.000000000 +0200 @@ -76,7 +76,7 @@ end def self.add_19tests name, hash - add_tests "#{name}__19_20_21_22_23", hash # HACK? + add_tests "#{name}__19_20_21_22_23_24", hash # HACK? end def self.add_19edgecases ruby, sexp, cases @@ -101,7 +101,7 @@ testcases[verbose][klass] = testcases[nonverbose][klass] end - VER_RE = "(1[89]|2[0123])" + VER_RE = "(1[89]|2[01234])" def self.generate_test klass, node, data, input_name, output_name klass.send :define_method, "test_#{node}" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/sexp.rb new/lib/sexp.rb --- old/lib/sexp.rb 2017-02-01 21:04:33.000000000 +0100 +++ new/lib/sexp.rb 2017-04-14 01:56:57.000000000 +0200 @@ -95,6 +95,10 @@ end end + def depth + 1 + (each_sexp.map(&:depth).max || 0) + end + ## # Enumeratates the sexp yielding to +b+ when the node_type == +t+. @@ -203,21 +207,36 @@ # Returns the maximum line number of the children of self. def line_max - self.deep_each.map(&:line).max + @line_max ||= self.deep_each.map(&:line).max end ## # Returns the size of the sexp, flattened. def mass - @mass ||= self.structure.flatten.size + @mass ||= + inject(1) { |t, s| + if Sexp === s then + t + s.mass + else + t + end + } end ## # Returns the node named +node+, deleting it if +delete+ is true. def method_missing meth, delete = false - find_node meth, delete + r = find_node meth, delete + if ENV["DEBUG"] then + if r.nil? then + warn "%p.method_missing(%p) => nil from %s" % [self, meth, caller.first] + elsif ENV["VERBOSE"] + warn "%p.method_missing(%p) from %s" % [self, meth, caller.first] + end + end + r end def respond_to? msg, private = false # :nodoc: @@ -242,6 +261,13 @@ end ## + # Sets the node type of the Sexp. + + def sexp_type= v + self[0] = v + end + + ## # Returns the Sexp body, ie the values without the node type. def sexp_body diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/sexp_processor.rb new/lib/sexp_processor.rb --- old/lib/sexp_processor.rb 2017-02-01 21:04:33.000000000 +0100 +++ new/lib/sexp_processor.rb 2017-04-14 01:56:57.000000000 +0200 @@ -33,7 +33,7 @@ class SexpProcessor - VERSION = "4.8.0" + VERSION = "4.9.0" ## # Automatically shifts off the Sexp type before handing the @@ -278,12 +278,7 @@ # NOTE: this is costly, but we are in the generic processor # so we shouldn't hit it too much with RubyToC stuff at least. - #if Sexp === exp and not exp.sexp_type.nil? then - begin - result.sexp_type = exp.sexp_type - rescue Exception - # nothing to do, on purpose - end + result.sexp_type = exp.sexp_type if Sexp === exp and exp.sexp_type else msg = "Bug! Unknown node-type #{type.inspect} to #{self.class}" msg += " in #{exp_orig.inspect} from #{caller.inspect}" if $DEBUG diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2017-02-01 21:04:33.000000000 +0100 +++ new/metadata 2017-04-14 01:56:57.000000000 +0200 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: sexp_processor version: !ruby/object:Gem::Version - version: 4.8.0 + version: 4.9.0 platform: ruby authors: - Ryan Davis @@ -30,7 +30,7 @@ E4oJcnPkJAr0rw504JGtlZtONZQblwmRJOIdXzolaE3NRGUzGVOUSptZppAKiavY fO6tdKQc/5RfA8oQEkg8hrxA5PQSz4TOFJGLpFvIapEk6tMruQ0bHgkhr9auXg== -----END CERTIFICATE----- -date: 2017-02-01 00:00:00.000000000 Z +date: 2017-04-13 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rdoc Binary files old/metadata.gz.sig and new/metadata.gz.sig differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/test_sexp.rb new/test/test_sexp.rb --- old/test/test_sexp.rb 2017-02-01 21:04:33.000000000 +0100 +++ new/test/test_sexp.rb 2017-04-14 01:56:57.000000000 +0200 @@ -1,10 +1,24 @@ $TESTING = true require 'minitest/autorun' +require "minitest/benchmark" if ENV["BENCH"] require 'sexp_processor' require 'stringio' require 'pp' +def pyramid_sexp max + # s(:array, + # s(:array, s(:s, 1)), + # s(:array, s(:s, 1), s(:s, 2)), + # ... + # s(:array, s(:s, 1), s(:s, 2), ... s(:s, max-1))) + + s(:array, + *(1...max).map { |n| + s(:array, *(1..n).map { |m| + s(:s, m) })}) +end + class SexpTestCase < Minitest::Test # KEY for regex tests # :a == no change @@ -235,6 +249,15 @@ assert_equal 7, s.mass end + def test_mass_huge + max = 100 + sexp = pyramid_sexp max + + exp = (max*max + max)/2 # pyramid number 1+2+3+...+m + + assert_equal exp, sexp.mass + end + def test_method_missing assert_nil @sexp.not_there assert_equal s(:lit, 42), @basic_sexp.lit @@ -342,6 +365,13 @@ assert_equal [42], @basic_sexp.each_sexp.map { |_, n| n } end + def test_depth + assert_equal 1, s(:a).depth + assert_equal 2, s(:a, s(:b)).depth + assert_equal 3, s(:a, s(:b1, s(:c)), s(:b2)).depth + assert_equal 5, s(:a, s(:b, s(:c, s(:d, s(:e))))).depth + end + def test_deep_each result = [] @complex_sexp.deep_each { |s| result << s if s.first == :if } @@ -373,3 +403,30 @@ end end + +class BenchSexp < Minitest::Benchmark + def run + GC.disable + super + ensure + GC.enable + end + + def self.bench_range + bench_linear 100, 500, 50 + end + + @@data = Hash[bench_range.map { |n| [n, pyramid_sexp(n)] }] + + def bench_pyramid + assert_performance_power do |max| + pyramid_sexp max + end + end + + def bench_mass + assert_performance_power do |max| + @@data[max].mass + end + end +end if ENV["BENCH"]