cutter 0.8.2 → 0.8.3

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.
File without changes
@@ -0,0 +1,157 @@
1
+ # Cutter
2
+
3
+ Two-methods-gem I use a lot for simple debugging & performance measuring purposes.
4
+
5
+ Include it into Gemfile:
6
+
7
+ ```ruby
8
+ group :development, :test do
9
+ gem 'cutter'
10
+ end
11
+ ```
12
+
13
+ ## I) #inspect! (or #iii - it is an alias)
14
+
15
+ Insert #inspect! method into any of your methods:
16
+
17
+ ```ruby
18
+ def your_method *your_args
19
+ inspect! {} # curly braces are important!
20
+ ...
21
+ end
22
+
23
+ # your_method(1,"foo",:bar) =>
24
+
25
+ # method `your_method'
26
+ # variables:
27
+ # your_args: [1, "foo", :bar]
28
+ ```
29
+
30
+ It gives simple but nice trace for inspection: method's name and args that were passed to method.
31
+
32
+ With ```inspect!(:instance){}``` we also see instance variables:
33
+
34
+ ```ruby
35
+ def instance_demo a, b
36
+ @instance_var = "blip!"
37
+ inspect!(:instance){}
38
+ end
39
+
40
+ # instance_demo 1, 2
41
+ # method: `instance_demo'
42
+ # called from class: RSpec::Core::ExampleGroup::Nested_1::Nested_1
43
+ # local_variables:
44
+ # a: 1
45
+ # b: 2
46
+ # instance_variables:
47
+ # @instance_var: blip!
48
+ ```
49
+
50
+ With ```inspect!(:self){}``` we have self#inspect of class to which method belongs to:
51
+
52
+ ```ruby
53
+ def method_self_inspect name, *args
54
+ # ...
55
+ inspect!(:self) {}
56
+ end
57
+
58
+ # method_self_inspect(1,2,3,4,5) =>
59
+
60
+ # method: `method_self_inspect'
61
+ # called from class: SelfInspectDemo
62
+ # variables:
63
+ # name: 1
64
+ # args: [2, 3, 4, 5]
65
+ # block:
66
+ # self inspection:
67
+ # #<SelfInspectDemo:0x82be488 @variable="I'm variable">
68
+ ```
69
+
70
+ Option :caller gives us caller methods chain:
71
+
72
+ ```ruby
73
+ def method_caller_chain name, *args
74
+ # ...
75
+ inspect!(:caller)
76
+ end
77
+
78
+ # method_caller_chain(1,2,3,4,5) =>
79
+
80
+ # method: `method_caller_chain'
81
+ # called from class: RSpec::Core::ExampleGroup::Nested_1::Nested_1
82
+ # variables:
83
+ # name: 1
84
+ # args: [2, 3, 4, 5]
85
+ # block:
86
+ # caller methods:
87
+ # /home/stanislaw/_work_/gems/cutter/spec/inspection/demo_spec.rb:33:in `method_caller_chain'
88
+ # /home/stanislaw/_work_/gems/cutter/spec/inspection/demo_spec.rb:40:in `block (3 levels) in <top (required)>'
89
+ # /home/stanislaw/.rvm/gems/ruby-1.9.2-p180@310/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:48:in `instance_eval'
90
+ ```
91
+
92
+ And finally ```inspect!(:max){}``` produces maximum information: options
93
+ :instance, :self, :caller are included + Ruby's ordinary #inspect method
94
+ is called on every variable.
95
+
96
+ ```ruby
97
+ def maximal
98
+ inspect!(:max){}
99
+ end
100
+
101
+ # maximal(1, :two, "three", :four => 5) =>
102
+ #
103
+ # method: `maximal' (maximal tracing)
104
+ # called from class: RSpec::Core::ExampleGroup::Nested_1::Nested_1
105
+ # local_variables:
106
+ # args: [1, :two, "three", {:four=>5}]
107
+ # instance_variables:
108
+ # @example: #<RSpec::Core::Example:0xa1d378 >
109
+ # ...
110
+ # self inspection:
111
+ # #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x9e5f8f4
112
+ # ...
113
+ # caller methods:
114
+ # /home/stanislaw/work/gems/cutter/spec/inspection/demo_spec.rb:28:in `maximal'
115
+ # /home/stanislaw/work/gems/cutter/spec/inspection/demo_spec.rb:54:in `block (3 levels) in <top (required)>'
116
+ # ...
117
+ ```
118
+
119
+ If you want all #inspect! methods fall silent at once, use
120
+
121
+ ```ruby
122
+ Cutter::Inspection.quiet!
123
+ ```
124
+
125
+ To make them sound again do
126
+
127
+ ```ruby
128
+ Cutter::Inspection.loud!
129
+ ```
130
+
131
+ You can clone it and try
132
+
133
+ ```ruby
134
+ bundle exec rspec spec/inspection/demo_spec.rb
135
+ ```
136
+
137
+ Very! Very simple!
138
+
139
+ ### Notes
140
+ 1. Instead of #inspect! you can use #iii - just an alias more convenient for typing.
141
+ 2. #inspect! colorizes its output. If somebody suggests even better color scheme, I will be thankful.
142
+
143
+ ## II) #stamper
144
+
145
+ Description is coming...
146
+
147
+ Acts as self.benchmark{} (in Rails) or Benchmark.measure{} (common Ruby) but with stamps in any position in block executed.
148
+ It is much simpler to write it quickly than all these Measure-dos.
149
+
150
+ ## Contributors
151
+
152
+ * Stanislaw Pankevich
153
+ * Kristian Mandrup
154
+
155
+ ## Copyright
156
+
157
+ Copyright (c) 2011 Stanislaw Pankevich
@@ -1,3 +1,5 @@
1
+ require 'cutter/version'
2
+
1
3
  require 'cutter/array'
2
4
  require 'cutter/railtie' if defined?(Rails)
3
5
 
File without changes
@@ -29,28 +29,30 @@ module Cutter
29
29
  end
30
30
 
31
31
  def colors_config
32
- @colors ||= {:line => :blue,
33
- :time => :light_blue,
32
+ @colors ||= {
33
+ :line => :blue,
34
+ :time => :light_blue,
34
35
 
35
- :message_name => :cyan,
36
- :message_line => :cyan,
37
- :total_line => :yellow,
38
- :total_count => :yellow
39
- # Colors for #inspect!
40
- #:called_from => :light_magenta,
41
- #:class_name => :red,
42
- #:method => :blue,
43
- #:method_name => :green,
44
- #:lv => :blue,
45
- #:lv_names => :magenta,
46
- #:lv_values => :light_red,
47
- #:iv => :cyan,
48
- #:iv_names => :light_cyan,
49
- #:iv_values => :light_blue,
50
- #:self_inspection => :red,
51
- #:self_inspection_trace => :blue,
52
- #:caller_methods => :light_cyan,
53
- #:caller_method => :green
36
+ :message_name => :cyan,
37
+ :message_line => :cyan,
38
+ :total_line => :yellow,
39
+ :total_count => :yellow,
40
+
41
+ # Colors for #inspect!
42
+ # :called_from => :light_magenta,
43
+ :class_name => :light_green,
44
+ :method => :red,
45
+ :method_name => :yellow,
46
+ # :lv => :blue,
47
+ # :lv_names => :magenta,
48
+ # :lv_values => :light_red,
49
+ # :iv => :cyan,
50
+ :iv_names => :cyan,
51
+ :iv_values => :light_blue,
52
+ :self_inspection => :red,
53
+ :self_inspection_trace => :blue,
54
+ :caller_methods => :red,
55
+ :caller_method => :green
54
56
  }
55
57
  end
56
58
  end
@@ -29,92 +29,102 @@ class Object
29
29
  raise ArgumentError, "Try inspect(binding) or inspect! {}", caller if (!block_given? && !_binding)
30
30
  _binding ||= block.binding
31
31
 
32
- options = options.extract_options!
33
-
34
- max = options[:max]
35
- options.maximize_options! if max
36
-
37
- # Want caller methods chain to be traced? - pass option :level to inspect!
38
- level = options[:level]
39
- _caller = caller
32
+ max = true if options.include? :max
33
+ options << :instance << :max << :self << :caller if max
34
+ options.uniq!
35
+
36
+ iv = true if options.include? :instance
37
+
38
+ # Want caller methods chain to be traced? - pass option :caller to #inspect!
39
+ _caller = true if options.include? :caller
40
40
 
41
- self_inspection = eval('self.inspect', _binding) if options[:inspect]
41
+ self_inspection = eval('self.inspect', _binding) if options.include? :self
42
42
 
43
43
  # Basic info
44
44
  method_name = eval('__method__', _binding)
45
45
  class_name = eval('self.class', _binding)
46
46
 
47
- puts "\n%s `%s' %s" % ['method:'.__cs(:method), method_name.__cs(:method_name), ('(maximal tracing)' if max)]
48
- puts " %s %s" % ['called from class:'.__cs(:called_from), class_name.__cs(:class_name)]
47
+ puts "\n%s `%s' %s" % ['method:'.to_colorized_string(:method), method_name.to_colorized_string(:method_name), ('(maximal tracing)' if max)]
48
+ puts " %s %s" % ['called from class:'.to_colorized_string(:called_from), class_name.to_colorized_string(:class_name)]
49
49
 
50
50
  # Local Variables
51
51
  lvb = eval('local_variables',_binding)
52
- puts " %s %s" % ['local_variables:'.__cs(:lv), ("[]" if lvb.empty?)]
52
+ puts " %s %s" % ['local_variables:'.to_colorized_string(:lv), ("[]" if lvb.empty?)]
53
53
 
54
54
  lvb.map do |lv|
55
55
  local_variable = eval(lv.to_s, _binding)
56
- local_variable = (max ? local_variable.inspect : local_variable.__rs)
56
+ local_variable = (max ? local_variable.inspect : local_variable.to_real_string)
57
57
 
58
- puts " %s: %s" % [lv.__cs(:lv_names), local_variable.__cs(:lv_values)]
58
+ puts " %s: %s" % [lv.to_colorized_string(:lv_names), local_variable.to_colorized_string(:lv_values)]
59
59
  end if lvb
60
60
 
61
61
  # Instance Variables
62
- ivb = eval('instance_variables',_binding)
63
-
64
- puts " %s %s" % ["instance_variables:".__cs(:iv), ("[]" if ivb.empty?)]
65
-
66
- ivb.map do |iv|
67
- instance_variable = eval(iv.to_s, _binding)
68
- instance_variable = (max ? instance_variable.inspect : instance_variable.__rs)
69
-
70
- puts " %s: %s" % [iv.__cs(:iv_names), instance_variable.__cs(:iv_values)]
71
- end if ivb
62
+ begin
63
+ ivb = eval('instance_variables',_binding)
64
+
65
+ puts " %s %s" % ["instance_variables:".to_colorized_string(:iv), ("[]" if ivb.empty?)]
66
+
67
+ ivb.map do |iv|
68
+ instance_variable = eval(iv.to_s, _binding)
69
+ instance_variable = (max ? instance_variable.inspect : instance_variable.to_real_string)
70
+
71
+ puts " %s: %s" % [iv.to_colorized_string(:iv_names), instance_variable.to_colorized_string(:iv_values)]
72
+ end if ivb
73
+ end if iv
72
74
 
