powerbar 1.0.12 → 1.0.13
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/{README.rdoc → README.MD} +29 -29
- data/ass/screencast.gif +0 -0
- data/lib/powerbar.rb +11 -4
- data/lib/powerbar/version.rb +1 -1
- data/powerbar.gemspec +0 -1
- metadata +4 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d7b69a940b100adf7d075d39e0e861a2fe11e52
|
4
|
+
data.tar.gz: ed6d0bb872782aca625c0883e397210f14b00b90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38a535f86d864c4d30e9e11f7fd891f6bd0afe2af05f5039f7403080cb3c9b14585585e9fc3ebbe3725f2b6a41acc35c646d1968852883f0d80553bb19d7d2ff
|
7
|
+
data.tar.gz: deee7b06944397b0135f295ce685d2091e5a11b712f8b391c156cca505cec65ced7a8d02e9be6f1a702423d75df92a3f4cc5a879b84d3f1534b2b55aca1a29aa
|
data/{README.rdoc → README.MD}
RENAMED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
# PowerBar
|
2
2
|
|
3
3
|
This is PowerBar - The last progressbar-library you'll ever need.
|
4
4
|
|
5
|
-
|
5
|
+
## Features
|
6
6
|
|
7
7
|
* Detects when stdout is not a terminal and automatically falls back to logging
|
8
8
|
* Does not clutter your log-files with ansi-codes!
|
@@ -21,54 +21,54 @@ This is PowerBar - The last progressbar-library you'll ever need.
|
|
21
21
|
multi-part operation then you can change the status-message of a running
|
22
22
|
PowerBar to reflect the current state.
|
23
23
|
|
24
|
-
|
24
|
+
## Demo
|
25
25
|
|
26
|
-
|
26
|
+

|
27
27
|
|
28
|
+
## Installation
|
28
29
|
|
29
|
-
|
30
|
+
`gem install powerbar`
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
== Getting Started
|
32
|
+
## Getting Started
|
34
33
|
|
35
34
|
Watch the demo that was installed along with the gem:
|
36
35
|
|
37
|
-
|
36
|
+
`powerbar-demo`
|
38
37
|
|
39
|
-
Then look at the
|
38
|
+
Then look at the [source-code](https://github.com/busyloop/powerbar/blob/master/bin/powerbar-demo) of the demo. Pretty much all use-cases are covered in there, including templates and how to hook in your own logger.
|
40
39
|
|
41
40
|
|
42
|
-
|
41
|
+
## Example (for the impatient)
|
43
42
|
|
44
|
-
|
43
|
+
```
|
44
|
+
#!/usr/bin/env ruby
|
45
45
|
|
46
|
-
|
46
|
+
require 'powerbar'
|
47
47
|
|
48
|
-
|
49
|
-
|
48
|
+
total = 100000
|
49
|
+
step = 1000
|
50
50
|
|
51
|
-
|
51
|
+
p = PowerBar.new
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
# Override some defaults to demonstrate how the settings work
|
54
|
+
p.settings.tty.finite.template.barchar = '*'
|
55
|
+
p.settings.tty.finite.template.padchar = '.'
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
# Dummy loop to simulate some progress
|
58
|
+
(0..total).step(step).each do |i|
|
59
|
+
p.show(:msg => 'DEMO 1 - Ten seconds of progress', :done => i, :total => total)
|
60
|
+
sleep 0.1
|
61
|
+
end
|
62
|
+
p.close
|
63
|
+
```
|
63
64
|
|
64
|
-
|
65
|
+
## Documentation?
|
65
66
|
|
66
|
-
Use the
|
67
|
+
Use the [source](https://github.com/busyloop/powerbar/blob/master/lib/powerbar.rb), Luke!
|
67
68
|
|
68
|
-
|
69
|
+
## License (MIT)
|
69
70
|
|
70
71
|
Copyright (C) 2011 by moe@busyloop.net
|
71
|
-
|
72
72
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
73
73
|
of this software and associated documentation files (the "Software"), to deal
|
74
74
|
in the Software without restriction, including without limitation the rights
|
data/ass/screencast.gif
ADDED
Binary file
|
data/lib/powerbar.rb
CHANGED
@@ -37,7 +37,7 @@ class PowerBar
|
|
37
37
|
:time_last_show => Time.at(0), # <- don't mess with us
|
38
38
|
:time_last_update => Time.at(0), # <- unless you know
|
39
39
|
:time_start => nil, # <- what you're doing!
|
40
|
-
:time_now => nil, # <-
|
40
|
+
:time_now => nil, # <-
|
41
41
|
:msg => 'PowerBar!',
|
42
42
|
:done => 0,
|
43
43
|
:total => :unknown,
|
@@ -199,7 +199,7 @@ class PowerBar
|
|
199
199
|
state.time_start ||= Time.now
|
200
200
|
state.time_now = Time.now
|
201
201
|
|
202
|
-
@rate ||= PowerBar::Rate.new(state.time_now,
|
202
|
+
@rate ||= PowerBar::Rate.new(state.time_now,
|
203
203
|
state.settings.rate_sample_window,
|
204
204
|
state.settings.rate_sample_max_interval)
|
205
205
|
@rate.append(state.time_now, state.done)
|
@@ -309,7 +309,14 @@ class PowerBar
|
|
309
309
|
end
|
310
310
|
|
311
311
|
def terminal_width
|
312
|
-
|
312
|
+
if /solaris/ =~ RUBY_PLATFORM && (`stty` =~ /\brows = (\d+).*\bcolumns = (\d+)/)
|
313
|
+
w, r = [$2, $1]
|
314
|
+
else
|
315
|
+
w, r = `stty size 2>/dev/null`.split.reverse
|
316
|
+
end
|
317
|
+
w = `tput cols` unless w
|
318
|
+
w = w.to_i if w
|
319
|
+
w
|
313
320
|
end
|
314
321
|
|
315
322
|
private
|
@@ -353,7 +360,7 @@ class PowerBar
|
|
353
360
|
|
354
361
|
HQ_UNITS = %w(b k M G T).freeze
|
355
362
|
def humanize_quantity(number, format='%n%u')
|
356
|
-
return nil if number.nil?
|
363
|
+
return nil if number.nil?
|
357
364
|
return nil if number.is_a? Float and (number.nan? or number.infinite?)
|
358
365
|
kilo = settings.kilo
|
359
366
|
return number if number.to_i < kilo
|
data/lib/powerbar/version.rb
CHANGED
data/powerbar.gemspec
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: powerbar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Moe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: ansi
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.5.0
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 1.5.0
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: hashie
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -48,8 +34,9 @@ extra_rdoc_files: []
|
|
48
34
|
files:
|
49
35
|
- ".gitignore"
|
50
36
|
- Gemfile
|
51
|
-
- README.
|
37
|
+
- README.MD
|
52
38
|
- Rakefile
|
39
|
+
- ass/screencast.gif
|
53
40
|
- ass/screenshot.png
|
54
41
|
- bin/powerbar-demo
|
55
42
|
- lib/powerbar.rb
|