ubalo 0.22 → 0.23

Sign up to get free protection for your applications and to get access to all the features.
data/bin/ubalo CHANGED
@@ -22,7 +22,7 @@ end
22
22
  use_openstruct true
23
23
 
24
24
  def logger
25
- @logger ||= Ubalo::Util::Logger.new $stdin.tty?
25
+ @logger ||= Ubalo::Logger.new $stdin.tty?
26
26
  end
27
27
 
28
28
  def connect_url
data/lib/ubalo.rb CHANGED
@@ -12,6 +12,7 @@ require "ubalo/pod_archive"
12
12
  require "ubalo/container_process"
13
13
  require "ubalo/task"
14
14
  require "ubalo/pod_dir"
15
+ require "ubalo/logger"
15
16
  require "ubalo/tailer"
16
17
 
17
18
  module Ubalo
@@ -16,6 +16,7 @@ module Ubalo
16
16
 
17
17
  def update_attributes(attributes)
18
18
  @state = attributes.fetch('state')
19
+ @runtime = attributes.fetch('runtime')
19
20
  @started_at = parse_datetime(attributes.fetch('started_at'))
20
21
  @stopped_at = parse_datetime(attributes.fetch('stopped_at'))
21
22
  @exit_type = attributes.fetch('exit_type')
@@ -33,7 +34,7 @@ module Ubalo
33
34
  def printable_result
34
35
  s = ""
35
36
  s << "status: #{exit_result}\n"
36
- s << "runtime: #{runtime}\n"
37
+ s << "runtime: #{pretty_runtime}\n"
37
38
 
38
39
  if output and output.length > 0
39
40
  s << "stdout/stderr:\n"
@@ -42,10 +43,9 @@ module Ubalo
42
43
  s
43
44
  end
44
45
 
45
- def runtime
46
- if @started_at
47
- seconds = ((@stopped_at || DateTime.now) - @started_at) * 86400
48
- "%2.1f s" % seconds
46
+ def pretty_runtime
47
+ if @runtime
48
+ "%2.1f s" % @runtime
49
49
  end
50
50
  end
51
51
 
@@ -0,0 +1,50 @@
1
+ module Ubalo
2
+ class Logger
3
+ def initialize tty
4
+ @incomplete_line = false
5
+ @tty = tty
6
+ end
7
+
8
+ def tty?
9
+ @tty
10
+ end
11
+
12
+ def print(str)
13
+ @incomplete_line = true
14
+ $stderr.print(str)
15
+ end
16
+
17
+ def puts(str="")
18
+ @incomplete_line = false
19
+ $stderr.print(str + "\n")
20
+ end
21
+
22
+ def complete_line
23
+ $stderr.print("\n") if @incomplete_line
24
+ @incomplete_line = false
25
+ end
26
+
27
+ def poll
28
+ 600.times do
29
+ if result = yield
30
+ return result
31
+ end
32
+ sleep 0.5
33
+ end
34
+
35
+ self.complete_line
36
+ raise Ubalo::Error, "timed-out while waiting"
37
+ end
38
+
39
+ def poll_on(message)
40
+ self.print message
41
+ result = poll do
42
+ self.print '.'
43
+ yield
44
+ end
45
+
46
+ self.puts " done."
47
+ result
48
+ end
49
+ end
50
+ end
data/lib/ubalo/tailer.rb CHANGED
@@ -13,7 +13,7 @@ module Ubalo
13
13
  # Erase current line.
14
14
  if tty?
15
15
  @logger.print "\r"
16
- @logger.print " " * Integer(ENV.fetch("COLUMNS", 80))
16
+ @logger.print " " * Integer(Util.columns)
17
17
  @logger.print "\r"
18
18
  end
19
19
 
@@ -23,7 +23,7 @@ module Ubalo
23
23
  end
24
24
 
25
25
  if tty?
26
- @logger.print Color.blue(wrap(message))
26
+ @logger.print Color.green(wrap(message))
27
27
  else
