bumbler 0.2.0 → 0.2.1
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 +4 -4
- data/bin/bumbler +17 -0
- data/lib/bumbler/progress.rb +38 -39
- data/lib/bumbler/version.rb +1 -1
- metadata +43 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdafd8de66c8e6e9fecbc41654d7408d1f8ab1af
|
4
|
+
data.tar.gz: e56cae51bb0e6a97aec7a3e4f9ac5fc7145ab38b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 242b08d8a00f098058d1d387498581a45c8f7748100120fe86d8796bb23fb6455136d128836a9f845bcf8743858f6542ba5e719f58865b27c0ceabdb3976be95
|
7
|
+
data.tar.gz: 857dc10735d0cc90f34fec7e4b8d8ddae9647347b7dc6181152a1334e2f2b5d3602be89ff236fea0356b636666dad84b3b966a8764546df200805a4ea2a54520
|
data/bin/bumbler
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
3
|
+
|
4
|
+
require 'optparse'
|
5
|
+
require 'bumbler'
|
6
|
+
|
7
|
+
OptionParser.new do |parser|
|
8
|
+
parser.banner = <<BANNER
|
9
|
+
Bumbler shows how long loading your bundle components take.
|
10
|
+
|
11
|
+
Usage:
|
12
|
+
bumbler
|
13
|
+
|
14
|
+
Options:
|
15
|
+
BANNER
|
16
|
+
parser.on("-h", "--help","Show this.") { puts parser; exit }
|
17
|
+
parser.on('-v', '--version','Show Version'){ puts Bumbler::VERSION; exit}
|
18
|
+
end.parse!
|
19
|
+
|
3
20
|
require 'bumbler/go'
|
4
21
|
require './config/environment'
|
5
22
|
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib') # bundler kicks us out
|
data/lib/bumbler/progress.rb
CHANGED
@@ -2,92 +2,91 @@ module Bumbler
|
|
2
2
|
module Progress
|
3
3
|
@item_count = 0
|
4
4
|
@loaded_items = 0
|
5
|
-
|
5
|
+
|
6
6
|
# registry[item_type][item_name] = {:time => 123.45}
|
7
7
|
@registry = Hash.new { |h,k| h[k] = {} }
|
8
|
-
|
8
|
+
|
9
9
|
class << self
|
10
10
|
def registry
|
11
11
|
@registry
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def register_item(type, name)
|
15
15
|
# Build a blank key for the item
|
16
16
|
unless @registry[type][name]
|
17
17
|
@item_count += 1
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
@registry[type][name] = {}
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def item_started(type, name)
|
24
24
|
@curr_item = {:type => type, :name => name}
|
25
|
-
|
25
|
+
|
26
26
|
self.render_progress
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def item_finished(type, name, time)
|
30
30
|
@registry[type][name] = {:time => time}
|
31
|
-
|
31
|
+
|
32
32
|
@loaded_items += 1
|
33
|
-
|
33
|
+
|
34
34
|
@prev_item = {:type => type, :name => name, :time => time}
|
35
35
|
@curr_item = nil if @curr_item && @curr_item[:name] == @prev_item[:name] && @curr_item[:type] == @prev_item[:type]
|
36
|
-
|
36
|
+
|
37
37
|
self.render_progress
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def start!
|
41
41
|
# No-op for now.
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
def tty_width
|
45
45
|
`tput cols`.to_i || 80
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
def bar(width)
|
49
49
|
inner_size = width - 2
|
50
|
-
|
50
|
+
|
51
51
|
fill_size = [((@loaded_items.to_f / @item_count.to_f) * inner_size).to_i, inner_size].min
|
52
52
|
fill = '#' * fill_size
|
53
53
|
empty = ' ' * (inner_size - fill_size)
|
54
|
-
|
54
|
+
|
55
55
|
return "[#{fill}#{empty}]"
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
def render_progress
|
59
|
-
unless $stdout.tty?
|
60
|
-
puts '(%s/%d) %s' % [@loaded_items.to_s.rjust(@item_count.to_s.size), @item_count, message]
|
61
|
-
return
|
62
|
-
end
|
63
|
-
|
64
59
|
# Do nothing if we don't have any items to load
|
65
60
|
return if @item_count == 0
|
66
|
-
|
67
|
-
width = self.tty_width
|
68
|
-
|
69
|
-
print "\r\e[A\r\e[A" if @outputted_once
|
70
|
-
@outputted_once = true
|
71
|
-
|
61
|
+
|
72
62
|
# Output components:
|
73
63
|
# [#######################################]
|
74
64
|
# (##/##) <current>... <prev> (####.##ms)
|
75
|
-
#
|
65
|
+
#
|
76
66
|
# Skip the current if there isn't enough room
|
77
67
|
count = '(%s/%d) ' % [@loaded_items.to_s.rjust(@item_count.to_s.size), @item_count]
|
78
68
|
current = @curr_item ? "#{@curr_item[:name]}... " : ''
|
79
69
|
prev = @prev_item ? '%s (%sms)' % [@prev_item[:name], ('%.2f' % @prev_item[:time]).rjust(7)] : ''
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
70
|
+
|
71
|
+
if $stdout.tty?
|
72
|
+
width = self.tty_width
|
73
|
+
|
74
|
+
print "\r\e[A\r\e[A" if @outputted_once
|
75
|
+
@outputted_once = true
|
76
|
+
|
77
|
+
# Align the bottom row
|
78
|
+
space_for_current = width - (count.length + prev.length)
|
79
|
+
|
80
|
+
# Render the progress
|
81
|
+
puts self.bar(width)
|
82
|
+
|
83
|
+
if space_for_current >= current.length
|
84
|
+
puts count + current + prev.rjust(width - count.length - current.length)
|
85
|
+
else
|
86
|
+
puts count + prev.rjust(width - count.length)
|
87
|
+
end
|
88
|
+
elsif @curr_item
|
89
|
+
puts '%s %s' % [count, @curr_item[:name]]
|
91
90
|
end
|
92
91
|
end
|
93
92
|
end
|
data/lib/bumbler/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bumbler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian MacLeod
|
@@ -24,6 +24,48 @@ dependencies:
|
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest-rg
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest-around
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
27
69
|
description: Why stare blankly at your terminal window when you can clutter it up
|
28
70
|
with awesome progress bars?
|
29
71
|
email:
|