perforator 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b3622ce3f88d863ac6b0aedf38c796d8d593d611
4
- data.tar.gz: 29086ae16a88db6dc61754cdcd23aebc470df3e3
3
+ metadata.gz: 765608fcc481e88b7621130998a320433e424f61
4
+ data.tar.gz: b4d0060e1a221516f3e4eec1263c5ea1da90d614
5
5
  SHA512:
6
- metadata.gz: 73193d58bb3eb2f024065848063b4ba79251620ea6ca87b5f6c3a9fd8e3e0f565da6586ec2400644d88edb2ac5d5df5c2c0decd9d0eea217ce3fe340f6424819
7
- data.tar.gz: e39fbafccb6373c68c109c0056a065ec6cefdf3abf9429f2902fa780b107010f7937c4b6ed15c98a87ca7abf4eaf286bdd1bd51c5bbc5f4f5e628455a054cb90
6
+ metadata.gz: 52bbcde22a49ac34237cf3cfc401130f15cd1f6b94fda34ce21ece48c1cfde06c34030db01ce40fe5b52289cc5168fde415c632043cde79ddcdc36f7c0c1d4d1
7
+ data.tar.gz: 19460fd73bf0913ef060651f30afe8e32185a5e06432ecabd683baa0b693c96f48a6fff6f384cc820585075d8936fd1fc95c3e8e46cb9a81ea865b285cd4a609
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Build Status](https://travis-ci.org/sveredyuk/perforator.svg?branch=master)](https://travis-ci.org/sveredyuk/perforator)
2
+
1
3
  # Perforator
2
4
 
3
5
  ### Simple and pretty stupid way to measure execution time of your code
@@ -50,6 +52,49 @@ my_meter = Perforator::Meter.new(
50
52
  )
51
53
  ```
52
54
 
55
+
56
+ You can skip any option if you don't need it.
57
+
58
+ But for callbacks :expected_time is necessary:
59
+ ```ruby
60
+ Perforator::Meter.new(positive_callback: -> { puts ':)' }) #=> NoExpectedTimeError
61
+ ```
62
+
63
+ Callbacks must be callable:
64
+ ```ruby
65
+ Perforator::Meter.new(positive_callback: Hash.new) #=> NotCallableCallbackError
66
+
67
+ ```
68
+
69
+ Expeted time must be fixnum:
70
+ ```ruby
71
+ Perforator::Meter.new(expected_time: '10') #=> NotFixnumExpectedTimeError
72
+
73
+ ```
74
+
75
+ Just wrap your code with meter:
76
+ ```ruby
77
+ my_meter.call do
78
+ # put your code here
79
+ end
80
+ ```
81
+
82
+ Any of undefined method for meter will be added to output and log. It helps to add some custom breakpoints:
83
+ ```ruby
84
+ my_meter.call do |meter|
85
+ meter.some_start 'Value'
86
+ # put your code here
87
+ meter.some_finish 'Valud'
88
+ end
89
+
90
+ # =======> your label
91
+ # some_start: Value
92
+ # Start: 2017-06-02 14:24:53 +0300
93
+ # Finish: 2017-06-02 14:24:54 +0300
94
+ # Spent: 1.000919
95
+ # some_finish Value
96
+ ```
97
+
53
98
  ## Development
54
99
 
55
100
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,3 +1,3 @@
1
1
  module Perforator
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
data/lib/perforator.rb CHANGED
@@ -88,8 +88,8 @@ module Perforator
88
88
  end
89
89
 
90
90
  # TODO Add possibility to log method_missing keys
91
- # def method_missing(meth, *args, &blk)
92
- # log!("#{meth}: #{args[0]}")
93
- # end
91
+ def method_missing(meth, *args, &blk)
92
+ log!("#{meth}: #{args[0]}")
93
+ end
94
94
  end
95
95
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perforator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volodya Sveredyuk