xp5k 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/xp5k/rake/dsl.rb +2 -0
- data/lib/xp5k/rake/task.rb +14 -0
- data/lib/xp5k/rake/timer.rb +60 -0
- data/lib/xp5k/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66fba490efafb700478c294bb2610171dff6f863
|
4
|
+
data.tar.gz: c6e7107caa06c5250c2875a5dfa6fb9fa27a8281
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 046781b3385e56c8aa53af27a61c5fce65938f1bed773e170ceee8f68e26296f18e4715586fedf7b69e5d3546594ab6c2e29981e6dd8debf80b2d56d35b78386
|
7
|
+
data.tar.gz: 33f38af0caf29b957d566c971b40231807c0044f073140cfb05985859c319bf7dd6d0e17bcc1237e1cb1c87633036b94ff0da689904307a4d91887166a43c9e0
|
data/lib/xp5k/rake/dsl.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
module XP5K
|
2
|
+
module Rake
|
3
|
+
class Timer
|
4
|
+
|
5
|
+
@@initial_timer = nil
|
6
|
+
@@current = nil
|
7
|
+
|
8
|
+
attr_accessor :start_time, :stop_time, :task_name, :parent, :childs
|
9
|
+
|
10
|
+
def initialize(name)
|
11
|
+
@start_time = Time.now
|
12
|
+
@stop_time = nil
|
13
|
+
@parent = nil
|
14
|
+
@childs ||= []
|
15
|
+
@task_name = name
|
16
|
+
@@initial_timer ||= self
|
17
|
+
if @@current
|
18
|
+
if @@current.stop_time
|
19
|
+
@parent = @@current.parent
|
20
|
+
else
|
21
|
+
@parent = @@current
|
22
|
+
end
|
23
|
+
end
|
24
|
+
@@current = self
|
25
|
+
end
|
26
|
+
|
27
|
+
def stop()
|
28
|
+
@stop_time = Time.now
|
29
|
+
self.parent.childs << self if self.parent
|
30
|
+
@@current = self.parent
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.summary
|
34
|
+
level = 1
|
35
|
+
@@initial_timer.stop unless @@initial_timer.stop_time
|
36
|
+
puts "| " * (level - 1) + "|-- #{@@initial_timer.task_name} : #{self.duration(@@initial_timer)}"
|
37
|
+
timer = @@initial_timer
|
38
|
+
until (@@initial_timer.childs.count == 0 and level == 0) do
|
39
|
+
if timer.childs.count > 0
|
40
|
+
timer = timer.childs.shift
|
41
|
+
level += 1
|
42
|
+
puts "| " * (level - 1) + "|-- #{timer.task_name} -> #{self.duration(timer)}"
|
43
|
+
else
|
44
|
+
level -= 1
|
45
|
+
timer = timer.parent
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def self.duration(timer)
|
54
|
+
Time.at(timer.stop_time - timer.start_time).utc.strftime("%Hh %Mm %Ss")
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
data/lib/xp5k/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xp5k
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pascal Morillon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -112,6 +112,8 @@ files:
|
|
112
112
|
- lib/xp5k/exceptions.rb
|
113
113
|
- lib/xp5k/rake.rb
|
114
114
|
- lib/xp5k/rake/dsl.rb
|
115
|
+
- lib/xp5k/rake/task.rb
|
116
|
+
- lib/xp5k/rake/timer.rb
|
115
117
|
- lib/xp5k/role.rb
|
116
118
|
- lib/xp5k/version.rb
|
117
119
|
- lib/xp5k/xp.rb
|