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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05e818d1a505624b253bc187ebc195f35274972c
4
- data.tar.gz: 68288589c6871734cdbfa80ea65f0c52bbac27ef
3
+ metadata.gz: 24c63cb7b767c7c567d57325acb63764ebb4b49a
4
+ data.tar.gz: 44556772c4feb2700fb136bb724689a480c9b79d
5
5
  SHA512:
6
- metadata.gz: 174b35b5e8da79525461ba47384cb3d9a789585fd8acd980e477b108c470783209091340dbf5292a803ea3e2fe4e7ab302a38fbd89fd56325514bb1aff02d3e5
7
- data.tar.gz: ba6128a8fb8f5332605528bf220b96ff35de19f5bd86381422e1727c82a8675b1c050a602d4ee852ef411bef77ddda8afe92acc4966a378f42ed762972337603
6
+ metadata.gz: baf7c3fd9781bb40bf9854cab07b3c68f3b02b07c2acfab5162c95d192f17f26e2ed56c3c5198ae66bdecf47d0ca49ea0b2db8d282cf14b40a38fd278e3d5625
7
+ data.tar.gz: f49edc98670a6d3a08d4c6566053fbcc6adb58a79c96954b7f0117419565c0ba805e696282bd407a1379787a9c1c64e9eff1e1ad2d1da9026377a4ccad236f08
@@ -0,0 +1,6 @@
1
+ = 0.1.0
2
+ - support logger
3
+ - set output time format
4
+
5
+ = 0.0.1
6
+ - launch first version
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
- 'bar' * 1000000
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
- That's all.
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/[my-github-username]/mtracker/fork )
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`)
@@ -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
- puts "[start] #{label}"
7
+ put_track_info "[start] #{label}"
7
8
  yield
8
- puts "[end] #{label} (#{Time.now - start_time} sec)"
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
@@ -1,3 +1,3 @@
1
1
  module Mtracker
2
- VERSION = "0.0.1"
2
+ VERSION = '0.1.0'
3
3
  end
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.1
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-03 00:00:00.000000000 Z
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