ubalo 0.19 → 0.20

Sign up to get free protection for your applications and to get access to all the features.
data/bin/ubalo CHANGED
@@ -187,7 +187,7 @@ desc 'Show information about a pod'
187
187
  command :pod do |c|
188
188
  c.action do |global_options,options,args|
189
189
  pod.refresh!
190
- puts pod.printable_result
190
+ puts pod.full_printable_result
191
191
  end
192
192
  end
193
193
 
@@ -219,7 +219,7 @@ command :task do |c|
219
219
  task = pod.latest_task
220
220
  end
221
221
 
222
- puts task.printable_result
222
+ puts task.full_printable_result
223
223
  end
224
224
  end
225
225
 
@@ -253,7 +253,7 @@ command 'task:stop' do |c|
253
253
  task.refresh!
254
254
  task.complete?
255
255
  end
256
- puts task.printable_result
256
+ puts task.full_printable_result
257
257
  end
258
258
  end
259
259
 
@@ -16,22 +16,56 @@ module Ubalo
16
16
 
17
17
  def update_attributes(attributes)
18
18
  @state = attributes.fetch('state')
19
+ @started_at = parse_datetime(attributes.fetch('started_at'))
20
+ @stopped_at = parse_datetime(attributes.fetch('stopped_at'))
19
21
  @exit_type = attributes.fetch('exit_type')
20
22
  @exit_result = attributes.fetch('exit_result')
21
23
  @output = attributes.fetch('output')
22
24
  end
23
25
 
24
- def tail(message)
26
+ def tail(running_message, final_message)
25
27
  tailer = Ubalo::Tailer.new(logger)
26
- tailer.poll_on(message) do
28
+ logger.poll do
27
29
  yield
28
- tailer.update(@output)
30
+
31
+ message = "(#{runtime}) #{running_message}..."
32
+ if completed?
33
+ message << "#{final_message}. Exit status: #{exit_result}"
34
+ end
35
+
36
+ tailer.update(@output, message)
29
37
  completed?
30
38
  end
31
39
  end
32
40
 
41
+ def printable_result
42
+ s = ""
43
+ s << "status: #{exit_result}\n"
44
+ s << "runtime: #{runtime}\n"
45
+
46
+ if output and output.length > 0
47
+ s << "stdout/stderr:\n"
48
+ s << Util.indent(output)
49
+ end
50
+ s
51
+ end
52
+
33
53
  def completed?
34
54
  @state == 'complete'
35
55
  end
56
+
57
+ def runtime
58
+ if @started_at
59
+ days = ((@stopped_at || DateTime.now) - @started_at)
60
+ minutes, seconds = (days * 86400).divmod(60)
61
+ "%d:%02d s" % [minutes, seconds]
62
+ end
63
+ end
64
+
65
+ def parse_datetime(string)
66
+ if string
67
+ DateTime.parse(string)
68
+ end
69
+ end
36
70
  end
37
71
  end
data/lib/ubalo/pod.rb CHANGED
@@ -66,7 +66,7 @@ module Ubalo
66
66
  end
67
67
 
68
68
  def latest_task
69
- if task_json = request(:get, "/tasks").first
69
+ if task_json = request(:get, "/tasks/latest")
70
70
  @account.task_from_json(task_json)
71
71
  else
72
72
  raise Ubalo::Error, "Could not find latest task for #{fullname.inspect}"
@@ -105,7 +105,8 @@ module Ubalo
105
105
  compilation_process
106
106
  end
107
107
 
108
- compilation_process.tail("Waiting for #{fullname.inspect} to compile") do
108
+ logger.puts "Compilation process output:"
109
+ compilation_process.tail("Compiling #{fullname}", "compiled") do
109
110
  refresh!
110
111
  end
111
112
 
@@ -128,14 +129,13 @@ module Ubalo
128
129
  s = ""
129
130
  s << " name: #{fullname}\n"
130
131
  s << " state: #{state}\n"
132
+ s
133
+ end
131
134
 
135
+ def full_printable_result
136
+ s = printable_result
132
137
  if compilation_process