28
28
  @logger.puts wrap(message)
29
29
  end
data/lib/ubalo/util.rb CHANGED
@@ -18,55 +18,6 @@ module Ubalo
18
18
  end
19
19
  end
20
20
 
21
- class Logger
22
- def initialize tty
23
- @incomplete_line = false
24
- @tty = tty
25
- end
26
-
27
- def tty?
28
- @tty
29
- end
30
-
31
- def print(str)
32
- @incomplete_line = true
33
- $stderr.print(str)
34
- end
35
-
36
- def puts(str="")
37
- @incomplete_line = false
38
- $stderr.print(str + "\n")
39
- end
40
-
41
- def complete_line
42
- $stderr.print("\n") if @incomplete_line
43
- @incomplete_line = false
44
- end
45
-
46
- def poll
47
- 600.times do
48
- if result = yield
49
- return result
50
- end
51
- sleep 0.5
52
- end
53
-
54
- self.complete_line
55
- raise Ubalo::Error, "timed-out while waiting"
56
- end
57
-
58
- def poll_on(message)
59
- self.print message
60
- result = poll do
61
- self.print '.'
62
- yield
63
- end
64
-
65
- self.puts " done."
66
- result
67
- end
68
- end
69
-
70
21
  class << self
71
22
  def normalize_pod_name(default_username, pod_name)
72
23
  if pod_name.include?("/")
@@ -162,6 +113,12 @@ module Ubalo
162
113
  def debug_mode?
163
114
  ENV['UBALO_DEBUG'] == 'true'
164
115
  end
116
+
117
+ def columns
118
+ @columns ||= Integer(`tput cols`.strip)
119
+ rescue
120
+ 80
121
+ end
165
122
  end
166
123
  end
167
124
 
data/lib/ubalo/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Ubalo
2
2
  unless const_defined?('VERSION')
3
- VERSION = "0.22"
3
+ VERSION = "0.23"
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.22'
4
+ version: '0.23'
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-15 00:00:00.000000000 Z
12
+ date: 2012-06-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gli
16
- requirement: &70151076782260 !ruby/object:Gem::Requirement
16
+ requirement: &70362525730360 !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: *70151076782260
24
+ version_requirements: *70362525730360
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: highline
27
- requirement: &70151076781820 !ruby/object:Gem::Requirement
27
+ requirement: &70362525729940 !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: *70151076781820
35
+ version_requirements: *70362525729940
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: json
38
- requirement: &70151076781260 !ruby/object:Gem::Requirement
38
+ requirement: &70362525729520 !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: *70151076781260
46
+ version_requirements: *70362525729520
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rest-client
49
- requirement: &70151076780740 !ruby/object:Gem::Requirement
49
+ requirement: &70362525729020 !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: *70151076780740
57
+ version_requirements: *70362525729020
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: archive-tar-minitar
60
- requirement: &70151076780320 !ruby/object:Gem::Requirement
60
+ requirement: &70362525769540 !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: *70151076780320
68
+ version_requirements: *70362525769540
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: launchy
71
- requirement: &70151076779840 !ruby/object:Gem::Requirement
71
+ requirement: &70362525769080 !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: *70151076779840
79
+ version_requirements: *70362525769080
80
80
  description: CLI and API client for Ubalo
81
81
  email: dev@ubalo.com
82
82
  executables:
@@ -86,6 +86,7 @@ extra_rdoc_files: []
86
86
  files:
87
87
  - lib/ubalo/account.rb
88
88
  - lib/ubalo/container_process.rb
89
+ - lib/ubalo/logger.rb
89
90
  - lib/ubalo/pod.rb
90
91
  - lib/ubalo/pod_archive.rb
91
92
  - lib/ubalo/pod_dir.rb
@@ -122,3 +123,4 @@ signing_key:
122
123
  specification_version: 3
123
124
  summary: CLI and API client for Ubalo
124
125
  test_files: []
126
+ has_rdoc: