indicator 0.1.0 → 0.1.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.
- data/README.rdoc +16 -0
- data/lib/indicator.rb +60 -31
- data/lib/indicator/version.rb +1 -1
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -45,3 +45,19 @@ Manual control
|
|
45
45
|
sleep 0.2
|
46
46
|
end
|
47
47
|
spinner.clean
|
48
|
+
|
49
|
+
Predefined sets
|
50
|
+
Indicator::spin :set => :p do
|
51
|
+
10.times do
|
52
|
+
sleep 0.5
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
Available sets: :x :< :> :V :dots :bars :p :bqpd :-
|
57
|
+
|
58
|
+
Custom set
|
59
|
+
Indicator::spin :frames => %w{ * + } do
|
60
|
+
10.times do
|
61
|
+
sleep 0.5
|
62
|
+
end
|
63
|
+
end
|
data/lib/indicator.rb
CHANGED
@@ -1,31 +1,60 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path('../indicator/spin', __FILE__)
|
3
|
+
|
4
|
+
module Indicator
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def set name = :bar
|
8
|
+
case name
|
9
|
+
when :bar
|
10
|
+
%w{ | / - \\ }
|
11
|
+
when :x
|
12
|
+
%w{ + X }
|
13
|
+
when :<
|
14
|
+
%w{ | < }
|
15
|
+
when :>
|
16
|
+
%w{ | > }
|
17
|
+
when :V
|
18
|
+
%w{ V > ^ }
|
19
|
+
when :dots
|
20
|
+
%w{ : . }
|
21
|
+
when :bars
|
22
|
+
%w{ - = }
|
23
|
+
when :p
|
24
|
+
%w{ p b d q }
|
25
|
+
when :bqpd
|
26
|
+
%w{ bq pd }
|
27
|
+
when :-
|
28
|
+
%w{ - ~ }
|
29
|
+
else
|
30
|
+
%w{ | / - \\ }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def spinner opts={}
|
35
|
+
opts[:frames] = set opts[:set] unless opts[:frames]
|
36
|
+
Indicator::Spin.new opts
|
37
|
+
end
|
38
|
+
|
39
|
+
def spin opts={}, &blk
|
40
|
+
spinner = opts[:spinner] || self.spinner(opts)
|
41
|
+
noclean = opts[:noclean] || false
|
42
|
+
ondemand = opts[:ondemand] || false
|
43
|
+
|
44
|
+
if ondemand
|
45
|
+
yield spinner
|
46
|
+
else
|
47
|
+
t = Thread.new { yield spinner }
|
48
|
+
|
49
|
+
while t.alive?
|
50
|
+
spinner.spinning
|
51
|
+
end
|
52
|
+
|
53
|
+
t.join
|
54
|
+
end
|
55
|
+
|
56
|
+
spinner.clean unless noclean
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
data/lib/indicator/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: indicator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
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-02-
|
12
|
+
date: 2012-02-05 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &8710280 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 2.7.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *8710280
|
25
25
|
description: Sometimes you need to display activity on the text console to inform
|
26
26
|
the user that the program is actually doing something. Be funny with a lot predefined
|
27
27
|
sets or make you own widget to display an animation text during a long-running process
|