indicator 0.1.1 → 0.1.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 CHANGED
@@ -8,10 +8,10 @@ widget to display an animation text during a long-running process in your consol
8
8
 
9
9
 
10
10
  =Installation
11
- From the command line.
11
+ ==From the command line.
12
12
  gem install indicator
13
13
 
14
- Using Gemfile.
14
+ ==Using Gemfile.
15
15
 
16
16
  1 Add to your application Gemfile
17
17
  gem 'indicator'
@@ -20,7 +20,7 @@ Using Gemfile.
20
20
  bundle install
21
21
 
22
22
  =Usage
23
- Animated
23
+ ==Animated
24
24
 
25
25
  Indicator::spin do
26
26
  10.times do
@@ -28,7 +28,7 @@ Animated
28
28
  end
29
29
  end
30
30
 
31
- On demand update
31
+ ==On demand update
32
32
 
33
33
  Indicator::spin(:ondemand => true) do |spinner|
34
34
  10.times do
@@ -37,7 +37,7 @@ On demand update
37
37
  end
38
38
  end
39
39
 
40
- Manual control
40
+ ==Manual control
41
41
 
42
42
  spinner = Indicator.spinner
43
43
  10.times do
@@ -46,7 +46,7 @@ Manual control
46
46
  end
47
47
  spinner.clean
48
48
 
49
- Predefined sets
49
+ ==Predefined sets
50
50
  Indicator::spin :set => :p do
51
51
  10.times do
52
52
  sleep 0.5
@@ -55,7 +55,9 @@ Predefined sets
55
55
 
56
56
  Available sets: :x :< :> :V :dots :bars :p :bqpd :-
57
57
 
58
- Custom set
58
+ UNICODE extra sets: :arrows :box :braile
59
+
60
+ ==Custom set
59
61
  Indicator::spin :frames => %w{ * + } do
60
62
  10.times do
61
63
  sleep 0.5
data/lib/indicator.rb CHANGED
@@ -1,60 +1,2 @@
1
- # encoding: utf-8
2
- require File.expand_path('../indicator/spin', __FILE__)
1
+ require File.expand_path('../indicator/spinner', __FILE__)
3
2
 
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
@@ -0,0 +1,68 @@
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
+
30
+ when :arrows
31
+ %w{ ← ↖ ↑ ↗ → ↘ ↓ ↙ ← ↖ ↑ ↗ → ↘ ↓ ↙ }
32
+ when :box
33
+ %w{ ┤ ┘ ┴ └ ├ ┌ ┬ ┐ ┤ ┘ ┴ └ ├ ┌ ┬ ┐ }
34
+ when :braile
35
+ %w{ ⣾ ⣽ ⣻ ⢿ ⡿ ⣟ ⣯ ⣷ ⠁ ⠂ ⠄ ⡀ ⢀ ⠠ ⠐ ⠈ }
36
+
37
+ else
38
+ %w{ | / - \\ }
39
+ end
40
+ end
41
+
42
+ def spinner opts={}
43
+ opts[:frames] = set opts[:set] unless opts[:frames]
44
+ Indicator::Spin.new opts
45
+ end
46
+
47
+ def spin opts={}, &blk
48
+ spinner = opts[:spinner] || self.spinner(opts)
49
+ noclean = opts[:noclean] || false
50
+ ondemand = opts[:ondemand] || false
51
+
52
+ if ondemand
53
+ yield spinner
54
+ else
55
+ t = Thread.new { yield spinner }
56
+
57
+ while t.alive?
58
+ spinner.spinning
59
+ end
60
+
61
+ t.join
62
+ end
63
+
64
+ spinner.clean unless noclean
65
+ end
66
+
67
+ end
68
+ end
@@ -1,3 +1,3 @@
1
1
  module Indicator
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-02-05 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &8710280 !ruby/object:Gem::Requirement
16
+ requirement: &14306040 !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: *8710280
24
+ version_requirements: *14306040
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
@@ -33,6 +33,7 @@ extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
35
  - lib/indicator/version.rb
36
+ - lib/indicator/spinner.rb
36
37
  - lib/indicator/spin.rb
37
38
  - lib/indicator.rb
38
39
  - MIT-LICENSE