73
75
  # Self inspection
74
76
  begin
75
- puts " self inspection:".__cs(:self_inspection)
76
- puts " %s" % self_inspection.__cs(:self_inspection_trace)
77
+ puts " self inspection:".to_colorized_string(:self_inspection)
78
+ puts " %s" % self_inspection.to_colorized_string(:self_inspection_trace)
77
79
  end if self_inspection
78
80
 
79
81
  # Caller methods chain
80
82
  begin
81
- puts " caller methods: ".__cs(:caller_methods)
82
- 0.upto(level).each {|index|
83
- puts " %s" % _caller[index].__cs(:caller_method)
84
- }
85
- end if level
83
+ puts " caller methods: ".to_colorized_string(:caller_methods)
84
+ caller.each do |meth|
85
+ puts " %s" % meth.to_colorized_string(:caller_method)
86
+ end
87
+ end if _caller
86
88
 
87
89
  puts "\n"
90
+
88
91
  # Yield mysterious things if they exist in block.
89
- yield if block_given?
92
+ yield if block_given?
90
93
  end
91
94
 
92
- protected
95
+ alias :iii :inspect!
93
96
 
94
- def caller_method_name(level = 1)
95
- caller[level][/`([^']*)'/,1].to_sym
96
- end
97
-
98
- def maximize_options!
99
- self.merge!({:max => true, :inspect => true, :level => 2})
100
- end
97
+ protected
101
98
 
102
- # ("real string") Now used to print Symbols with colons
103
- def __rs
99
+ # "Real string". It is now used to print Symbols with colons
100
+ def to_real_string
104
101
  return ":#{self.to_s}" if self.class == Symbol
105
- self
102
+ to_s
106
103
  end
107
104
 
108
- def __cs obj
109
- color = __colors[obj] || :default
105
+ def to_colorized_string obj
106
+ colors = Cutter::ColoredOutputs.colors_config
107
+ color = colors[obj] || :default
110
108
  color != :default ? to_s.send(color) : to_s
111
109
  end
110
+ end
112
111
 
113
- private
112
+ class Object
113
+ def rrr object = nil
114
+ raise object.inspect
115
+ end
114
116
 
115
- def __colors
116
- Cutter::ColoredOutputs.colors_config
117
+ def ppp object = nil
118
+ puts object.inspect
117
119
  end
118
120
 
121
+ def lll object = nil
122
+ Rails.logger.info object.inspect
123
+ end if defined? Rails
119
124
  end
120
125
 
126
+ # def caller_method_name(level = 1)
127
+ # caller[level][/`([^']*)'/,1].to_sym
128
+ # end
129
+
130
+
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ module Cutter
2
+ VERSION="0.8.3"
3
+ end
metadata CHANGED
@@ -1,121 +1,123 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cutter
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.3
4
5
  prerelease:
5
- version: 0.8.2
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - stanislaw
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-08-09 00:00:00 +03:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2012-05-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: activesupport
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
23
21
  version: 2.3.5
24
22
  type: :runtime
25
23
  prerelease: false
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.3.5
30
+ - !ruby/object:Gem::Dependency
28
31
  name: colorize
29
- requirement: &id002 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
30
33
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0.5"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0.5'
35
38
  type: :runtime
36
39
  prerelease: false
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0.5'
46
+ - !ruby/object:Gem::Dependency
39
47
  name: bundler
40
- requirement: &id003 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
41
49
  none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 1.0.0
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
46
54
  type: :development
47
55
  prerelease: false
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
50
63
  name: jeweler
51
- requirement: &id004 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
52
65
  none: false
53
- requirements:
54
- - - ~>
55
- - !ruby/object:Gem::Version
56
- version: 1.6.2
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
57
70
  type: :development
58
71
  prerelease: false
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: rcov
62
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
63
73
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: "0"
68
- type: :development
69
- prerelease: false
70
- version_requirements: *id005
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
71
78
  description: longer description of your gem
72
79
  email: s.pankevich@gmail.com
73
80
  executables: []
74
-
75
81
  extensions: []
76
-
77
- extra_rdoc_files:
82
+ extra_rdoc_files:
78
83
  - LICENSE.txt
79
- - README.textile
80
- files:
84
+ - README.md
85
+ files:
81
86
  - lib/cutter.rb
82
87
  - lib/cutter/array.rb
83
88
  - lib/cutter/colored_outputs.rb
84
89
  - lib/cutter/inspection.rb
85
90
  - lib/cutter/railtie.rb
86
91
  - lib/cutter/stamper.rb
92
+ - lib/cutter/version.rb
87
93
  - LICENSE.txt
88
- - README.textile
89
- has_rdoc: true
94
+ - README.md
90
95
  homepage: http://github.com/stanislaw/cutter
91
- licenses:
96
+ licenses:
92
97
  - MIT
93
98
  post_install_message:
94
99
  rdoc_options: []
95
-
96
- require_paths:
100
+ require_paths:
97
101
  - lib
98
- required_ruby_version: !ruby/object:Gem::Requirement
102
+ required_ruby_version: !ruby/object:Gem::Requirement
99
103
  none: false
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- hash: -202257491
104
- segments:
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ segments:
105
109
  - 0
106
- version: "0"
107
- required_rubygems_version: !ruby/object:Gem::Requirement
110
+ hash: -579611375
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
112
  none: false
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- version: "0"
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
113
117
  requirements: []
114
-
115
118
  rubyforge_project:
116
- rubygems_version: 1.6.2
119
+ rubygems_version: 1.8.19
117
120
  signing_key:
118
121
  specification_version: 3
119
122
  summary: one-line summary of your gem
120
123
  test_files: []
121
-
@@ -1,189 +0,0 @@
1
- h1. Cutter
2
-
3
- Two-methods-gem I use a lot for simple debugging & performance measuring purposes.
4
-
5
- Include it into Gemfile:
6
-
7
- <pre>
8
- <code>
9
- gem 'cutter'
10
- </code>
11
- </pre>
12
-
13
- h2. I) #inspect!
14
-
15
- Insert #inspect! method into any of your methods:
16
-
17
- <pre>
18
- <code>
19
- def your_method *your_args
20
- inspect! {} # this string exactly!
21
- ...
22
- end
23
-
24
- your_method(1,"foo",:bar) =>
25
-
26
- method `your_method'
27
- variables:
28
- args: [1, "foo", :bar]
29
- </code>
30
- </pre>
31
-
32
- or in more rigorous way:
33
-
34
- <pre>
35
- <code>
36
- def your_another_method(first, second, third, &block)
37
- inspect!(binding)
38
- end
39
-
40
- your_another_method(1,"foo",:bar) =>
41
-
42
- method `your_another_method'
43
- variables:
44
- first: 1
45
- second: "foo"
46
- third: :bar
47
- block:
48
- </code>
49
- </pre>
50
-
51
- Gives simple but nice trace for inspection: method's name and args that were passed to method
52
-
53
- With :inspect => true we have self#inspect of class to which method belongs to:
54
-
55
- <pre>
56
- <code>
57
- def method_self_inspect
58
- ...
59
- inspect!(:inspect => true) {}
60
- end
61
-
62
- method_self_inspect(1,2,3,4,5) =>
63
-
64
- method: `method_self_inspect'
65
- called from class: SelfInspectDemo
66
- variables:
67
- name: 1
68
- args: [2, 3, 4, 5]
69
- block:
70
- self inspection:
71
- #<SelfInspectDemo:0x82be488 @variable="I'm variable">
72
- </code>
73
- </pre>
74
-
75
- And finally :level => N gives caller methods chain (N + 1 caller methods):
76
-
77
- <pre>
78
- <code>
79
- def method_caller_chain
80
- ...
81
- inspect!(:level => 2)
82
- end
83
-
84
- method_caller_chain(1,2,3,4,5) =>
85
-
86
- method: `method_caller_chain'
87
- called from class: RSpec::Core::ExampleGroup::Nested_1::Nested_1
88
- variables:
89
- name: 1
90
- args: [2, 3, 4, 5]
91
- block:
92
- caller methods:
93
- /home/stanislaw/_work_/gems/cutter/spec/inspection/demo_spec.rb:33:in `method_caller_chain'
94
- /home/stanislaw/_work_/gems/cutter/spec/inspection/demo_spec.rb:40:in `block (3 levels) in <top (required)>'
95
- /home/stanislaw/.rvm/gems/ruby-1.9.2-p180@310/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:48:in `instance_eval'
96
- </code>
97
- </pre>
98
-
99
- If you want all #inspect! methods fall silent at once, use
100
- @Cutter::Inspection.quiet!@
101
- To make them sound again do
102
- @Cutter::Inspection.loud!@
103
-
104
- You can clone it and try
105
-
106
- @bundle exec rspec spec/inspection/demo_spec.rb@
107
-
108
- Very! Very simple!
109
-
110
- h2. II) #stamper
111
-
112
- <pre>
113
- <code>
114
- Stamper.scope :stan => "testing test_method" do |stan|
115
- stan.msg _1: 'stamp1'
116
- stan.msg _2: 'stamp2'
117
- stan.msg _3: 'stamp3'
118
- end
119
-
120
- Stamper.scope :hello => "testing hello part" do |stan|
121
- stan.msg _1: 'hello stan'
122
- stan.msg _2: 'nice to see you'
123
- end
124
-
125
- v = 32
126
-
127
- stamper :stan do |s|
128
- s.stamp
129
- s.stamp :_1
130
- sleep 0.1
131
- s.stamp :_2
132
- s.stamp :hello_world
133
- stamper :hello do |s|
134
- s.stamp :_1
135
- sleep 0.1
136
- s.stamp :_2
137
- end
138
- sleep 0.1
139
- s.stamp "hello world: #{v}" # access var before block
140
- s.stamp :_3
141
- sleep 0.1
142
- end
143
-
144
- =>
145
-
146
- ------------------------------
147
- ~ START "testing test_method"
148
- ~ stamp: 0 ms
149
- ~ stamp: 0 ms stamp1
150
- ~ stamp: 101 ms stamp2
151
- ~ stamp: 101 ms Hello world
152
- ------------------------------
153
- ~ START "testing hello part"
154
- ~ stamp: 0 ms hello stan
155
- ~ stamp: 101 ms nice to see you
156
- ~ END "testing hello part"
157
- [101ms]
158
- ------------------------------
159
- ~ stamp: 305 ms Hello world: 32
160
- ~ stamp: 305 ms stamp3
161
- ~ END "testing test_method"
162
- [406ms]
163
- ------------------------------
164
- </code>
165
- </pre>
166
-
167
- or simply:
168
- <pre>
169
- <code>
170
- def test_method
171
- stamper {
172
- piece of code
173
- }
174
- end
175
- </code>
176
- </pre>
177
-
178
- Acts as self.benchmark{} (in Rails) or Benchmark.measure{} (common Ruby) but with stamps in any position in block executed.
179
- It is much simpler to write it quickly than all these Measure-dos.
180
-
181
- h2. Contributors
182
-
183
- * Stanislaw Pankevich
184
- * Kristian Mandrup
185
-
186
- h2. Copyright
187
-
188
- Copyright (c) 2011 Stanislaw Pankevich
189
-