indicator 1.0.0 → 1.0.2
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 +6 -2
- data/lib/indicator/spin.rb +12 -8
- data/lib/indicator/version.rb +1 -1
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -68,13 +68,15 @@ UNICODE extra sets: :arrows :box :braile
|
|
68
68
|
===Using count
|
69
69
|
Use int method to increment percent
|
70
70
|
|
71
|
-
Indicator::spin :count =>
|
71
|
+
Indicator::spin :count => 20 do |spin|
|
72
72
|
10.times do
|
73
|
-
spin.inc
|
73
|
+
spin.inc 2
|
74
74
|
sleep 0.2
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
+
Default increment is 1.
|
79
|
+
|
78
80
|
===Using count, pre-text and post-text
|
79
81
|
Indicator::spin :pre => "Work", :frames => [' ', '. ', '.. ', '...'], :count => 10, :post => ' in progress' do |spin|
|
80
82
|
10.times do
|
@@ -83,6 +85,8 @@ Use int method to increment percent
|
|
83
85
|
end
|
84
86
|
end
|
85
87
|
|
88
|
+
:pre_percent and :post_percent is also available.
|
89
|
+
|
86
90
|
===Change post-text
|
87
91
|
Indicator::spin :pre => "Work", :frames => [' ', '. ', '.. ', '...'], :count => 10 do |spin|
|
88
92
|
10.times do |i|
|
data/lib/indicator/spin.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module Indicator
|
3
3
|
class Spin
|
4
|
-
attr_accessor :pre, :post, :delay
|
4
|
+
attr_accessor :pre, :post, :pre_percent, :post_percent, :delay
|
5
5
|
|
6
6
|
def initialize opts={}
|
7
|
-
@frames
|
8
|
-
@delay
|
9
|
-
@pre
|
10
|
-
@post
|
11
|
-
@count
|
7
|
+
@frames = opts[:frames] || %w{ | / - \\ }
|
8
|
+
@delay = opts[:delay] || 0.1
|
9
|
+
@pre = opts[:pre] || ''
|
10
|
+
@post = opts[:post] || ''
|
11
|
+
@count = opts[:count] || nil
|
12
|
+
@pre_percent = opts[:pre_percent] || ''
|
13
|
+
@post_percent = opts[:post_percent] || ''
|
12
14
|
init
|
13
15
|
end
|
14
16
|
|
@@ -18,8 +20,8 @@ module Indicator
|
|
18
20
|
printf @spin
|
19
21
|
end
|
20
22
|
|
21
|
-
def inc
|
22
|
-
@current +=
|
23
|
+
def inc increment = 1
|
24
|
+
@current += increment
|
23
25
|
end
|
24
26
|
|
25
27
|
def spinning
|
@@ -42,7 +44,9 @@ module Indicator
|
|
42
44
|
@spin = @pre
|
43
45
|
@spin += @frames[0]
|
44
46
|
@frames.push @frames.shift
|
47
|
+
@spin += @pre_percent
|
45
48
|
@spin += sprintf(" %3.2f%", @current * 100.0 / @count) if @count
|
49
|
+
@spin += @post_percent
|
46
50
|
@spin += @post
|
47
51
|
end
|
48
52
|
|
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: 1.0.
|
4
|
+
version: 1.0.2
|
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-13 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &17460400 !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: *17460400
|
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
|