133
- s << "status: #{compilation_process.exit_result}\n"
134
-
135
- if compilation_process.output and compilation_process.output.length > 0
136
- s << "stdout/stderr:\n"
137
- s << Util.indent(compilation_process.output)
138
- end
138
+ s << compilation_process.printable_result
139
139
  end
140
140
  s
141
141
  end
data/lib/ubalo/tailer.rb CHANGED
@@ -6,16 +6,7 @@ module Ubalo
6
6
  @lines = 0
7
7
  end
8
8
 
9
- def poll_on(message)
10
- @message = message
11
-
12
- @logger.puts "stdout/stderr: "
13
- @logger.poll do
14
- yield
15
- end
16
- end
17
-
18
- def update(output)
9
+ def update(output, message)
19
10
  @lines.times do
20
11
  @logger.print "\e[A"
21
12
  @logger.print " " * Integer(ENV.fetch("COLUMNS", 80))
@@ -30,7 +21,7 @@ module Ubalo
30
21
  end
31
22
 
32
23
  puts ""
33
- puts @message
24
+ puts message
34
25
  end
35
26
 
36
27
  def puts(str)
data/lib/ubalo/task.rb CHANGED
@@ -32,7 +32,8 @@ module Ubalo
32
32
  container_process
33
33
  end
34
34
 
35
- container_process.tail("Waiting for task #{label.inspect}") do
35
+ puts "Task process output:"
36
+ container_process.tail("Running #{label.inspect}", "completed") do
36
37
  refresh!
37
38
  end
38
39
 
@@ -71,15 +72,6 @@ module Ubalo
71
72
  s << " state: #{state}\n"
72
73
  s << " time: #{'%.1f' % elapsed_time} s\n"
73
74
 
74
- if container_process
75
- s << "status: #{container_process.exit_result}\n"
76
-
77
- if container_process.output and container_process.output.length > 0
78
- s << "stdout/stderr:\n"
79
- s << Util.indent(container_process.output)
80
- end
81
- end
82
-
83
75
  if output?
84
76
  if @output_error
85
77
  s << "! Parse error in output: #{@output_error.message}"
@@ -91,6 +83,14 @@ module Ubalo
91
83
  s
92
84
  end
93
85
 
86
+ def full_printable_result
87
+ s = printable_result
88
+ if container_process
89
+ s << container_process.printable_result
90
+ end
91
+ s
92
+ end
93
+
94
94
  def pretty_argv
95
95
  Shellwords.join(argv)
96
96
  end
data/lib/ubalo/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Ubalo
2
2
  unless const_defined?('VERSION')
3
- VERSION = "0.19"
3
+ VERSION = "0.20"
4
4
  end
5
5
 
6
6
  def self.version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ubalo
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.19'
4
+ version: '0.20'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-06 00:00:00.000000000 Z
12
+ date: 2012-06-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gli
16
- requirement: &70178184528280 !ruby/object:Gem::Requirement
16
+ requirement: &70273345221500 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70178184528280
24
+ version_requirements: *70273345221500
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: highline
27
- requirement: &70178184527840 !ruby/object:Gem::Requirement
27
+ requirement: &70273345220120 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70178184527840
35
+ version_requirements: *70273345220120
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: json
38
- requirement: &70178184527360 !ruby/object:Gem::Requirement
38
+ requirement: &70273345218440 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70178184527360
46
+ version_requirements: *70273345218440
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rest-client
49
- requirement: &70178184526780 !ruby/object:Gem::Requirement
49
+ requirement: &70273345216520 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.6.3
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70178184526780
57
+ version_requirements: *70273345216520
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: archive-tar-minitar
60
- requirement: &70178184526180 !ruby/object:Gem::Requirement
60
+ requirement: &70273345213160 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70178184526180
68
+ version_requirements: *70273345213160
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: launchy
71
- requirement: &70178184525320 !ruby/object:Gem::Requirement
71
+ requirement: &70273345211620 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70178184525320
79
+ version_requirements: *70273345211620
80
80
  description: CLI and API client for Ubalo
81
81
  email: dev@ubalo.com
82
82
  executables: