testability-driver 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. data/bin/tdriver-devtools +0 -0
  2. data/ext/native_extensions.c +165 -6
  3. data/lib/tdriver-devtools/behaviour/old/xml/update +0 -0
  4. data/lib/tdriver-devtools/behaviour/xml/generate.rb +0 -0
  5. data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +15 -1
  6. data/lib/tdriver-devtools/doc/update +0 -0
  7. data/lib/tdriver-devtools/doc/xslt/template.xsl +24 -14
  8. data/lib/tdriver-devtools/doc/xslt/update +0 -0
  9. data/lib/tdriver-devtools/tdriver-devtools.rb +0 -0
  10. data/lib/tdriver-devtools/tests/feature_tests/update +0 -0
  11. data/lib/tdriver/base/behaviour/{behaviour.rb → abstract.rb} +3 -6
  12. data/lib/tdriver/base/behaviour/behaviours/object_abstract.rb +107 -0
  13. data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +2 -2
  14. data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +47 -37
  15. data/lib/tdriver/base/behaviour/factory.rb +260 -382
  16. data/lib/tdriver/base/behaviour/loader.rb +22 -4
  17. data/lib/tdriver/base/controller/abstraction.rb +56 -0
  18. data/lib/tdriver/base/controller/loader.rb +21 -0
  19. data/lib/tdriver/base/loader.rb +3 -1
  20. data/lib/tdriver/base/sut/controller.rb +91 -74
  21. data/lib/tdriver/base/sut/factory.rb +8 -8
  22. data/lib/tdriver/base/sut/generic/behaviours/agent.rb +77 -0
  23. data/lib/tdriver/base/sut/generic/behaviours/sut.rb +116 -96
  24. data/lib/tdriver/base/sut/generic/commands/agent.rb +43 -0
  25. data/lib/tdriver/base/sut/sut.rb +10 -8
  26. data/lib/tdriver/base/test_object/abstract.rb +25 -24
  27. data/lib/tdriver/base/test_object/adapter.rb +67 -44
  28. data/lib/tdriver/base/test_object/behaviours/test_object.rb +79 -20
  29. data/lib/tdriver/base/test_object/factory.rb +45 -15
  30. data/lib/tdriver/base/test_object/xml/adapter.rb +80 -57
  31. data/lib/tdriver/env.rb +0 -0
  32. data/lib/tdriver/loader.rb +0 -0
  33. data/lib/tdriver/matti.rb +0 -0
  34. data/lib/tdriver/report/error_recovery/tdriver_error_recovery.rb +1 -0
  35. data/lib/tdriver/report/report.rb +2 -1
  36. data/lib/tdriver/report/report_crash_file_capture.rb +12 -0
  37. data/lib/tdriver/report/report_creator.rb +6 -2
  38. data/lib/tdriver/report/report_execution_statistics.rb +27 -11
  39. data/lib/tdriver/report/report_graph_generator.rb +59 -0
  40. data/lib/tdriver/report/report_test_case_run.rb +34 -2
  41. data/lib/tdriver/report/report_writer.rb +12 -0
  42. data/lib/tdriver/tdriver.rb +12 -1
  43. data/lib/tdriver/util/agent/loader.rb +22 -0
  44. data/lib/tdriver/util/agent/service.rb +107 -0
  45. data/lib/tdriver/util/common/crc16.rb +17 -10
  46. data/lib/tdriver/util/common/hash.rb +4 -1
  47. data/lib/tdriver/util/common/kernel.rb +11 -0
  48. data/lib/tdriver/util/common/numeric.rb +48 -0
  49. data/lib/tdriver/util/common/object.rb +5 -2
  50. data/lib/tdriver/util/common/string.rb +8 -1
  51. data/lib/tdriver/util/filters/attribute_filter.rb +121 -0
  52. data/lib/tdriver/util/filters/loader.rb +29 -0
  53. data/lib/tdriver/util/fixture/loader.rb +22 -0
  54. data/lib/tdriver/util/fixture/service.rb +157 -0
  55. data/lib/tdriver/util/loader.rb +8 -2
  56. data/lib/tdriver/util/logger/logger.rb +12 -6
  57. data/lib/tdriver/util/other/config.rb +0 -0
  58. data/lib/tdriver/util/parameter/parameter.rb +221 -152
  59. data/lib/tdriver/util/plugin/error.rb +0 -0
  60. data/lib/tdriver/util/video/camera_linux.rb +36 -22
  61. data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +3 -13
  62. data/lib/tdriver/util/xml/parsers/nokogiri/node.rb +13 -8
  63. data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +51 -9
  64. data/lib/tdriver/util/xml/xml.rb +4 -2
  65. data/lib/tdriver/verify/verify.rb +280 -621
  66. data/lib/tdriver/version.rb +1 -1
  67. data/xml/behaviours/generic.xml +34 -0
  68. data/xml/templates/generic.xml +20 -3
  69. metadata +168 -240
  70. data/lib/tdriver-devtools/tests/feature_tests/output/application_closable_0x3f.feature +0 -10
  71. data/lib/tdriver-devtools/tests/feature_tests/output/application_close.feature +0 -15
  72. data/lib/tdriver-devtools/tests/feature_tests/output/application_environment.feature +0 -10
  73. data/lib/tdriver-devtools/tests/feature_tests/output/application_executable_name.feature +0 -10
  74. data/lib/tdriver-devtools/tests/feature_tests/output/application_uid.feature +0 -10
  75. data/lib/tdriver-devtools/tests/feature_tests/output/created.rid +0 -1
  76. data/lib/tdriver-devtools/tests/feature_tests/output/find_find.feature +0 -15
  77. data/lib/tdriver-devtools/tests/feature_tests/output/flash_behaviour_flash.feature +0 -10
  78. data/lib/tdriver-devtools/tests/feature_tests/output/flash_behaviour_flash_images.feature +0 -15
  79. data/lib/tdriver-devtools/tests/feature_tests/output/sut_application.feature +0 -15
  80. data/lib/tdriver-devtools/tests/feature_tests/output/sut_capture_screen.feature +0 -10
  81. data/lib/tdriver-devtools/tests/feature_tests/output/sut_child.feature +0 -10
  82. data/lib/tdriver-devtools/tests/feature_tests/output/sut_clear_verify_blocks.feature +0 -10
  83. data/lib/tdriver-devtools/tests/feature_tests/output/sut_connect.feature +0 -10
  84. data/lib/tdriver-devtools/tests/feature_tests/output/sut_controller_execution_order.feature +0 -10
  85. data/lib/tdriver-devtools/tests/feature_tests/output/sut_controller_execution_order_0x3d.feature +0 -10
  86. data/lib/tdriver-devtools/tests/feature_tests/output/sut_current_application_id.feature +0 -15
  87. data/lib/tdriver-devtools/tests/feature_tests/output/sut_disconnect.feature +0 -10
  88. data/lib/tdriver-devtools/tests/feature_tests/output/sut_dump_count.feature +0 -15
  89. data/lib/tdriver-devtools/tests/feature_tests/output/sut_freeze.feature +0 -10
  90. data/lib/tdriver-devtools/tests/feature_tests/output/sut_frozen.feature +0 -10
  91. data/lib/tdriver-devtools/tests/feature_tests/output/sut_get_application_id.feature +0 -10
  92. data/lib/tdriver-devtools/tests/feature_tests/output/sut_get_object.feature +0 -10
  93. data/lib/tdriver-devtools/tests/feature_tests/output/sut_get_operator_data.feature +0 -10
  94. data/lib/tdriver-devtools/tests/feature_tests/output/sut_get_ui_dump.feature +0 -15
  95. data/lib/tdriver-devtools/tests/feature_tests/output/sut_get_user_information.feature +0 -10
  96. data/lib/tdriver-devtools/tests/feature_tests/output/sut_input.feature +0 -15
  97. data/lib/tdriver-devtools/tests/feature_tests/output/sut_parameter.feature +0 -15
  98. data/lib/tdriver-devtools/tests/feature_tests/output/sut_press_key.feature +0 -10
  99. data/lib/tdriver-devtools/tests/feature_tests/output/sut_received_data.feature +0 -10
  100. data/lib/tdriver-devtools/tests/feature_tests/output/sut_refresh.feature +0 -20
  101. data/lib/tdriver-devtools/tests/feature_tests/output/sut_refresh_timeout.feature +0 -15
  102. data/lib/tdriver-devtools/tests/feature_tests/output/sut_refresh_tries.feature +0 -15
  103. data/lib/tdriver-devtools/tests/feature_tests/output/sut_refresh_ui_dump.feature +0 -20
  104. data/lib/tdriver-devtools/tests/feature_tests/output/sut_run.feature +0 -10
  105. data/lib/tdriver-devtools/tests/feature_tests/output/sut_sent_data.feature +0 -10
  106. data/lib/tdriver-devtools/tests/feature_tests/output/sut_state.feature +0 -10
  107. data/lib/tdriver-devtools/tests/feature_tests/output/sut_translate.feature +0 -30
  108. data/lib/tdriver-devtools/tests/feature_tests/output/sut_ui_type.feature +0 -10
  109. data/lib/tdriver-devtools/tests/feature_tests/output/sut_ui_version.feature +0 -10
  110. data/lib/tdriver-devtools/tests/feature_tests/output/sut_unfreeze.feature +0 -10
  111. data/lib/tdriver-devtools/tests/feature_tests/output/sut_update.feature +0 -10
  112. data/lib/tdriver-devtools/tests/feature_tests/output/sut_verify_always.feature +0 -20
  113. data/lib/tdriver-devtools/tests/feature_tests/output/sut_verify_blocks.feature +0 -10
  114. data/lib/tdriver-devtools/tests/feature_tests/output/sut_x_path.feature +0 -10
  115. data/lib/tdriver-devtools/tests/feature_tests/output/sut_xml_data.feature +0 -10
  116. data/lib/tdriver-devtools/tests/feature_tests/output/sut_xml_data_0x3d.feature +0 -10
  117. data/lib/tdriver-devtools/tests/feature_tests/output/sut_xml_data_crc.feature +0 -10
  118. data/lib/tdriver-devtools/tests/feature_tests/output/switchbox_behaviour_power_down.feature +0 -10
  119. data/lib/tdriver-devtools/tests/feature_tests/output/switchbox_behaviour_power_status.feature +0 -10
  120. data/lib/tdriver-devtools/tests/feature_tests/output/switchbox_behaviour_power_up.feature +0 -10
  121. data/lib/tdriver-devtools/tests/feature_tests/output/switchbox_behaviour_reset.feature +0 -10
  122. data/lib/tdriver-devtools/tests/feature_tests/output/verification_test_object_exists_0x3f.feature +0 -15
  123. data/lib/tdriver/base/behaviour/factory_new.rb +0 -409
  124. data/lib/tdriver/base/test_object/identificator.rb +0 -518
  125. data/lib/tdriver/util/filters/dynamic_attributes.rb +0 -189
@@ -0,0 +1,59 @@
1
+ ############################################################################
2
+ ##
3
+ ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
+ ## All rights reserved.
5
+ ## Contact: Nokia Corporation (testabilitydriver@nokia.com)
6
+ ##
7
+ ## This file is part of Testability Driver.
8
+ ##
9
+ ## If you have questions regarding the use of this file, please contact
10
+ ## Nokia at testabilitydriver@nokia.com .
11
+ ##
12
+ ## This library is free software; you can redistribute it and/or
13
+ ## modify it under the terms of the GNU Lesser General Public
14
+ ## License version 2.1 as published by the Free Software Foundation
15
+ ## and appearing in the file LICENSE.LGPL included in the packaging
16
+ ## of this file.
17
+ ##
18
+ ############################################################################
19
+
20
+ class ReportGraphGenerator
21
+ def initialize(columns,data)
22
+ @columns=columns
23
+ @data=data
24
+ end
25
+
26
+ def generate_graph(file_name)
27
+
28
+ begin
29
+ require 'gruff'
30
+ rescue LoadError
31
+ $stderr.puts "Can't load the Gruff gem. If its missing from your system please run 'gem install gruff' to install it."
32
+ end
33
+
34
+ begin
35
+ g = Gruff::Line.new()
36
+
37
+ data_rows = Hash.new #Create hash for data
38
+ @columns.each do |title|
39
+ data_rows[title] = Array.new #Create array for data
40
+ end
41
+
42
+ @data.each do |value|
43
+ value.each_key do |key|
44
+ data_rows[key].push(value[key].to_f) #Put values in the row data
45
+ end
46
+ end
47
+
48
+ data_rows.each_key do |key|
49
+ g.data(key, data_rows[key])
50
+ end
51
+
52
+ g.write(file_name)
53
+
54
+ rescue Exception => e
55
+ puts "Graph creation failed #{e.message} from data: "
56
+ p data_rows
57
+ end
58
+ end
59
+ end
@@ -324,7 +324,31 @@ module TDriverReportCreator
324
324
  def set_test_case_behaviour_log(value,test_case)
