cutter 0.8.4 → 0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +19 -18
- data/lib/cutter/stamper.rb +1 -3
- data/lib/cutter/version.rb +1 -1
- metadata +2 -18
data/README.md
CHANGED
@@ -16,8 +16,9 @@ Insert #inspect! method into any of your methods:
|
|
16
16
|
|
17
17
|
```ruby
|
18
18
|
def your_method *your_args
|
19
|
+
# ...
|
19
20
|
inspect! {} # curly braces are important!
|
20
|
-
...
|
21
|
+
# ...
|
21
22
|
end
|
22
23
|
|
23
24
|
# your_method(1,"foo",:bar) =>
|
@@ -32,13 +33,13 @@ It gives simple but nice trace for inspection: method's name and args that were
|
|
32
33
|
With ```inspect!(:instance){}``` we also see instance variables:
|
33
34
|
|
34
35
|
```ruby
|
35
|
-
def
|
36
|
+
def your_method a, b
|
36
37
|
@instance_var = "blip!"
|
37
38
|
inspect!(:instance){}
|
38
39
|
end
|
39
40
|
|
40
|
-
#
|
41
|
-
# method: `
|
41
|
+
# your_method 1, 2
|
42
|
+
# method: `your_method'
|
42
43
|
# called from class: RSpec::Core::ExampleGroup::Nested_1::Nested_1
|
43
44
|
# local_variables:
|
44
45
|
# a: 1
|
@@ -50,14 +51,14 @@ With ```inspect!(:instance){}``` we also see instance variables:
|
|
50
51
|
With ```inspect!(:self){}``` we have self#inspect of class to which method belongs to:
|
51
52
|
|
52
53
|
```ruby
|
53
|
-
def
|
54
|
+
def your_method name, *args
|
54
55
|
# ...
|
55
56
|
inspect!(:self) {}
|
56
57
|
end
|
57
58
|
|
58
|
-
#
|
59
|
+
# your_method(1,2,3,4,5) =>
|
59
60
|
|
60
|
-
# method: `
|
61
|
+
# method: `your_method'
|
61
62
|
# called from class: SelfInspectDemo
|
62
63
|
# variables:
|
63
64
|
# name: 1
|
@@ -70,21 +71,21 @@ With ```inspect!(:self){}``` we have self#inspect of class to which method belon
|
|
70
71
|
Option :caller gives us caller methods chain:
|
71
72
|
|
72
73
|
```ruby
|
73
|
-
def
|
74
|
+
def your_method name, *args
|
74
75
|
# ...
|
75
76
|
inspect!(:caller)
|
76
77
|
end
|
77
78
|
|
78
|
-
#
|
79
|
+
# your_method(1,2,3,4,5) =>
|
79
80
|
|
80
|
-
# method: `
|
81
|
+
# method: `your_method'
|
81
82
|
# called from class: RSpec::Core::ExampleGroup::Nested_1::Nested_1
|
82
83
|
# variables:
|
83
84
|
# name: 1
|
84
85
|
# args: [2, 3, 4, 5]
|
85
86
|
# block:
|
86
87
|
# caller methods:
|
87
|
-
# /home/stanislaw/_work_/gems/cutter/spec/inspection/demo_spec.rb:33:in `
|
88
|
+
# /home/stanislaw/_work_/gems/cutter/spec/inspection/demo_spec.rb:33:in `your_method'
|
88
89
|
# /home/stanislaw/_work_/gems/cutter/spec/inspection/demo_spec.rb:40:in `block (3 levels) in <top (required)>'
|
89
90
|
# /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
|
```
|
@@ -94,13 +95,13 @@ And finally ```inspect!(:max){}``` produces maximum information: options
|
|
94
95
|
is called on every variable.
|
95
96
|
|
96
97
|
```ruby
|
97
|
-
def
|
98
|
+
def your_method *args
|
98
99
|
inspect!(:max){}
|
99
100
|
end
|
100
101
|
|
101
102
|
# maximal(1, :two, "three", :four => 5) =>
|
102
103
|
#
|
103
|
-
# method: `
|
104
|
+
# method: `your_method' (maximal tracing)
|
104
105
|
# called from class: RSpec::Core::ExampleGroup::Nested_1::Nested_1
|
105
106
|
# local_variables:
|
106
107
|
# args: [1, :two, "three", {:four=>5}]
|
@@ -142,14 +143,14 @@ Very! Very simple!
|
|
142
143
|
|
143
144
|
## II) #stamper
|
144
145
|
|
145
|
-
|
146
|
-
|
147
|
-
```
|
146
|
+
Acts as benchmark{} in Rails or Benchmark.measure{} (common Ruby) but with stamps in any position in block executed.
|
147
|
+
It is much simpler to write it quickly than all these Measure-dos.
|
148
148
|
|
149
149
|
Description is coming...
|
150
150
|
|
151
|
-
|
152
|
-
|
151
|
+
```ruby
|
152
|
+
bundle exec rspec spec/stamper/demo_spec.rb
|
153
|
+
```
|
153
154
|
|
154
155
|
## Contributors
|
155
156
|
|
data/lib/cutter/stamper.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'active_support/core_ext/string/inflections.rb'
|
2
|
-
|
3
1
|
class Object
|
4
2
|
def time_now
|
5
3
|
Time.now.strftime("%s%L").to_i
|
@@ -104,7 +102,7 @@ module Cutter
|
|
104
102
|
|
105
103
|
def stamp lbl = nil
|
106
104
|
return if Stamper.off?
|
107
|
-
message = messages[lbl] || lbl.to_s
|
105
|
+
message = messages[lbl] || lbl.to_s
|
108
106
|
time_passed = time_now - time_initial
|
109
107
|
print " " * nindent
|
110
108
|
printf("stamp: %7d ms #{message}\n", time_passed)
|
data/lib/cutter/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cutter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,22 +11,6 @@ bindir: bin
|
|
11
11
|
cert_chain: []
|
12
12
|
date: 2012-05-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: activesupport
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 2.3.5
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 2.3.5
|
30
14
|
- !ruby/object:Gem::Dependency
|
31
15
|
name: colorize
|
32
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -105,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
89
|
version: '0'
|
106
90
|
segments:
|
107
91
|
- 0
|
108
|
-
hash:
|
92
|
+
hash: -914412113
|
109
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
94
|
none: false
|
111
95
|
requirements:
|