rubyment 0.6.25563758 → 0.6.25581116
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 +4 -4
- data/lib/rubyment.rb +814 -86
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0a1dc731e8fd7860ae00dcf476648dd311322f2
|
4
|
+
data.tar.gz: 75ec3ac1a176cbef2d3717f4c0aa8ec45ef05c20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 798fc0253107f5b698b529776dfbd12133506b25afe02be2cd1a66ee2aad01fadf495002868f1374569d6fa281cd5c8740c0a175bd07a0c31848a28d036ccee9
|
7
|
+
data.tar.gz: 82bc3dccb487171a155c3af0cd0d78a379815f69338d3618ff2ce84c7e5873e5d871a250c91e5d181033327a380956b70d0b1c40ea7e7a23941ea65dadba3660
|
data/lib/rubyment.rb
CHANGED
@@ -112,11 +112,11 @@ module RubymentExperimentModule
|
|
112
112
|
=begin
|
113
113
|
|
114
114
|
# documentation_begin
|
115
|
-
# short_desc
|
115
|
+
# short_desc => "calls the method #call of an object, or return the object itself",
|
116
116
|
@memory[:documentation].push = {
|
117
117
|
:function => :call_or_itself,
|
118
118
|
:short_desc => short_desc,
|
119
|
-
:description => "
|
119
|
+
:description => "",
|
120
120
|
:params => [
|
121
121
|
{
|
122
122
|
:name => :args,
|
@@ -333,7 +333,6 @@ module RubymentExperimentModule
|
|
333
333
|
debug = debug.nne
|
334
334
|
debug && (stderr.puts "{#{__method__} starting")
|
335
335
|
debug && (stderr.puts "caller=#{caller_label.inspect}")
|
336
|
-
debug && (stderr.puts backtrace)
|
337
336
|
debug && (stderr.puts "args=#{args.inspect}")
|
338
337
|
test_cases = test_cases.nne [
|
339
338
|
# [ :id, :expectation, :actual_params ],
|
@@ -351,6 +350,7 @@ module RubymentExperimentModule
|
|
351
350
|
result = send actual_params_method_name, *actual_params_method_args
|
352
351
|
expectation[test_case_id] = test_expectation
|
353
352
|
actual[test_case_id] = result
|
353
|
+
debug && (stderr.puts "[test_expectation.hash, result.hash]=#{[test_expectation.hash, result.hash].inspect}")
|
354
354
|
}
|
355
355
|
judgement = actual.keys.map {|test_case|
|
356
356
|
[expectation[test_case], actual[test_case] , test_case]
|
@@ -364,48 +364,372 @@ module RubymentExperimentModule
|
|
364
364
|
|
365
365
|
|
366
366
|
=begin
|
367
|
+
write the second argument of the array args into the filepath in the first argument
|
367
368
|
=end
|
368
|
-
def
|
369
|
-
|
370
|
-
|
371
|
-
|
369
|
+
def file__json args=[]
|
370
|
+
require 'json'
|
371
|
+
file_path,
|
372
|
+
enum,
|
373
|
+
reserved = args
|
374
|
+
File.write file_path, JSON.pretty_generate({ :root.to_s => enum })
|
375
|
+
end
|
376
|
+
|
377
|
+
|
378
|
+
=begin
|
379
|
+
inverse of #file__json
|
380
|
+
=end
|
381
|
+
def load__file_json args=[]
|
382
|
+
require 'json'
|
383
|
+
file_path,
|
384
|
+
reserved = args
|
385
|
+
file_contents = File.read file_path
|
386
|
+
puts "file_contents size=#{file_contents.size}"
|
387
|
+
loaded = JSON.parse file_contents
|
388
|
+
puts "loaded size=#{loaded.size}"
|
389
|
+
puts "loaded=#{loaded.inspect}"
|
390
|
+
loaded[:root.to_s]
|
391
|
+
end
|
392
|
+
|
393
|
+
|
394
|
+
=begin
|
395
|
+
c = :c
|
396
|
+
experiment__input_select [[:a, :b, :c], c ]
|
397
|
+
=end
|
398
|
+
def experiment__input_select args=[]
|
399
|
+
alternatives,
|
400
|
+
default,
|
401
|
+
reserved = args
|
402
|
+
stderr = @memory[:stderr]
|
403
|
+
caption = alternatives.each_with_index.map {|a, i| "#{i} - #{a.inspect}"}.join("\n")
|
404
|
+
stderr.puts "[alternatives: #{caption}][default: #{default.inspect}]"
|
405
|
+
alternative = input_single_line
|
406
|
+
selection = alternative.nne && alternatives[alternative.to_i] || default
|
407
|
+
end
|
408
|
+
|
409
|
+
|
410
|
+
# these shell_ functions can take only flatten arrays (intended for ARGV):
|
411
|
+
def shell_string_split args=[]
|
412
|
+
string,
|
413
|
+
splitter,
|
414
|
+
reserved = args
|
415
|
+
string.split Regexp.new splitter
|
416
|
+
end
|
417
|
+
|
418
|
+
|
419
|
+
def shell_array_first a
|
420
|
+
a.first
|
421
|
+
end
|
422
|
+
|
423
|
+
|
424
|
+
def shell_array_deepen a
|
425
|
+
[ a ]
|
426
|
+
end
|
427
|
+
|
428
|
+
|
429
|
+
def get_self args=[]
|
430
|
+
self
|
431
|
+
end
|
432
|
+
|
433
|
+
|
434
|
+
=begin
|
435
|
+
enum = (s.scan /http_[^(]*/).uniq.map
|
436
|
+
# => #<Enumerator: ...>
|
437
|
+
# send_enumerator [ enum, :gsub, ["http_", ""] ]
|
438
|
+
# => ["delete", "get", "head", "post", "put"]
|
439
|
+
|
440
|
+
|
441
|
+
=end
|
442
|
+
def send_enumerator args=[]
|
443
|
+
enum,
|
444
|
+
method,
|
445
|
+
args_to_method,
|
446
|
+
block_to_method,
|
447
|
+
replace_at_index,
|
448
|
+
reserved = args
|
449
|
+
|
450
|
+
args_to_method = args_to_method.nne []
|
451
|
+
|
452
|
+
calling_tuples = enum.map {|e|
|
453
|
+
method_name = (!method.respond_to? :call) && method || nil
|
454
|
+
method_to_call = (!method_name) && method || (
|
455
|
+
(!replace_at_index) && e.method(:send)
|
456
|
+
) || method(:send)
|
457
|
+
c_t = args_to_method.dup
|
458
|
+
replace_at_index && (c_t[replace_at_index] = e)
|
459
|
+
method_name && (c_t.unshift method_name)
|
460
|
+
c_t.unshift method_to_call
|
461
|
+
c_t
|
462
|
+
}
|
463
|
+
|
464
|
+
calling_tuples.map {|c_t|
|
465
|
+
method_to_call, *args_to_call = c_t
|
466
|
+
method_to_call.call *args_to_call, &block_to_method
|
467
|
+
}
|
468
|
+
end
|
469
|
+
|
470
|
+
|
471
|
+
=begin
|
472
|
+
given a duck type table, return the entries having
|
473
|
+
methods that o responds to in their first entry.
|
474
|
+
|
475
|
+
by default, uses a table useful to determine
|
476
|
+
method_name for the call:
|
477
|
+
o.map.method_name {|a, b| }
|
478
|
+
if o is an Array, it should be each_with_entries:
|
479
|
+
experiment__duck_type__hash_array [ [] ]
|
480
|
+
=> [[:product, :each_with_key, :itself]]
|
481
|
+
|
482
|
+
if o is a Hash, it should be (another) map.
|
483
|
+
experiment__duck_type__hash_array [ {} ]
|
484
|
+
=> [[:keys, :map, :reversed]]
|
485
|
+
|
486
|
+
note that "reversed" means that the order must
|
487
|
+
be |b,a| instead
|
488
|
+
|
489
|
+
=end
|
490
|
+
def experiment__duck_type__hash_array args=[]
|
491
|
+
o,
|
492
|
+
duck_type_table,
|
493
|
+
reserved = args
|
494
|
+
duck_type_table = duck_type_table.nne [
|
495
|
+
[ :product, :each_with_index, :itself, :to_a ],
|
496
|
+
[ :keys, :map, :reverse, :to_h ],
|
497
|
+
]
|
498
|
+
rv = duck_type_table.select { |e|
|
499
|
+
responding_method, *r = e
|
500
|
+
o.respond_to? responding_method
|
501
|
+
}
|
502
|
+
rv
|
503
|
+
end
|
504
|
+
|
505
|
+
|
506
|
+
=begin
|
507
|
+
for each leaf of a (which normally is an Array or Hash),
|
508
|
+
calls block_to_send_to_leaf giving the leaf as arg,
|
509
|
+
(or return the leaf in the case block_to_send_to_leaf is nil).
|
510
|
+
modifies tuples and deep_keys so it contains the results, the
|
511
|
+
deep_keys and the tuples at each step.
|
512
|
+
|
513
|
+
direct_cycle_placeholder => object to place when a directed cycled
|
514
|
+
(ie, the object is already present in its stack) is found. defaults
|
515
|
+
to :direct_cycle_placeholder. undirect cycle: same thing, but searches
|
516
|
+
in the visited_nodes.
|
517
|
+
|
518
|
+
Don't use nil, 0, "" as cycleplace holders, use a value v which
|
519
|
+
returns itself if called v.nne; it means that the default
|
520
|
+
should be used
|
521
|
+
|
522
|
+
BFS: only problem: this uniq should work on object ID
|
523
|
+
x[1][:tuples].transpose[2].transpose.flatten.uniq
|
524
|
+
=> [{:a=>{:b=>:c}, :d=>{:e=>nil}}, {:b=>:c}, {:e=>nil}]
|
525
|
+
|
526
|
+
|
527
|
+
=end
|
528
|
+
def experiment__recursive_array__visitor args=[]
|
529
|
+
graph_object,
|
530
|
+
block_to_send_to_leaf,
|
531
|
+
deep_keys,
|
532
|
+
duck_type_detector,
|
372
533
|
debug,
|
373
|
-
|
374
|
-
|
375
|
-
|
534
|
+
duck_type_table,
|
535
|
+
tuples,
|
536
|
+
stack,
|
537
|
+
visited_nodes,
|
538
|
+
direct_cycle_placeholder,
|
539
|
+
undirect_cycle_placeholder,
|
540
|
+
undirected_graph,
|
376
541
|
reserved = args
|
542
|
+
recursion_args = args.dup
|
377
543
|
|
378
544
|
stderr = @memory[:stderr]
|
379
545
|
debug = debug.nne
|
380
|
-
debug = 1
|
381
546
|
debug && (stderr.puts "{#{__method__} starting")
|
382
|
-
debug && (stderr.puts "
|
383
|
-
debug && (stderr.puts "
|
547
|
+
debug && (stderr.puts "caller=#{caller_label}")
|
548
|
+
debug && (stderr.puts "args.each_with_index=#{args.each_with_index.entries.inspect}")
|
549
|
+
undirect_cycle_placeholder = undirect_cycle_placeholder.nne ":undirect_cycle_placeholder"
|
550
|
+
direct_cycle_placeholder = direct_cycle_placeholder.nne ":direct_cycle_placeholder"
|
551
|
+
# structures one per node: nne
|
552
|
+
deep_keys = deep_keys.nne []
|
553
|
+
stack = stack.nne []
|
554
|
+
# structures shared by all nodes: just ensure exists
|
555
|
+
tuples ||= []
|
556
|
+
visited_nodes ||= []
|
557
|
+
|
558
|
+
# old_debug = debug
|
559
|
+
# debug = (graph_object.keys.index :b) rescue old_debug
|
560
|
+
debug && (stderr.puts "=#{}")
|
561
|
+
debug && (stderr.puts "graph_object.object_id=#{graph_object.object_id}")
|
562
|
+
object_id_method_name = :object_id_method_name
|
563
|
+
|
564
|
+
|
565
|
+
# cycles detection section
|
566
|
+
undirected_cycle = undirected_graph && (
|
567
|
+
visited_nodes.map(&:object_id).index graph_object.object_id
|
568
|
+
)
|
569
|
+
debug && undirected_graph && (stderr.puts "visited_nodes_with_oid=#{visited_nodes.map{|y| [y, y.object_id] }}")
|
570
|
+
debug && (stderr.puts "undirected_cycle=#{undirected_cycle.inspect}")
|
384
571
|
|
385
|
-
|
386
|
-
|
387
|
-
debug && (stderr.puts "
|
572
|
+
directed_cycle = stack.map(&:object_id).index graph_object.object_id
|
573
|
+
debug && (stderr.puts "stack_with_oid=#{stack.map{|y| [y, y.object_id] }}")
|
574
|
+
debug && (stderr.puts "directed_cycle=#{directed_cycle.inspect}")
|
388
575
|
|
389
|
-
|
390
|
-
|
391
|
-
|
576
|
+
cycle_placeholder = (
|
577
|
+
directed_cycle && direct_cycle_placeholder ||
|
578
|
+
undirected_cycle && undirect_cycle_placeholder
|
579
|
+
)
|
580
|
+
cycle_placeholder && (a = cycle_placeholder)
|
581
|
+
cycle_placeholder.negate_me && (a = graph_object)
|
392
582
|
|
393
|
-
|
394
|
-
|
395
|
-
|
583
|
+
# debug = old_debug
|
584
|
+
visited_nodes.push a
|
585
|
+
stack.push a
|
396
586
|
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
587
|
+
# detecting the type of object. depending if Hash or Array,
|
588
|
+
# methods to call are different.
|
589
|
+
duck_type_detector = duck_type_detector.nne :map
|
590
|
+
duck_type_def = experiment__duck_type__hash_array(
|
591
|
+
[
|
592
|
+
a,
|
593
|
+
duck_type_table
|
594
|
+
])
|
595
|
+
iterating_method = duck_type_def.transpose[1].to_a.first
|
596
|
+
final_method = duck_type_def.transpose[2].to_a.first
|
597
|
+
revert_method = duck_type_def.transpose[3].to_a.first
|
598
|
+
leaf = nil
|
599
|
+
result = (a.respond_to? duck_type_detector) && a.send(iterating_method).map {|a, b|
|
600
|
+
e, i = *([a, b].send(final_method))
|
601
|
+
debug && (stderr.puts "e, i=#{[e, i]}")
|
602
|
+
recursion_args[0] = e
|
603
|
+
deep_keys.push i
|
604
|
+
recursion_args[2] = deep_keys.dup
|
605
|
+
recursion_args[6] = tuples
|
606
|
+
recursion_args[7] = stack.dup
|
607
|
+
recursion_args[8] = visited_nodes
|
608
|
+
recursion_args[9] = directed_cycle
|
609
|
+
recursion_args[10] = undirected_cycle
|
610
|
+
debug && (stderr.puts "recursion_args.each_with_index=#{recursion_args.each_with_index.entries.inspect}")
|
611
|
+
child_result = send __method__, recursion_args
|
612
|
+
deep_keys.pop
|
613
|
+
[i, child_result]
|
614
|
+
} || (
|
615
|
+
block_to_send_to_leaf && (leaf = block_to_send_to_leaf. call a)
|
616
|
+
!block_to_send_to_leaf && (leaf = a)
|
617
|
+
tuples.push [
|
618
|
+
deep_keys,
|
619
|
+
leaf,
|
620
|
+
stack,
|
621
|
+
[:cycle_to_stack_index, directed_cycle],
|
622
|
+
[:cycle_to_visited_nodes_index, undirected_cycle],
|
623
|
+
]
|
624
|
+
leaf
|
625
|
+
)
|
402
626
|
|
627
|
+
# rebuilding the graph object after visits
|
628
|
+
rebuilt_object = (nil.send revert_method) rescue result
|
629
|
+
(result.respond_to? duck_type_detector) && (
|
630
|
+
result.map {|i, e|
|
631
|
+
rebuilt_object[i] = e[:result]
|
632
|
+
# rebuilt_object[i] = (e[:result] rescue e)
|
633
|
+
}
|
634
|
+
)
|
635
|
+
rv = {
|
636
|
+
:visited_nodes => visited_nodes,
|
637
|
+
:tuples => tuples,
|
638
|
+
:result => rebuilt_object,
|
639
|
+
}
|
640
|
+
# stack.pop
|
403
641
|
debug && (stderr.puts "will return #{rv.inspect}")
|
404
642
|
debug && (stderr.puts "#{__method__} returning}")
|
405
643
|
rv
|
406
644
|
end
|
407
645
|
|
408
646
|
|
647
|
+
def test__experiment__recursive_array__visitor args=[]
|
648
|
+
method_to_test = :experiment__recursive_array__visitor
|
649
|
+
direct_cycle_h = {
|
650
|
+
:a => {
|
651
|
+
:b => [ :c ],
|
652
|
+
},
|
653
|
+
:d => {
|
654
|
+
:e => nil,
|
655
|
+
},
|
656
|
+
}
|
657
|
+
direct_cycle_h[:a][:f] = direct_cycle_h[:a]
|
658
|
+
undirect_cycle_h = {
|
659
|
+
:a => {
|
660
|
+
:b => [ :c ],
|
661
|
+
},
|
662
|
+
:d => {
|
663
|
+
:e => nil,
|
664
|
+
},
|
665
|
+
}
|
666
|
+
undirect_cycle_h[:d][:g] = undirect_cycle_h[:a]
|
667
|
+
[
|
668
|
+
(send method_to_test, [
|
669
|
+
[ 1, [ 2, 3, [ 4 ] ] ],
|
670
|
+
lambda {|x| "a{#{x}}a" },
|
671
|
+
:deep_keys.to_nil,
|
672
|
+
:duck_type_d.to_nil,
|
673
|
+
:debug_please.negate_me,
|
674
|
+
]),
|
675
|
+
|
676
|
+
(send method_to_test, [
|
677
|
+
{
|
678
|
+
:a => {
|
679
|
+
:b => :c,
|
680
|
+
},
|
681
|
+
:d => {
|
682
|
+
:e => nil,
|
683
|
+
},
|
684
|
+
},
|
685
|
+
lambda {|x| "h{#{x}}h" },
|
686
|
+
:deep_keys.to_nil,
|
687
|
+
:duck_type_d.to_nil,
|
688
|
+
:debug_please.negate_me,
|
689
|
+
]),
|
690
|
+
|
691
|
+
(send method_to_test, [
|
692
|
+
direct_cycle_h,
|
693
|
+
lambda {|x| "dch{#{x}}dch" },
|
694
|
+
:deep_keys.to_nil,
|
695
|
+
:duck_type_d.to_nil,
|
696
|
+
:debug_please.negate_me,
|
697
|
+
]),
|
698
|
+
|
699
|
+
(send method_to_test, [
|
700
|
+
undirect_cycle_h,
|
701
|
+
lambda {|x| "uch{#{x}}uch" },
|
702
|
+
:deep_keys.to_nil,
|
703
|
+
:duck_type_d.to_nil,
|
704
|
+
:debug_please.negate_me,
|
705
|
+
:duck_type_table.to_nil,
|
706
|
+
:tuples.to_nil,
|
707
|
+
:stack.to_nil,
|
708
|
+
:visited_nodes.to_nil,
|
709
|
+
:direct_cycle_placeholder.to_nil,
|
710
|
+
:undirect_cycle_placeholder.to_nil,
|
711
|
+
:undirect_graph,
|
712
|
+
]),
|
713
|
+
|
714
|
+
(send method_to_test, [
|
715
|
+
undirect_cycle_h,
|
716
|
+
lambda {|x| "not_uch{#{x}}not_uch" },
|
717
|
+
:deep_keys.to_nil,
|
718
|
+
:duck_type_d.to_nil,
|
719
|
+
:debug_please.negate_me,
|
720
|
+
:duck_type_table.to_nil,
|
721
|
+
:tuples.to_nil,
|
722
|
+
:stack.to_nil,
|
723
|
+
:visited_nodes.to_nil,
|
724
|
+
:direct_cycle_placeholder.to_nil,
|
725
|
+
:undirect_cycle_placeholder.to_nil,
|
726
|
+
:undirect_graph.negate_me,
|
727
|
+
]),
|
728
|
+
|
729
|
+
]
|
730
|
+
end
|
731
|
+
|
732
|
+
|
409
733
|
end
|
410
734
|
|
411
735
|
|
@@ -418,9 +742,139 @@ end
|
|
418
742
|
module RubymentMaintainedModule
|
419
743
|
|
420
744
|
|
745
|
+
=begin
|
746
|
+
# documentation_begin
|
747
|
+
# short_desc = "extracts information about a block and return them structurally in an array."
|
748
|
+
@memory[:documentation].push = {
|
749
|
+
:function => :block_info_base,
|
750
|
+
:short_desc => short_desc,
|
751
|
+
:description => "",
|
752
|
+
:params => [
|
753
|
+
{
|
754
|
+
:name => :args,
|
755
|
+
:description => "list of parameters",
|
756
|
+
:duck_type => Array,
|
757
|
+
:default_behavior => [],
|
758
|
+
:params => [
|
759
|
+
{
|
760
|
+
:name => :block,
|
761
|
+
:duck_type => Exception,
|
762
|
+
:default_behavior => nil,
|
763
|
+
:description => "block to extract info from",
|
764
|
+
},
|
765
|
+
{
|
766
|
+
:name => :max_str_index,
|
767
|
+
:duck_type => FixNum,
|
768
|
+
:default_behavior => -1,
|
769
|
+
:description => "limit the full string output to this last index",
|
770
|
+
},
|
771
|
+
{
|
772
|
+
:name => :reserved,
|
773
|
+
:duck_type => Object,
|
774
|
+
:default_behavior => nil,
|
775
|
+
:description => "reserved for future use",
|
776
|
+
},
|
777
|
+
],
|
778
|
+
},
|
779
|
+
],
|
780
|
+
:return_value => [
|
781
|
+
{
|
782
|
+
:name => :short,
|
783
|
+
:duck_type => String,
|
784
|
+
:default_behavior => "",
|
785
|
+
:description => "a brief about the block; normally a block inspection",
|
786
|
+
},
|
787
|
+
{
|
788
|
+
:name => :full,
|
789
|
+
:duck_type => String,
|
790
|
+
:default_behavior => "",
|
791
|
+
:description => "all the information about the block",
|
792
|
+
},
|
793
|
+
{
|
794
|
+
:name => :inspection,
|
795
|
+
:duck_type => String,
|
796
|
+
:default_behavior => "",
|
797
|
+
:description => "the block inspection",
|
798
|
+
},
|
799
|
+
{
|
800
|
+
:name => :source_location,
|
801
|
+
:duck_type => Object,
|
802
|
+
:duck_type => [:_a, Array, :strings],
|
803
|
+
:description => the block location",
|
804
|
+
},
|
805
|
+
{
|
806
|
+
:name => :source,
|
807
|
+
:duck_type => String,
|
808
|
+
:default_behavior => "",
|
809
|
+
:description => "the block source code",
|
810
|
+
},
|
811
|
+
{
|
812
|
+
:name => :class_,
|
813
|
+
:duck_type => String,
|
814
|
+
:default_behavior => "",
|
815
|
+
:description => "the block class",
|
816
|
+
},
|
817
|
+
{
|
818
|
+
:name => :comment,
|
819
|
+
:duck_type => String,
|
820
|
+
:default_behavior => "",
|
821
|
+
:description => "the block comment",
|
822
|
+
},
|
823
|
+
{
|
824
|
+
:name => :reserved,
|
825
|
+
:duck_type => Object,
|
826
|
+
:default_behavior => nil,
|
827
|
+
:description => "reserved for future use",
|
828
|
+
},
|
829
|
+
],
|
830
|
+
}
|
831
|
+
# documentation_end
|
832
|
+
=end
|
833
|
+
def block_info_base args=[]
|
834
|
+
block,
|
835
|
+
max_str_index,
|
836
|
+
reserved = args
|
837
|
+
inspection = block.inspect
|
838
|
+
class_ = block.class
|
839
|
+
comment = block.comment rescue [nil, "doesn't respond to :comment"]
|
840
|
+
source = block.source rescue [nil, "doesn't respond to :source"]
|
841
|
+
source_location = block.source_location rescue [nil, "doesn't respond to :source_location"]
|
842
|
+
parameters = block.parameters.inspect rescue [nil, "doesn't respond to :parameters"]
|
843
|
+
short = inspection
|
844
|
+
full = (
|
845
|
+
[
|
846
|
+
"inspection{",
|
847
|
+
inspection,
|
848
|
+
"}",
|
849
|
+
"class{",
|
850
|
+
class_,
|
851
|
+
"}",
|
852
|
+
"source_location{",
|
853
|
+
source_location,
|
854
|
+
"}",
|
855
|
+
"source{",
|
856
|
+
source,
|
857
|
+
"}",
|
858
|
+
"comment{",
|
859
|
+
comment,
|
860
|
+
"}",
|
861
|
+
"parameters{",
|
862
|
+
parameters,
|
863
|
+
"}",
|
864
|
+
]
|
865
|
+
).join "\n"
|
866
|
+
|
867
|
+
full = string_truncate [
|
868
|
+
full,
|
869
|
+
max_str_index,
|
870
|
+
]
|
871
|
+
[short, full, inspection, source_location, source, class_, comment]
|
872
|
+
end
|
873
|
+
|
874
|
+
|
421
875
|
=begin
|
422
876
|
# documentation_begin
|
423
|
-
# short_desc = "
|
877
|
+
# short_desc = "extracts information about an exception and return them structurally in an array."
|
424
878
|
@memory[:documentation].push = {
|
425
879
|
:function => :exception_info_base,
|
426
880
|
:short_desc => short_desc,
|
@@ -539,7 +993,7 @@ module RubymentMaintainedModule
|
|
539
993
|
|
540
994
|
=begin
|
541
995
|
# documentation_begin
|
542
|
-
# short_desc = "
|
996
|
+
# short_desc = "generates a block which may return exceptions instead of raising them."
|
543
997
|
@memory[:documentation].push = {
|
544
998
|
:function => :bled,
|
545
999
|
:short_desc => short_desc,
|
@@ -567,7 +1021,7 @@ module RubymentMaintainedModule
|
|
567
1021
|
:name => :output_backtrace,
|
568
1022
|
:duck_type => Object,
|
569
1023
|
:default_behavior => :nil,
|
570
|
-
:description => "
|
1024
|
+
:description => "debug the block execution (misleading name)",
|
571
1025
|
},
|
572
1026
|
{
|
573
1027
|
:name => :backtrace_max_str_len,
|
@@ -631,7 +1085,7 @@ module RubymentMaintainedModule
|
|
631
1085
|
stderr = @memory[:stderr]
|
632
1086
|
default_on_exception,
|
633
1087
|
dont_rescue,
|
634
|
-
output_backtrace,
|
1088
|
+
output_backtrace, # better call "debug_block"
|
635
1089
|
backtrace_max_str_len,
|
636
1090
|
debug,
|
637
1091
|
reserved = args
|
@@ -642,16 +1096,25 @@ module RubymentMaintainedModule
|
|
642
1096
|
rv = Proc.new { |*block_args|
|
643
1097
|
(debug || output_backtrace) && (stderr.puts "{#{__method__} block starting")
|
644
1098
|
(debug || output_backtrace) && (stderr.puts "block_args=#{block_args.inspect}")
|
1099
|
+
(debug || output_backtrace) && (stderr.puts "block_args.size=#{block_args.size}")
|
645
1100
|
brv = begin
|
646
|
-
[ (block.call *block_args), nil, nil]
|
1101
|
+
local_rv = [ (block.call *block_args), nil, nil]
|
1102
|
+
(debug || output_backtrace) && (stderr.puts "#{__method__} block: survived exception and returned #{local_rv.inspect}")
|
1103
|
+
local_rv
|
647
1104
|
rescue => e
|
648
1105
|
e_info = exception_info_base [
|
649
1106
|
e,
|
650
1107
|
backtrace_max_str_len
|
651
1108
|
]
|
1109
|
+
b_info = block_info_base [
|
1110
|
+
block,
|
1111
|
+
backtrace_max_str_len
|
1112
|
+
]
|
652
1113
|
(debug || output_backtrace) && (stderr.puts "#{__method__} block: #{block.inspect}\nfull exception info:\n#{e_info[1]}")
|
653
|
-
(debug || output_backtrace) && (stderr.puts "#{__method__} block:
|
1114
|
+
(debug || output_backtrace) && (stderr.puts "#{__method__} block: info #{b_info[1]} ")
|
1115
|
+
(debug || output_backtrace) && (dont_rescue) && (stderr.puts "#{__method__} block: dont_rescue=#{dont_rescue.inspect}; will rethrow")
|
654
1116
|
dont_rescue && (raise e)
|
1117
|
+
(debug || output_backtrace) && (stderr.puts "#{__method__} block: dont_rescue=#{dont_rescue.inspect}; not rethrowing rethrow")
|
655
1118
|
[ default_on_exception, e_info, e ]
|
656
1119
|
end
|
657
1120
|
(debug || output_backtrace) && (stderr.puts "block #{block.inspect} will return #{brv.inspect}")
|
@@ -667,7 +1130,7 @@ module RubymentMaintainedModule
|
|
667
1130
|
|
668
1131
|
=begin
|
669
1132
|
# documentation_begin
|
670
|
-
# short_desc = "
|
1133
|
+
# short_desc = "truncates a string"
|
671
1134
|
@memory[:documentation].push = {
|
672
1135
|
:function => :string_truncate,
|
673
1136
|
:short_desc => short_desc,
|
@@ -1236,7 +1699,7 @@ module RubymentTestModule
|
|
1236
1699
|
# test_case:
|
1237
1700
|
[
|
1238
1701
|
# id:
|
1239
|
-
|
1702
|
+
"test #{method_to_test} base :array_first_remainder",
|
1240
1703
|
# expectation:
|
1241
1704
|
[ [ :arg_to_send_1, [:arg_to_send_2, :arg_to_send_3]], nil, nil],
|
1242
1705
|
# method_name + args:
|
@@ -1245,15 +1708,154 @@ module RubymentTestModule
|
|
1245
1708
|
method_to_test,
|
1246
1709
|
# args to method_to_test:
|
1247
1710
|
[
|
1248
|
-
|
1249
|
-
|
1711
|
+
# array_first_remainder is a method of...
|
1712
|
+
self,
|
1713
|
+
# method to call
|
1714
|
+
:array_first_remainder,
|
1715
|
+
# args to array_first_remainder
|
1716
|
+
[ :arg_to_send_1, :arg_to_send_2, :arg_to_send_3 ],
|
1717
|
+
# block to array_first_remainder
|
1718
|
+
nil,
|
1719
|
+
# args_to_bled:
|
1720
|
+
[nil, :dont_rescue.negate_me, :debug_block.negate_me],
|
1721
|
+
# nil method takes Array (and not splat)
|
1722
|
+
:is_array_method,
|
1723
|
+
# destination:
|
1724
|
+
nil,
|
1725
|
+
# debug:
|
1726
|
+
0,
|
1727
|
+
],
|
1728
|
+
],
|
1729
|
+
],
|
1730
|
+
# test_case:
|
1731
|
+
[
|
1732
|
+
# id:
|
1733
|
+
"test #{method_to_test} base nil method ",
|
1734
|
+
# expectation:
|
1735
|
+
[[ :arg_to_send_1, :arg_to_send_2, :arg_to_send_3 ], nil, nil],
|
1736
|
+
# method_name + args:
|
1737
|
+
[
|
1738
|
+
# method_name:
|
1739
|
+
method_to_test,
|
1740
|
+
# args to method_to_test:
|
1741
|
+
[
|
1742
|
+
# object responding to method to call:
|
1743
|
+
self,
|
1744
|
+
# method to call: nil method (no method):
|
1745
|
+
:method_to_call.to_nil,
|
1746
|
+
# args to nil method:
|
1747
|
+
[ :arg_to_send_1, :arg_to_send_2, :arg_to_send_3 ],
|
1748
|
+
# block to nil method:
|
1749
|
+
nil,
|
1750
|
+
# args_to_bled:
|
1751
|
+
[nil, :no_rescue.negate_me, :debug_block.to_nil],
|
1752
|
+
# nil method takes splat (and not Array)
|
1753
|
+
:is_array_method.to_nil,
|
1754
|
+
# destination:
|
1755
|
+
nil,
|
1756
|
+
# debug:
|
1757
|
+
0,
|
1758
|
+
],
|
1759
|
+
],
|
1760
|
+
],
|
1761
|
+
# test_case:
|
1762
|
+
[
|
1763
|
+
# id:
|
1764
|
+
"test #{method_to_test} nil.inspect ",
|
1765
|
+
# expectation:
|
1766
|
+
["nil", nil, nil],
|
1767
|
+
# method_name + args:
|
1768
|
+
[
|
1769
|
+
# method_name:
|
1770
|
+
method_to_test,
|
1771
|
+
# args to method_to_test:
|
1772
|
+
[
|
1773
|
+
# object responding to method to call:
|
1774
|
+
nil,
|
1775
|
+
# method to call on nil
|
1776
|
+
:inspect,
|
1777
|
+
# args to inspect:
|
1778
|
+
nil,
|
1779
|
+
# block to inspect:
|
1780
|
+
nil,
|
1781
|
+
# args_to_bled:
|
1782
|
+
[nil, :no_rescue.negate_me, :debug_block.to_nil ],
|
1783
|
+
# inspect takes splat (and not Array)
|
1784
|
+
:is_array_method.to_nil,
|
1785
|
+
# destination:
|
1786
|
+
nil,
|
1787
|
+
# debug:
|
1788
|
+
0,
|
1250
1789
|
],
|
1251
|
-
# array_first_remainder is a function of...
|
1252
|
-
self,
|
1253
|
-
# debug:
|
1254
|
-
0,
|
1255
1790
|
],
|
1256
1791
|
],
|
1792
|
+
# test_case:
|
1793
|
+
[
|
1794
|
+
# id:
|
1795
|
+
"test #{method_to_test} array.map(&:to_s) ",
|
1796
|
+
# expectation:
|
1797
|
+
[["1", "2", "3"], nil, nil],
|
1798
|
+
# method_name + args:
|
1799
|
+
[
|
1800
|
+
# method_name:
|
1801
|
+
method_to_test,
|
1802
|
+
# args to method_to_test:
|
1803
|
+
[
|
1804
|
+
# object responding to method to call:
|
1805
|
+
[1, 2, 3],
|
1806
|
+
# method to call on [1, 2, 3]:
|
1807
|
+
:map,
|
1808
|
+
# args to :map
|
1809
|
+
[],
|
1810
|
+
# block to map:
|
1811
|
+
lambda {|x| x.to_s },
|
1812
|
+
# args_to_bled:
|
1813
|
+
[nil, :no_rescue.negate_me, :debug_block.to_nil ],
|
1814
|
+
# map takes splat (and not Array)
|
1815
|
+
:is_array_method.to_nil,
|
1816
|
+
# destination:
|
1817
|
+
nil,
|
1818
|
+
# debug:
|
1819
|
+
0,
|
1820
|
+
],
|
1821
|
+
],
|
1822
|
+
],
|
1823
|
+
# test_case:
|
1824
|
+
[
|
1825
|
+
# id:
|
1826
|
+
"test #{method_to_test} array_unflatten_base",
|
1827
|
+
# expectation:
|
1828
|
+
[[ :a, [ :b ], :c], nil, nil],
|
1829
|
+
# method_name + args:
|
1830
|
+
[
|
1831
|
+
# method_name:
|
1832
|
+
method_to_test,
|
1833
|
+
# args to method_to_test:
|
1834
|
+
[
|
1835
|
+
# object responding to method call:
|
1836
|
+
self,
|
1837
|
+
# method to call on self
|
1838
|
+
:array_unflatten_base, [
|
1839
|
+
[:a, "[", :b, "]", :c],
|
1840
|
+
:shallow,
|
1841
|
+
:debug.negate_me,
|
1842
|
+
:reserved_tokens.to_nil,
|
1843
|
+
:inverse.negate_me,
|
1844
|
+
],
|
1845
|
+
# block to array_unflatten_base
|
1846
|
+
nil,
|
1847
|
+
# args_to_bled:
|
1848
|
+
[nil, :dont_rescue.negate_me, :debug_block.to_nil],
|
1849
|
+
# array_unflatten_base takes array (and not splat)
|
1850
|
+
:is_array_method,
|
1851
|
+
# destination:
|
1852
|
+
nil,
|
1853
|
+
# debug:
|
1854
|
+
0,
|
1855
|
+
],
|
1856
|
+
],
|
1857
|
+
],
|
1858
|
+
# test_case end
|
1257
1859
|
|
1258
1860
|
]
|
1259
1861
|
end
|
@@ -1283,26 +1885,23 @@ module RubymentTestModule
|
|
1283
1885
|
=end
|
1284
1886
|
stderr = @memory[:stderr]
|
1285
1887
|
debug = debug.nne
|
1286
|
-
debug = 1
|
1287
1888
|
debug && (stderr.puts "{#{__method__} starting")
|
1288
1889
|
debug && (stderr.puts "caller=#{caller_label}")
|
1289
|
-
debug && (stderr.puts backtrace)
|
1290
1890
|
debug && (stderr.puts "args=#{args.inspect}")
|
1291
1891
|
test_cases = (test_cases__experiment__send_array_base args)
|
1292
1892
|
debug && (stderr.puts "test_cases.size=#{test_cases.size}")
|
1293
1893
|
experiment__tester_block = bled [
|
1294
1894
|
nil,
|
1295
1895
|
:no_rescue.negate_me,
|
1296
|
-
:output,
|
1896
|
+
:output.negate_me,
|
1297
1897
|
] {
|
1298
1898
|
experiment__tester [
|
1299
|
-
(test_cases),
|
1899
|
+
(test_cases), 0
|
1300
1900
|
]
|
1301
1901
|
}
|
1302
1902
|
debug && (stderr.puts "experiment__tester_block=#{experiment__tester_block.inspect}")
|
1303
1903
|
rv = experiment__tester_block.first.call
|
1304
1904
|
debug && (stderr.puts "will return #{rv.inspect}")
|
1305
|
-
# if raises exception before it will be unbalanced :
|
1306
1905
|
debug && (stderr.puts "#{__method__} returning}")
|
1307
1906
|
rv
|
1308
1907
|
end
|
@@ -1526,7 +2125,7 @@ module RubymentModule
|
|
1526
2125
|
# +headers+:: [Hash] +"Authorization"+ key will be added to it if +auth_user+ is given. Defaults to +{}+
|
1527
2126
|
# +method+:: [HTTP method] one of +:get+, +:method+, +:post+ or +:delete+. defaults to +:get+
|
1528
2127
|
# +timeout+:: [Fixnum, nil] defaults to +nil+
|
1529
|
-
# +
|
2128
|
+
# +request_method+:: [Method name] if given, won't call open-uri's or 'rest-client' , and will use this method instead. It has to have the same signature as #rest_request_or_open_uri_open. By default is +false+ to respect open-closed principle, but it is advised to be set to http_request_response__curl (which depends on 'curb') -- since, for some kind of responses, as redirects, a full featured http client is needed.
|
1530
2129
|
#
|
1531
2130
|
# @return [String, Object] read data (or +return_on_rescue+)
|
1532
2131
|
def file_read args=ARGV
|
@@ -1543,17 +2142,19 @@ module RubymentModule
|
|
1543
2142
|
method,
|
1544
2143
|
timeout,
|
1545
2144
|
debug,
|
2145
|
+
request_method,
|
1546
2146
|
reserved = args
|
1547
2147
|
debug = debug.nne 1
|
1548
2148
|
debug && (stderr.puts "{#{__method__} starting")
|
1549
2149
|
debug && (stderr.puts "args=#{args.inspect}")
|
2150
|
+
request_method = request_method.nne :rest_request_or_open_uri_open
|
1550
2151
|
uri = uri.nne ""
|
1551
2152
|
file_is_directory = File.directory?(uri)
|
1552
2153
|
must_return_on_rescue = false
|
1553
2154
|
return_on_directory_given ||= true
|
1554
2155
|
contents = !(file_is_directory) && (
|
1555
2156
|
begin
|
1556
|
-
url_response = (send
|
2157
|
+
url_response = (send request_method, [
|
1557
2158
|
uri,
|
1558
2159
|
payload,
|
1559
2160
|
verify_ssl,
|
@@ -1563,15 +2164,19 @@ module RubymentModule
|
|
1563
2164
|
password,
|
1564
2165
|
timeout,
|
1565
2166
|
skip_open_uri,
|
2167
|
+
:debug_request_method.to_nil,
|
2168
|
+
:no_rescue_i_catch_exceptions,
|
1566
2169
|
]).first
|
1567
2170
|
debug && (stderr.puts "url_response=#{url_response.inspect}")
|
1568
2171
|
url_response
|
1569
2172
|
rescue => e1
|
1570
2173
|
begin
|
1571
|
-
|
2174
|
+
e_info = exception_info_base [e1]
|
2175
|
+
debug && (stderr.puts "exception e1=#{e_info[1]} ")
|
1572
2176
|
File.read uri
|
1573
2177
|
rescue => e2
|
1574
|
-
|
2178
|
+
e_info = exception_info_base [e2]
|
2179
|
+
debug && (stderr.puts "exception e2=#{e_info[2]}")
|
1575
2180
|
debug && (stderr.puts "return_on_rescue=#{return_on_rescue.inspect}")
|
1576
2181
|
must_return_on_rescue = true
|
1577
2182
|
return_on_rescue
|
@@ -5046,11 +5651,13 @@ n8mFEtUKobsK
|
|
5046
5651
|
admit_non_ssl = admit_non_ssl.nne true
|
5047
5652
|
http_file_read_attempt = (
|
5048
5653
|
debug && (stderr.puts "file_read \"https://#{domain}:#{http_server_port}/#{path}\"")
|
5049
|
-
file_read ["https://#{domain}:#{http_server_port}/#{path}", nil, nil, :
|
5654
|
+
file_read ["https://#{domain}:#{http_server_port}/#{path}", nil, nil, nil, nil, :skip_open_uri, nil, nil, nil, nil, nil, nil, :http_request_response__curl]
|
5050
5655
|
)
|
5051
5656
|
debug && (stderr.puts "#{admit_non_ssl.inspect} && file_read \"http://#{domain}:#{http_server_port}/#{path}\"")
|
5052
5657
|
response = http_file_read_attempt ||
|
5053
|
-
admit_non_ssl && (
|
5658
|
+
admit_non_ssl && (
|
5659
|
+
file_read ["http://#{domain}:#{http_server_port}/#{path}", nil, nil, nil, nil, :skip_open_uri, nil, nil, nil, nil, nil, nil, :http_request_response__curl]
|
5660
|
+
)
|
5054
5661
|
rv = [response, http_file_read_attempt]
|
5055
5662
|
debug && (stderr.puts "#{__method__} will return [response, http_file_read_attempt]=#{rv.inspect}")
|
5056
5663
|
debug && (stderr.puts "#{__method__} returning}")
|
@@ -5196,6 +5803,10 @@ n8mFEtUKobsK
|
|
5196
5803
|
# experimental stuff coming. usage example:
|
5197
5804
|
# ./rubyment.rb invoke_double p test__shell_send_array__main "tinga" "" sub in EN
|
5198
5805
|
# ["tENga"]
|
5806
|
+
# will be deprecated by send_array_base
|
5807
|
+
# ./rubyment.rb invoke_double p experiment__send_array_base 300 "bytes"
|
5808
|
+
# [[51, 48, 48], nil, nil]
|
5809
|
+
# only works with strings by now
|
5199
5810
|
def test__shell_send_array__main args=[]
|
5200
5811
|
p args
|
5201
5812
|
object_to_send,
|
@@ -5857,7 +6468,8 @@ n8mFEtUKobsK
|
|
5857
6468
|
|
5858
6469
|
|
5859
6470
|
=begin
|
5860
|
-
#
|
6471
|
+
# begin_documentation
|
6472
|
+
# short_desc = "tests the function #string_repetition"
|
5861
6473
|
|
5862
6474
|
@memory[:documentation].push = {
|
5863
6475
|
:function => :test__string_repetition,
|
@@ -5880,6 +6492,7 @@ n8mFEtUKobsK
|
|
5880
6492
|
},
|
5881
6493
|
],
|
5882
6494
|
}
|
6495
|
+
# end_documentation
|
5883
6496
|
|
5884
6497
|
|
5885
6498
|
=end
|
@@ -5985,53 +6598,168 @@ n8mFEtUKobsK
|
|
5985
6598
|
end
|
5986
6599
|
|
5987
6600
|
|
6601
|
+
module RubymentDevelopmentModule
|
6602
|
+
|
6603
|
+
|
5988
6604
|
=begin
|
5989
|
-
|
5990
|
-
|
5991
|
-
|
5992
|
-
|
5993
|
-
|
5994
|
-
=begin
|
5995
|
-
c = :c
|
5996
|
-
experiment__input_select [[:a, :b, :c], c ]
|
6605
|
+
trying to get the interface compatible with
|
6606
|
+
# rest_request_or_open_uri_open
|
6607
|
+
# ideally, i would need an equivalent for
|
6608
|
+
# rest_response__request_base
|
6609
|
+
|
5997
6610
|
=end
|
5998
|
-
|
5999
|
-
def experiment__input_select args=[]
|
6000
|
-
alternatives,
|
6001
|
-
default,
|
6002
|
-
reserved = args
|
6611
|
+
def http_request_response__curl args=[]
|
6003
6612
|
stderr = @memory[:stderr]
|
6004
|
-
|
6005
|
-
|
6006
|
-
|
6007
|
-
|
6613
|
+
url,
|
6614
|
+
payload,
|
6615
|
+
verify_ssl,
|
6616
|
+
unimplemented__headers,
|
6617
|
+
method,
|
6618
|
+
auth_user,
|
6619
|
+
password,
|
6620
|
+
unimplemented__timeout,
|
6621
|
+
unused__skip_open_uri,
|
6622
|
+
debug,
|
6623
|
+
no_rescuing,
|
6624
|
+
reserved = args
|
6625
|
+
|
6626
|
+
debug = debug.nne
|
6627
|
+
debug && (stderr.puts "{#{__method__} starting")
|
6628
|
+
debug && (stderr.puts "caller=#{caller_label}")
|
6629
|
+
debug && (stderr.puts "args.each_with_index=#{args.each_with_index.entries.inspect}")
|
6630
|
+
no_rescuing = no_rescuing.nne
|
6631
|
+
method = method.nne "get"
|
6632
|
+
verify_ssl = verify_ssl.nne
|
6633
|
+
curl_method = "http_#{method.downcase}"
|
6634
|
+
curl_post_data = payload.nne
|
6635
|
+
curl_args = [url, curl_post_data].compact
|
6636
|
+
block = bled [
|
6637
|
+
:no_answer.to_nil,
|
6638
|
+
no_rescuing,
|
6639
|
+
no_rescuing,
|
6640
|
+
] {
|
6641
|
+
require 'curb'
|
6642
|
+
c = Curl::Easy.send curl_method, *curl_args
|
6643
|
+
c.http_auth_types = :basic
|
6644
|
+
c.username = auth_user
|
6645
|
+
c.password = password
|
6646
|
+
# follow_location?
|
6647
|
+
c.ssl_verify_host = verify_ssl
|
6648
|
+
c.ssl_verify_peer = verify_ssl
|
6649
|
+
c.perform
|
6650
|
+
[ c.body_str, nil, c.http_connect_code]
|
6651
|
+
}
|
6652
|
+
rv = block.first.call
|
6653
|
+
# rv = block_rv.first
|
6654
|
+
|
6655
|
+
debug && (stderr.puts "#{__method__} will return #{rv.inspect}")
|
6656
|
+
debug && (stderr.puts "#{__method__} returning}")
|
6657
|
+
rv
|
6658
|
+
end
|
6659
|
+
|
6660
|
+
|
6661
|
+
def runtime_tmp_dir # for initialize
|
6008
6662
|
end
|
6009
|
-
end
|
6010
6663
|
|
6011
6664
|
|
6012
6665
|
=begin
|
6666
|
+
returns args
|
6013
6667
|
=end
|
6014
|
-
|
6015
|
-
|
6016
|
-
|
6017
|
-
|
6018
|
-
|
6668
|
+
def experiment__resolve args=[]
|
6669
|
+
reference_or_value,
|
6670
|
+
resolver,
|
6671
|
+
debug,
|
6672
|
+
dont_resolve,
|
6019
6673
|
reserved = args
|
6020
|
-
|
6674
|
+
rv
|
6021
6675
|
end
|
6022
|
-
|
6023
|
-
|
6024
|
-
|
6676
|
+
|
6677
|
+
|
6678
|
+
|
6679
|
+
=begin
|
6680
|
+
# note: some functions may misbehave if they have different
|
6681
|
+
# behaviours depending if they get a block or not
|
6682
|
+
# to be tested.
|
6683
|
+
=end
|
6684
|
+
def experiment__send_array_base args=[]
|
6685
|
+
object_to_send,
|
6686
|
+
method_to_send,
|
6687
|
+
args_to_send,
|
6688
|
+
block_to_send,
|
6689
|
+
args_to_bled,
|
6690
|
+
is_array_method,
|
6691
|
+
reference,
|
6692
|
+
derref_args,
|
6693
|
+
debug,
|
6694
|
+
shallow,
|
6695
|
+
send_to_self,
|
6025
6696
|
reserved = args
|
6026
|
-
|
6027
|
-
|
6028
|
-
|
6029
|
-
puts "
|
6030
|
-
puts "
|
6031
|
-
|
6697
|
+
|
6698
|
+
stderr = @memory[:stderr]
|
6699
|
+
debug = debug.nne
|
6700
|
+
debug && (stderr.puts "{#{__method__} starting")
|
6701
|
+
debug && (stderr.puts "args.each_with_index=#{args.each_with_index.entries.inspect}")
|
6702
|
+
|
6703
|
+
reference = reference.nne
|
6704
|
+
args_to_send = args_to_send.nne []
|
6705
|
+
is_array_method = is_array_method.nne
|
6706
|
+
args_to_send = is_array_method && [args_to_send] || args_to_send
|
6707
|
+
block_to_send = block_to_send.nne
|
6708
|
+
|
6709
|
+
args_to_bled = args_to_bled.nne []
|
6710
|
+
default_on_exception,
|
6711
|
+
dont_rescue,
|
6712
|
+
output_backtrace,
|
6713
|
+
unsed = args_to_bled
|
6714
|
+
|
6715
|
+
default_on_exception = default_on_exception.nne
|
6716
|
+
dont_rescue = dont_rescue.nne
|
6717
|
+
output_backtrace = output_backtrace.nne
|
6718
|
+
|
6719
|
+
debug && (stderr.puts "general case{: #{object_to_send.inspect}.#{method_to_send.inspect}(#{args_to_send.inspect})&#{block_to_send} }")
|
6720
|
+
|
6721
|
+
send_block = bled(args_to_bled) {
|
6722
|
+
(debug || output_backtrace) && (stderr.puts "{#{__method__} block starting")
|
6723
|
+
(debug || output_backtrace) && (stderr.puts "#{__method__} block: args.each_with_index=#{args.each_with_index.entries.inspect}")
|
6724
|
+
|
6725
|
+
brv = object_to_send.send method_to_send, *args_to_send, &block_to_send
|
6726
|
+
|
6727
|
+
(debug || output_backtrace) && (stderr.puts "#{__method__} block will return #{brv.inspect}")
|
6728
|
+
(debug || output_backtrace) && (stderr.puts "#{__method__} block returning}")
|
6729
|
+
brv
|
6730
|
+
}.first
|
6731
|
+
|
6732
|
+
default_block = bled(args_to_bled) {
|
6733
|
+
(debug || output_backtrace) && (stderr.puts "#{__method__} block: nil method makes return #{args_to_send.inspect}")
|
6734
|
+
args_to_send
|
6735
|
+
}.first
|
6736
|
+
|
6737
|
+
block_return, e_info, exception = experiment__whether [
|
6738
|
+
method_to_send,
|
6739
|
+
send_block,
|
6740
|
+
default_block,
|
6741
|
+
]
|
6742
|
+
|
6743
|
+
rv = [block_return, e_info, exception]
|
6744
|
+
|
6745
|
+
debug && (stderr.puts "will return #{rv.inspect}")
|
6746
|
+
debug && (stderr.puts "#{__method__} returning}")
|
6747
|
+
rv
|
6032
6748
|
end
|
6749
|
+
|
6750
|
+
|
6033
6751
|
end
|
6034
6752
|
|
6035
6753
|
|
6754
|
+
=begin
|
6755
|
+
the purpose of this class is just to be able
|
6756
|
+
to have all the functions of RubymentModule
|
6757
|
+
available in a single object.
|
6758
|
+
=end
|
6759
|
+
class Rubyment
|
6760
|
+
include RubymentDevelopmentModule # must NOT be in master TODO
|
6761
|
+
include RubymentModule
|
6762
|
+
end
|
6763
|
+
|
6036
6764
|
(__FILE__ == $0) && Rubyment.new({:invoke => ARGV})
|
6037
6765
|
|