xp5k 0.0.13 → 0.0.14

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: e63243781dcd538f44d467d8bd3c2b852392c6dd
4
- data.tar.gz: c6533692344df8de75efaa9f8463f22c7df642b7
3
+ metadata.gz: 66fba490efafb700478c294bb2610171dff6f863
4
+ data.tar.gz: c6e7107caa06c5250c2875a5dfa6fb9fa27a8281
5
5
  SHA512:
6
- metadata.gz: 98a175bdcf30bfbd561b9457d10b74beb6be3cf427272f09e08436d4fd57b7fc67dc909a414c5b120add6d5bd2799e47a6fba512203d611f40d73a4696bf06c4
7
- data.tar.gz: e5f4f5a6f520321f19c1bfcd7956a1bb94cea850a952aa74c5146ab3c3949a9bab6868c43181601552b57a6fadf87ead08c561d0cc246d1020558d13a5dffd2c
6
+ metadata.gz: 046781b3385e56c8aa53af27a61c5fce65938f1bed773e170ceee8f68e26296f18e4715586fedf7b69e5d3546594ab6c2e29981e6dd8debf80b2d56d35b78386
7
+ data.tar.gz: 33f38af0caf29b957d566c971b40231807c0044f073140cfb05985859c319bf7dd6d0e17bcc1237e1cb1c87633036b94ff0da689904307a4d91887166a43c9e0
data/lib/xp5k/rake/dsl.rb CHANGED
@@ -2,6 +2,8 @@ require 'xp5k/role'
2
2
  require 'net/ssh/multi'
3
3
  require 'timeout'
4
4
  require 'thread'
5
+ require 'xp5k/rake/timer'
6
+ require 'xp5k/rake/task'
5
7
 
6
8
  module XP5K
7
9
  module Rake
@@ -0,0 +1,14 @@
1
+ module Rake
2
+ class Task
3
+
4
+ alias_method :rake_execute, :execute
5
+
6
+ def execute(args=nil)
7
+ timer = XP5K::Rake::Timer.new(name)
8
+ puts "--> Execute task #{name}"
9
+ rake_execute(args)
10
+ timer.stop
11
+ end
12
+
13
+ end
14
+ end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module XP5K
2
- VERSION='0.0.13'
2
+ VERSION='0.0.14'
3
3
  end
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.13
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-02 00:00:00.000000000 Z
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