mtracker 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGE_LOG.md +6 -0
- data/README.md +33 -4
- data/lib/mtracker.rb +11 -2
- data/lib/mtracker/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24c63cb7b767c7c567d57325acb63764ebb4b49a
|
4
|
+
data.tar.gz: 44556772c4feb2700fb136bb724689a480c9b79d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baf7c3fd9781bb40bf9854cab07b3c68f3b02b07c2acfab5162c95d192f17f26e2ed56c3c5198ae66bdecf47d0ca49ea0b2db8d282cf14b40a38fd278e3d5625
|
7
|
+
data.tar.gz: f49edc98670a6d3a08d4c6566053fbcc6adb58a79c96954b7f0117419565c0ba805e696282bd407a1379787a9c1c64e9eff1e1ad2d1da9026377a4ccad236f08
|
data/CHANGE_LOG.md
ADDED
data/README.md
CHANGED
@@ -23,10 +23,10 @@ Just include `Mtracker` module to your class and call `track` method with label
|
|
23
23
|
```
|
24
24
|
class Myclass
|
25
25
|
include Mtracker
|
26
|
-
|
26
|
+
|
27
27
|
def foo
|
28
28
|
track 'sample job' do
|
29
|
-
|
29
|
+
'bar' * 1000000
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -39,11 +39,40 @@ Then you can see following output:
|
|
39
39
|
[end] sample job (0.004353018 sec)
|
40
40
|
```
|
41
41
|
|
42
|
-
|
42
|
+
## Usage with logger
|
43
|
+
Just include `Mtracker` module to your class and make attribute reader named logger and
|
44
|
+
call `track` method with label and block.
|
45
|
+
|
46
|
+
```
|
47
|
+
class Myclass
|
48
|
+
include Mtracker
|
49
|
+
|
50
|
+
attr_accessor :logger
|
51
|
+
|
52
|
+
def initialize
|
53
|
+
# initialize logger
|
54
|
+
end
|
55
|
+
|
56
|
+
def foo
|
57
|
+
track 'sample job' do
|
58
|
+
'bar' * 1000000
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
```
|
63
|
+
|
64
|
+
Then you can see following output in your logger output as info level:
|
65
|
+
|
66
|
+
```
|
67
|
+
[start] sample job
|
68
|
+
[end] sample job (0.004353018 sec)
|
69
|
+
```
|
70
|
+
|
71
|
+
|
43
72
|
|
44
73
|
## Contributing
|
45
74
|
|
46
|
-
1. Fork it ( https://github.com/
|
75
|
+
1. Fork it ( https://github.com/muratayusuke/mtracker/fork )
|
47
76
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
77
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
49
78
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/mtracker.rb
CHANGED
@@ -1,10 +1,19 @@
|
|
1
1
|
require 'mtracker/version'
|
2
2
|
|
3
|
+
# module for tracking time
|
3
4
|
module Mtracker
|
4
5
|
def track(label)
|
5
6
|
start_time = Time.now
|
6
|
-
|
7
|
+
put_track_info "[start] #{label}"
|
7
8
|
yield
|
8
|
-
|
9
|
+
put_track_info "[end] #{label} (#{sprintf('%.3f', Time.now - start_time)} sec)"
|
10
|
+
end
|
11
|
+
|
12
|
+
def put_track_info(msg)
|
13
|
+
if respond_to?(:logger)
|
14
|
+
logger.info(msg)
|
15
|
+
else
|
16
|
+
puts msg
|
17
|
+
end
|
9
18
|
end
|
10
19
|
end
|
data/lib/mtracker/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mtracker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yusuke Murata
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -46,6 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- ".gitignore"
|
49
|
+
- CHANGE_LOG.md
|
49
50
|
- Gemfile
|
50
51
|
- LICENSE.txt
|
51
52
|
- README.md
|