cutter 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +52 -1
- data/lib/cutter.rb +1 -1
- data/lib/cutter/{inspector.rb → inspection.rb} +17 -1
- data/lib/cutter/stamper.rb +1 -1
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -1,6 +1,57 @@
|
|
1
1
|
= cutter
|
2
2
|
|
3
|
-
|
3
|
+
For now it is two-methods-gem, I use a lot for simple debugging & performance measuring purposes.
|
4
|
+
|
5
|
+
Include it into Gemfile:
|
6
|
+
gem 'cutter'
|
7
|
+
|
8
|
+
Methods are:
|
9
|
+
|
10
|
+
I) As inspect! method to any of your methods:
|
11
|
+
def your_method *args
|
12
|
+
inspect!(local_variables,binding) # this string exactly!
|
13
|
+
...
|
14
|
+
end
|
15
|
+
|
16
|
+
your_method(1,"foo",:bar) =>
|
17
|
+
method `your_method'
|
18
|
+
variables:
|
19
|
+
args: [1, "foo", :bar]
|
20
|
+
|
21
|
+
|
22
|
+
Gives simple but nice trace for inspection: method's name, local_variables(they include args passed to method)
|
23
|
+
|
24
|
+
If you want all #inspect! methods fall silent at once, use
|
25
|
+
Cutter::Inspection.quiet!
|
26
|
+
|
27
|
+
II)
|
28
|
+
def your_method
|
29
|
+
stamper("testing pieces of code") do
|
30
|
+
piece_of_code #1
|
31
|
+
stamp("piece #1 performed!")
|
32
|
+
piece_of_code #2
|
33
|
+
stamp("piece #2 performed!")
|
34
|
+
pirce_of_code #3
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
your_method =>
|
39
|
+
~ testing pieces of code
|
40
|
+
~ testing: start
|
41
|
+
~ testing: piece #1 performed!, 10ms
|
42
|
+
~ testing: piece #2 performed!, 231ms
|
43
|
+
~ testing: end (247ms)
|
44
|
+
|
45
|
+
|
46
|
+
or simply:
|
47
|
+
def test_method
|
48
|
+
stamper {
|
49
|
+
piece of code
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
Acts as self.benchmark{} or Benchmark.measure{} but with stamps in any position in block executed, and it is much simpler
|
54
|
+
to write it quickly than all these Measure-dos.
|
4
55
|
|
5
56
|
== Contributing to cutter
|
6
57
|
|
data/lib/cutter.rb
CHANGED
@@ -1,9 +1,25 @@
|
|
1
|
-
|
1
|
+
module Cutter
|
2
|
+
class Inspection
|
3
|
+
attr_accessor :quiet
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def quiet!
|
7
|
+
@quiet = true
|
8
|
+
end
|
2
9
|
|
10
|
+
def quiet?
|
11
|
+
@quiet
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Object
|
3
18
|
# For now inspect! method only may be used with two arguments (local_variables, binding)
|
4
19
|
# Binding is a Ruby class: http://www.ruby-doc.org/core/classes/Binding.html
|
5
20
|
|
6
21
|
def inspect! _local_variables, _binding
|
22
|
+
return true if Cutter::Inspection.quiet?
|
7
23
|
puts "method: `#{caller[0][/`([^']*)'/,1]}'"
|
8
24
|
puts %{ variables:}
|
9
25
|
_local_variables.map do |lv|
|
data/lib/cutter/stamper.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: cutter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- stanislaw
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-06-
|
13
|
+
date: 2011-06-22 00:00:00 +03:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -90,7 +90,7 @@ extra_rdoc_files:
|
|
90
90
|
- README.rdoc
|
91
91
|
files:
|
92
92
|
- lib/cutter.rb
|
93
|
-
- lib/cutter/
|
93
|
+
- lib/cutter/inspection.rb
|
94
94
|
- lib/cutter/railtie.rb
|
95
95
|
- lib/cutter/stamper.rb
|
96
96
|
- LICENSE.txt
|
@@ -109,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
109
109
|
requirements:
|
110
110
|
- - ">="
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
hash:
|
112
|
+
hash: 301476861
|
113
113
|
segments:
|
114
114
|
- 0
|
115
115
|
version: "0"
|