speedometer 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/speedometer.rb +18 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 762906cb1efe065de8cbb871b0154ed0bd2caa83
|
4
|
+
data.tar.gz: 9eec69ac82889208b7acd0e8bf9bbd5655289db7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5f16f4de7abd0bf93287fcd3e3b9580b80e0af6c7709965dd182d2a35819c266d013b1a0ebca0ebb490d8b1fc3d881b6f6e91643cd753c18e6c5aa6194baea2
|
7
|
+
data.tar.gz: 3d33d33bd8f1b9e355544955878cd2267c8a65655c9eca6a96d713c07489c7864d186763102deecaf30022884ef4526bc553c0aebea3fe5bdc543768ffdb5b05
|
data/lib/speedometer.rb
CHANGED
@@ -28,6 +28,7 @@ class Speedometer
|
|
28
28
|
@start_time = Time.now
|
29
29
|
@active = true
|
30
30
|
@refresh_time = 1000
|
31
|
+
@msg_lock = Mutex.new
|
31
32
|
if ["KB","MB","GB"].include?(units)
|
32
33
|
@units = units
|
33
34
|
else
|
@@ -36,14 +37,16 @@ class Speedometer
|
|
36
37
|
end
|
37
38
|
|
38
39
|
def clear
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
40
|
+
@msg_lock.synchronize do
|
41
|
+
length = `tput cols`
|
42
|
+
length = length.split.last.to_i
|
43
|
+
print "\r"
|
44
|
+
STDOUT.flush
|
45
|
+
print "#{' ' * length}"
|
46
|
+
STDOUT.flush
|
47
|
+
print "\r"
|
48
|
+
STDOUT.flush
|
49
|
+
end
|
47
50
|
end
|
48
51
|
|
49
52
|
def display
|
@@ -56,14 +59,18 @@ class Speedometer
|
|
56
59
|
if @units == "GB"
|
57
60
|
speed = speed / 1024
|
58
61
|
end
|
59
|
-
|
60
|
-
|
62
|
+
@msg_lock.synchronize do
|
63
|
+
print "#{speed.round(2)}#{@units}/s"
|
64
|
+
STDOUT.flush
|
65
|
+
end
|
61
66
|
sleep @refresh_time.to_f / 1000
|
62
67
|
end
|
63
68
|
|
64
69
|
def log(msg)
|
65
70
|
clear
|
66
|
-
|
71
|
+
@msg_lock.synchronize do
|
72
|
+
puts msg
|
73
|
+
end
|
67
74
|
display
|
68
75
|
end
|
69
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: speedometer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tadeus Dobrovolskij
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Library to track and display bandwith usage inside the application
|
14
14
|
email: root@tad-do.net
|