325
325
  @test_case_behaviour_log << [value.to_s,test_case]
326
326
  end
327
- #Thid methods sets video recording of the test case
327
+
328
+ #This methods checks the available video devices
329
+ #
330
+ # === params
331
+ #
332
+ # === returns
333
+ # nil
334
+ def each_video_device
335
+
336
+ if $parameters[:report_video, nil] != nil
337
+
338
+ device_index = 0
339
+ $parameters[:report_video].split("|").each do | video_device |
340
+ if !video_device.strip.empty?
341
+ yield video_device.strip, device_index.to_s
342
+ device_index += 1
343
+ end
344
+ end
345
+
346
+ end
347
+
348
+ end
349
+
350
+
351
+ #This methods sets video recording of the test case
328
352
  #
329
353
  # === params
330
354
  # rec_name: String, name of video file to create
@@ -338,6 +362,7 @@ module TDriverReportCreator
338
362
  tc_video_width = 640
339
363
  tc_video_height = 480
340
364
  tc_video_fps = 30
365
+ tc_max_time = '99:00:00'
341
366
 
342
367
  begin
343
368
  tc_video_width = $parameters[ :report_video_width ].to_i
@@ -354,6 +379,11 @@ module TDriverReportCreator
354
379
  rescue
355
380
  # parameter not loaded, do nothing
356
381
  end
382
+ begin
383
+ tc_max_time = $parameters[ :report_video_max_time ].to_i
384
+ rescue
385
+ # parameter not loaded, do nothing
386
+ end
357
387
 
358
388
 
359
389
  @tc_video_recorders = []
@@ -549,7 +579,9 @@ module TDriverReportCreator
549
579
  begin
550
580
  sut_attributes[:sut].capture_screen( :Filename => dump_folder+'/'+time_stamp+'_'+sut_id.to_s+'_state.png', :Redraw => true ) if sut_attributes[:is_connected]
551
581
  if arguments[:file]
552
- sut_attributes[:sut].capture_screen( :Filename => arguments[:file], :Redraw => true ) if sut_attributes[:is_connected]
582
+ base_name=File.basename(arguments[:file])
583
+ base_folder=File.dirname(arguments[:file])
584
+ sut_attributes[:sut].capture_screen( :Filename => "#{base_folder}/#{sut_id.to_s}_#{base_name}", :Redraw => true ) if sut_attributes[:is_connected]
553
585
  end
554
586
  image_html='<div class="img"><a href="state_xml/'<<
555
587
  time_stamp+'_'+sut_id.to_s+'_state.png'<<
@@ -890,6 +890,7 @@ display: block;
890
890
  format_behaviour_log(@test_case_behaviour_log)<<
891
891
  '</dd>'<<
892
892
  '</dl>'
893
+
893
894
  end
894
895
  if @test_case_user_data!=nil && !@test_case_user_data.empty?
895
896
  html_body=html_body<<
@@ -899,6 +900,17 @@ display: block;
899
900
  format_user_log_table( @test_case_user_data,@test_case_user_data_columns)<<
900
901
  '</dd>'<<
901
902
  '</dl>'
903
+ if $parameters[ :report_generate_duration_graph, false]=='true'
904
+ graph=ReportGraphGenerator.new(@test_case_user_data_columns,@test_case_user_data)
905
+ graph.generate_graph("#{folder}/graph.png")
906
+ html_body=html_body<<
907
+ '<dl class="togList">'<<
908
+ '<dt onclick="tog(this)" style="background-color: #CCCCCC;"><b style="font-size: large"><span><input id="Button1" type="button" value="Close" class="btn" /></span> Graph</b></dt>'<<
909
+ '<dd style="font-size: small">'<<
910
+ '<img border="0" src="graph.png"/>'<<
911
+ '</dd>'<<
912
+ '</dl>'
913
+ end
902
914
  end
903
915
  html_body=html_body<<
904
916
  '</div>'
@@ -86,7 +86,7 @@ module TDriver
86
86
  # ArgumentError:: Not connected to device 'id' if not connected at all / device already disconnected
87
87
  # ArgumentError:: Sut id not given
88
88
  # === example
89
- # @sut = TDriver.reboot_sut(:Id =>'sut_qt') # for Qt, should be connected already
89
+ # @sut = TDriver.reboot_sut(:Id => 'sut_qt') # for Qt, should be connected already
90
90
  def reboot_sut( sut_attributes = {} )
91
91
 
92
92
  MobyBase::SUTFactory.instance.reboot_sut( sut_attributes )
@@ -167,6 +167,14 @@ module TDriver
167
167
  File.expand_path( File.dirname( __FILE__ ) )
168
168
 
169
169
  end
170
+
171
+ # == nodoc
172
+ # TODO: document me
173
+ def version
174
+
175
+ ENV['TDRIVER_VERSION'] || "unknown"
176
+
177
+ end
170
178
 
171
179
  private
172
180
 
@@ -182,6 +190,9 @@ module TDriver
182
190
  # set xml cache buffer size
183
191
  MobyUtil::XML.buffer_size = $parameters[ :xml_cache_buffer_size, 10 ].to_i
184
192
 
193
+ # load behaviours
194
+ TDriver::BehaviourFactory.init( :path => File.join( config_dir, 'behaviours' ) )
195
+
185
196
  # initialization done, everything is ready
186
197
  $TDRIVER_INITIALIZED = true
187
198
 
@@ -0,0 +1,22 @@
1
+ ############################################################################
2
+ ##
3
+ ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
+ ## All rights reserved.
5
+ ## Contact: Nokia Corporation (testabilitydriver@nokia.com)
6
+ ##
7
+ ## This file is part of Testability Driver.
8
+ ##
9
+ ## If you have questions regarding the use of this file, please contact
10
+ ## Nokia at testabilitydriver@nokia.com .
11
+ ##
12
+ ## This library is free software; you can redistribute it and/or
13
+ ## modify it under the terms of the GNU Lesser General Public
14
+ ## License version 2.1 as published by the Free Software Foundation
15
+ ## and appearing in the file LICENSE.LGPL included in the packaging
16
+ ## of this file.
17
+ ##
18
+ ############################################################################
19
+
20
+ # agent command services module
21
+ require File.expand_path( File.join( File.dirname( __FILE__ ), 'service.rb' ) )
22
+
@@ -0,0 +1,107 @@
1
+ ############################################################################
2
+ ##
3
+ ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
+ ## All rights reserved.
5
+ ## Contact: Nokia Corporation (testabilitydriver@nokia.com)
6
+ ##
7
+ ## This file is part of Testability Driver.
8
+ ##
9
+ ## If you have questions regarding the use of this file, please contact
10
+ ## Nokia at testabilitydriver@nokia.com .
11
+ ##
12
+ ## This library is free software; you can redistribute it and/or
13
+ ## modify it under the terms of the GNU Lesser General Public
14
+ ## License version 2.1 as published by the Free Software Foundation
15
+ ## and appearing in the file LICENSE.LGPL included in the packaging
16
+ ## of this file.
17
+ ##
18
+ ############################################################################
19
+
20
+ module TDriver
21
+
22
+ class AgentService
23
+
24
+ =begin
25
+ # remove all public methods
26
+ instance_methods.each{ | method |
27
+ undef_method( method ) unless method =~ /^__|^(methods|inspect|to_s|class|nil?|extend)/
28
+ }
29
+
30
+ # required by commands method to list available services
31
+ private :methods
32
+ =end
33
+
34
+ # TODO: document me
35
+ def initialize( options = {} )
36
+
37
+ # verify that options is type of hash
38
+ options.check_type Hash, 'wrong argument type $1 for AgentCommandService options (expected $2)'
39
+
40
+ # verify that sut is defined in options hash
41
+ options.require_key :sut
42
+
43
+ sut = options[ :sut ]
44
+
45
+ TDriver::BehaviourFactory.apply_behaviour(
46
+ :object => self,
47
+ :object_type => [ 'AgentCommandService' ],
48
+ :env => [ '*', *sut.environment.to_s.split(";") ],
49
+ :input_type => [ '*', *sut.input.to_s.split(";") ],
50
+ :version => [ '*', *sut.ui_version.to_s.split(";") ]
51
+ )
52
+
53
+ # store given options
54
+ @options = options
55
+
56
+ # store sut variable
57
+ @sut = sut
58
+
59
+ # store caller backtrace
60
+ @caller = caller
61
+
62
+ end
63
+
64
+ # TODO: document me
65
+ def commands
66
+
67
+ class << self
68
+
69
+ # retrieve all public methods
70
+ instance_methods( false ).select{ | name | true unless name =~ /^__|^commands$/ }
71
+
72
+ end
73
+
74
+ end
75
+
76
+ private
77
+
78
+ # TODO: document me
79
+ def execute_command( command_data_object )
80
+
81
+ begin
82
+
83
+ # execute command
84
+ @sut.__send__( :execute_command, command_data_object )
85
+
86
+ rescue MobyBase::ControllerNotFoundError
87
+
88
+ # raise exception if sut doesn't have controller for the command data object
89
+ raise NotImplementedError, "Agent command #{ command_data_object.parameters[ :command ].inspect } is not supported on #{ @sut.id.inspect }", @caller
90
+
91
+ end
92
+
93
+ end
94
+
95
+ private
96
+
97
+ # TODO: document me
98
+ def method_missing( id, *args )
99
+
100
+ # raise exception if unknown command or not supported by sut
101
+ raise RuntimeError, "agent command #{ id.inspect } not supported by #{ @options[ :sut ].id }", caller
102
+
103
+ end
104
+
105
+ end # AgentCommandService
106
+
107
+ end # TDriver
@@ -73,20 +73,27 @@ module TDriver
73
73
 
74
74
  public
75
75
 
76
- # CRC-16-CCITT
77
- def crc16( buf, crc = 0 )
76
+ # check if implementation is already loaded from TDriver native Ruby C Extension; native crc routines are ~10% faster
77
+ unless instance_methods.include?( 'native_extension' )
78
+
79
+ # CRC-16-CCITT
80
+ def crc16( buf, crc = 0 )
78
81
 
79
- # calculate the checksum
80
- buf.each_byte{ | x | crc = ( ( crc << 8 ) ^ @CCITT_16[ ( crc >> 8 ) ^ x ] ) & 0xffff }
82
+ # calculate the checksum
83
+ buf.each_byte{ | x | crc = ( ( crc << 8 ) ^ @CCITT_16[ ( crc >> 8 ) ^ x ] ) & 0xffff }
81
84
 
82
- # result
83
- crc
85
+ # result
86
+ crc
84
87
 
85
- end # crc16
88
+ end # crc16
89
+
90
+ # determines that native extension is not in use
91
+ def native_extension
92
+
93
+ false
94
+
95
+ end
86
96
 
87
- # check if implementation is already loaded from TDriver native Ruby C Extension; native crc routines are ~10% faster
88
- unless instance_methods.include?( 'crc16_ibm' )
89
-
90
97
  # IBM-CRC-16: fallback when native extensions are not supported (e.g. jruby)
91
98
  def crc16_ibm( buf, crc = 0xffff )
92
99
 
@@ -66,9 +66,12 @@ class Hash
66
66
  # verify that receiver object contains all of given keys. Raises exception is key not found.
67
67
  def require_key( key, message = 'required key $1 not found from hash' )
68
68
 
69
+ # store caller backtrace before calling fetch
70
+ backtrace = caller
71
+
69
72
  fetch( key ){
70
73
 
71
- raise ArgumentError, message.gsub!( "$1", key.inspect ), caller
74
+ raise ArgumentError, message.gsub( "$1", key.inspect ), backtrace
72
75
 
73
76
  }
74
77
 
@@ -27,6 +27,17 @@ module Kernel
27
27
 
28
28
  end
29
29
 
30
+ # TODO: document me
31
+ def __method_path__
32
+
33
+ # retrieve filename, line number and method name
34
+ /^(.+?):(\d+)(?::in `(.*)')?/.match( caller.reverse[ -2 ].to_s )
35
+
36
+ # construct string with module/class and method name
37
+ "#{ ( [ Class, Module ].include?( self.class ) ? self.name : self.class.name ).to_s }##{ caller.first.to_s.scan(/`(.+)'$/).to_s }"
38
+
39
+ end
40
+
30
41
  # TODO: document me
31
42
  def warn_caller( message, remove_eval = true )
32
43
 
@@ -48,6 +48,54 @@ class Numeric
48
48
 
49
49
  end
50
50
 
51
+ # TODO: document me
52
+ def not_negative( message = 'Given value ($1) must not be negative', exception = ArgumentError )
53
+
54
+ if negative?
55
+
56
+ # replace macros
57
+ message.gsub!( '$1', self.inspect )
58
+
59
+ raise exception, message, caller
60
+
61
+ end
62
+
63
+ self
64
+
65
+ end
66
+
67
+ # TODO: document me
68
+ def not_zero( message = 'Given value must not be zero', exception = ArgumentError )
69
+
70
+ if zero?
71
+
72
+ # replace macros
73
+ message.gsub!( '$1', self.inspect )
74
+
75
+ raise exception, message, caller
76
+
77
+ end
78
+
79
+ self
80
+
81
+ end
82
+
83
+ # TODO: document me
84
+ def not_positive( message = 'Given value ($1) must not be positive', exception = ArgumentError )
85
+
86
+ if positive?
87
+
88
+ # replace macros
89
+ message.gsub!( '$1', self.inspect )
90
+
91
+ raise exception, message, caller
92
+
93
+ end
94
+
95
+ self
96
+
97
+ end
98
+
51
99
  # TODO: document me
52
100
  def check_range( range, message = "value $1 is out of range ($2)" )
53
101
 
@@ -27,26 +27,29 @@ class Object
27
27
 
28
28
  end
29
29
 
30
+ # TODO: document me
30
31
  def true?
31
32
 
32
33
  false
33
34
 
34
35
  end
35
36
 
37
+ # TODO: document me
36
38
  def false?
37
39
 
38
40
  false
39
41
 
40
42
  end
41
43
 
42
- def not_blank( message = "Object must not be blank", exception = ArgumentError )
44
+ # TODO: document me
45
+ def not_blank( message = "object must not be blank", exception = ArgumentError )
43
46
 
44
47
  raise exception, message, caller if blank?
45
48
 
46
49
  self
47
50
 
48
51
  end
49
-
52
+
50
53
  # define method to class instance
51
54
  def meta_def( method_name, &block )
52
55