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 CHANGED
@@ -1,6 +1,57 @@
1
1
  = cutter
2
2
 
3
- Description goes here.
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,3 +1,3 @@
1
1
  require 'cutter/railtie' if defined?(Rails)
2
- require 'cutter/inspector'
2
+ require 'cutter/inspection'
3
3
  require 'cutter/stamper'
@@ -1,9 +1,25 @@
1
- class Object
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|
@@ -8,7 +8,7 @@ class Object
8
8
  time_passed = time_now - @time_initial
9
9
  puts("~ testing: #{message}, #{time_passed}ms")
10
10
  end
11
- puts(" #{message}")
11
+ puts("~ #{message}")
12
12
  puts("~ testing: start")
13
13
  @time_initial = time_now
14
14
  yield
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cutter
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
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-09 00:00:00 +03:00
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/inspector.rb
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: -962111089
112
+ hash: 301476861
113
113
  segments:
114
114
  - 0
115
115
  version: "0"