spinning_cursor 0.1.0.rc1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --markup-provider=redcarpet
2
+ --markup=markdown
data/CHANGELOG ADDED
@@ -0,0 +1,18 @@
1
+ CHANGELOG
2
+ ===============================================================================
3
+
4
+ v0.1.0 (2012-04-10)
5
+ - First non-pre release
6
+ - Exceptions in the task cause the cursor to stop and the exception is shown
7
+ - Added the ability to change the banner message in the task block, allowing
8
+ you to update the user on the ongoing task.
9
+ - Returns a hash containing the start, finish and elapsed times
10
+
11
+ v0.1.0.rc1 (2012-04-09)
12
+ - Initial release
13
+ - Features:
14
+ - A sexy DSL
15
+ - Set the loading message, type of spinner and finished message
16
+ - Pass in an action block to do the whole start stop loop, or don't and
17
+ call stop yourself
18
+ - Change the finish message within your task block
data/Gemfile CHANGED
@@ -7,7 +7,9 @@ source "http://rubygems.org"
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
  group :development do
9
9
  gem "shoulda", ">= 0"
10
- gem "rdoc", "~> 3.12"
11
10
  gem "bundler", "~> 1.1.3"
12
11
  gem "jeweler", "~> 1.8.3"
12
+ gem "yard"
13
+ gem "redcarpet"
14
+ gem "github-markup"
13
15
  end
data/Gemfile.lock CHANGED
@@ -2,6 +2,7 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  git (1.2.5)
5
+ github-markup (0.7.2)
5
6
  jeweler (1.8.3)
6
7
  bundler (~> 1.0)
7
8
  git (>= 1.2.5)
@@ -11,17 +12,21 @@ GEM
11
12
  rake (0.9.2.2)
12
13
  rdoc (3.12)
13
14
  json (~> 1.4)
15
+ redcarpet (2.1.1)
14
16
  shoulda (3.0.1)
15
17
  shoulda-context (~> 1.0.0)
16
18
  shoulda-matchers (~> 1.0.0)
17
19
  shoulda-context (1.0.0)
18
20
  shoulda-matchers (1.0.0)
21
+ yard (0.7.5)
19
22
 
20
23
  PLATFORMS
21
24
  ruby
22
25
 
23
26
  DEPENDENCIES
24
27
  bundler (~> 1.1.3)
28
+ github-markup
25
29
  jeweler (~> 1.8.3)
26
- rdoc (~> 3.12)
30
+ redcarpet
27
31
  shoulda
32
+ yard
data/README.md ADDED
@@ -0,0 +1,179 @@
1
+ # Spinning Cursor
2
+
3
+ Spinning Cursor is a flexible DSL that allows you to easily produce a
4
+ customizable waiting/loading message for your Ruby command line program.
5
+
6
+ Beautifully keep your users informed with what your program is doing when a
7
+ more complex solution, such as a progress bar, doesn't fit your needs.
8
+
9
+ Inspired by Chris Wanstrath's
10
+ [Choice](http://https://github.com/defunkt/choice), Spinning Cursor provides
11
+ you with a _sexy_ DSL for easy use of the library.
12
+
13
+ ## Installation
14
+
15
+ As easy as RubyGems:
16
+
17
+ ```
18
+ $ gem install spinning_cursor
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ _It's so simple it hurts!_
24
+
25
+ ### Example
26
+
27
+ ```ruby
28
+ require 'spinning_cursor' # you'll definitely need this bit
29
+
30
+ SpinningCursor.start do
31
+ banner "An amazing task is happening"
32
+ type :spinner
33
+ action do
34
+ # Zzz
35
+ sleep 10
36
+ end
37
+ message "Huh?! I'm awake!"
38
+ end
39
+
40
+ # [OUPUT]
41
+ # The cursor can't be shown but it would look like this:
42
+ # An amazing task is happening \ <= that's the 'cursor', it animates!
43
+ #
44
+ # Huh?! I'm awake!
45
+ # => {:started=>2012-04-10 17:01:07 +0100,
46
+ # :finished=>2012-04-10 17:01:17 +0100, :elapsed=>10.000513}
47
+ ```
48
+
49
+ It's as easy as that!
50
+
51
+ ### Options
52
+
53
+ * `banner` - This displays before the cursor. Defaults to "Loading".
54
+ * `type` - The type of spinner (currently only `:dots` and `:spinner`).
55
+ Defaults to `:spinner`.
56
+ * `action` - The stuff you want to do whilst the spinner is spinning.
57
+ * `message` - The message you want to show the user once the task is finished.
58
+ Defaults to "Done".
59
+
60
+ ### But the action block would get too messy!
61
+
62
+ Fear not, lost soul. There are two ways to prevent messy code as a result of
63
+ the block.
64
+
65
+ 1. Call a method e.g. `action my_awesome_method`
66
+ 2. Start and stop the cursor manually
67
+
68
+ The first option is the simplest, but the second isn't so bad either.
69
+ It's pretty simple, just do:
70
+
71
+ ```ruby
72
+ SpinningCursor.start do
73
+ banner "Loading"
74
+ type :dots
75
+ message "Done"
76
+ end
77
+
78
+ # Complex code that takes a long time
79
+ sleep 20
80
+
81
+ SpinningCursor.stop
82
+ ```
83
+
84
+ **Notice** the absence of the `action` option. The start method will only keep
85
+ the cursor running if an `action` block isn't passed into it.
86
+
87
+ ### I want to be able to change the finish message conditionally!
88
+
89
+ Do you? Well that's easy too (I'm starting to see a pattern here...)!
90
+
91
+ Use the `set_message` method to change the message during the execution:
92
+
93
+ ```ruby
94
+ SpinningCursor.start do
95
+ banner "Calculating your favour colour, please wait"
96
+ type :dots
97
+ action do
98
+ sleep 20
99
+ if you_are_romantic
100
+ SpinningCursor.set_message "Your favourite colour is pink."
101
+ elsif you_are_peaceful
102
+ SpinningCursor.set_message "Your favourite colour is blue."
103
+ else
104
+ SpinningCursor.set_message "Can't figure it out =[!"
105
+ end
106
+ end
107
+ end
108
+ ```
109
+
110
+ You get the message. (see what I did there?)
111
+
112
+ ### I need to change the banner message during the task
113
+
114
+ Yay! All you need is the new version of the gem (v1.0.1) and you can change
115
+ the banner message in the same way you would the finish message, using
116
+ `set_banner`:
117
+
118
+ ```ruby
119
+ SpinningCursor.start do
120
+ banner "Stealing your food"
121
+ action do
122
+ sleep 10
123
+ SpinningCursor.set_banner "Now eating your food"
124
+ sleep 10
125
+ end
126
+ message "Thanks for the free food!"
127
+ end
128
+ ```
129
+
130
+ ### Timing the execution
131
+
132
+ Spinning Cursor will return a hash with the execution times. If an action
133
+ block is passed, it will be returned in the `SpinningCursor.start` method.
134
+ Otherwise, it will be returned once you call `SpinningCursor.stop`. You can
135
+ also get it with `SpinningCursor.get_exec_time`.
136
+
137
+ The hash contains the following, self-explanatory keys:
138
+
139
+ * `:started`
140
+ * `:finished`
141
+ * `:elapsed`
142
+
143
+ ## Contributing to Spinning Cursor
144
+
145
+ ### What to contribute
146
+
147
+ #### Suggestions
148
+
149
+ There isn't much this library should do, but a good suggestion is always
150
+ welcome. Make sure to use the issue track on GitHub to make suggestions -- and
151
+ fork & pull request if you want to implement it yourself, of course.
152
+
153
+ #### More Cursors!
154
+
155
+ Spinning Cursor could always use some cooler animated cursors, you can add a
156
+ cursor easily by creating a new method in the Cursor class that runs your
157
+ custom cursor.
158
+
159
+ #### Code optimisations
160
+
161
+ I'm pretty new to Ruby and this is my first attempt at a DSL. If you could
162
+ have a look at the source and offer any optimisations I would be greatly
163
+ indebted to you. It's a learning experience for me!
164
+
165
+ ### How to contribute
166
+
167
+ * Check out the latest master to make sure the feature hasn't been implemented
168
+ or the bug hasn't been fixed yet.
169
+ * Check out the issue tracker to make sure someone already hasn't requested it
170
+ and/or contributed it.
171
+ * Fork the project.
172
+ * Start a feature/bugfix branch.
173
+ * Commit and push until you are happy with your contribution.
174
+ * Make sure to add tests for it. This is important so I don't break it in a
175
+ future version unintentionally.
176
+ * Please try not to mess with the Rakefile, version, or history. If you want
177
+ to have your own version, or is otherwise necessary, that is fine, but
178
+ please isolate to its own commit so I can cherry-pick around it.
179
+
data/Rakefile CHANGED
@@ -17,9 +17,8 @@ Jeweler::Tasks.new do |gem|
17
17
  gem.name = "spinning_cursor"
18
18
  gem.homepage = "http://github.com/Prydonius/spinning_cursor"
19
19
  gem.license = "MIT"
20
- gem.summary = "A loader for command line tools in Ruby."
21
- gem.description = "Spinning Cursor is a tiny library that allows you to easily produce a
22
- waiting/loading message for your Ruby command line program."
20
+ gem.summary = "A DSL for adding animated loaders to your Ruby command line application."
21
+ gem.description = "Spinning Cursor is a flexible DSL that allows you to easily produce a customizable waiting/loading message for your Ruby command line program. Beautifully keep your users informed with what your program is doing when a more complex solution, such as a progress bar, doesn't fit your needs."
23
22
  gem.email = "adnan@prydoni.us"
24
23
  gem.authors = ["Adnan Abdulhussein"]
25
24
  # dependencies defined in Gemfile
@@ -34,16 +33,3 @@ Rake::TestTask.new(:test) do |test|
34
33
  end
35
34
 
36
35
  task :default => :test
37
-
38
- require 'rdoc/task'
39
- Rake::RDocTask.new do |rdoc|
40
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
41
-
42
- rdoc.rdoc_dir = 'rdoc'
43
- rdoc.title = "spinning_cursor #{version}"
44
- rdoc.rdoc_files.include('README*')
45
- rdoc.rdoc_files.include('LICENSE*')
46
- rdoc.rdoc_files.include('VERSION')
47
- rdoc.rdoc_files.include('lib/**/*.rb')
48
- rdoc.main = "README.rdoc"
49
- end
data/TODO ADDED
File without changes
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0.rc1
1
+ 0.1.0
@@ -17,30 +17,54 @@ module SpinningCursor
17
17
  end
18
18
 
19
19
  @@parsed = Parser.new(block)
20
- @@curs = Thread.new {
21
- Cursor.new((@@parsed.type nil), (@@parsed.banner nil))
22
- }
20
+ @@cursor = Cursor.new(@@parsed.banner nil)
21
+ @@curs = Thread.new { @@cursor.spin(@@parsed.type nil) }
22
+
23
+ # Time the execution
24
+ @@start = Time.now
25
+
23
26
  if @@parsed.action.nil?
24
27
  return
25
28
  end
26
- @@parsed.originator.instance_eval &@@parsed.action
27
- stop
29
+ # The action
30
+ begin
31
+ @@parsed.originator.instance_eval &@@parsed.action
32
+ rescue
33
+ set_message "Task failed..."
34
+ ensure
35
+ return stop
36
+ end
28
37
  end
29
38
 
30
39
  #
31
40
  # Kills the cursor thread and prints the finished message
41
+ # Returns execution time
32
42
  #
33
43
  def stop
34
- @@curs.kill
35
- reset_line
36
- puts (@@parsed.message nil)
44
+ begin
45
+ @@end = Time.now
46
+ @@elapsed = @@end - @@start
47
+
48
+ @@curs.kill
49
+ reset_line
50
+ puts (@@parsed.message nil)
51
+
52
+ # Return execution time
53
+ get_exec_time
54
+ rescue NameError
55
+ raise CursorNotRunning.new "Can't stop, no cursor running."
56
+ end
37
57
  end
38
58
 
39
59
  #
40
60
  # Determines whether the cursor thread is still running
41
61
  #
42
62
  def alive?
43
- @@curs.alive?
63
+ if not defined? @@curs
64
+ return false
65
+ else
66
+ @@curs.alive?
67
+ end
44
68
  end
45
69
 
46
70
  #
@@ -48,6 +72,38 @@ module SpinningCursor
48
72
  # non-deterministic output)
49
73
  #
50
74
  def set_message(msg)
51
- @@parsed.message msg
75
+ begin
76
+ @@parsed.message msg
77
+ rescue NameError
78
+ raise CursorNotRunning.new "Cursor isn't running... are you sure " +
79
+ "you're calling this from an action block?"
80
+ end
52
81
  end
82
+
83
+ #
84
+ # Sets the banner message during execution
85
+ #
86
+ def set_banner(banner)
87
+ begin
88
+ @@cursor.banner = banner
89
+ rescue NameError
90
+ raise CursorNotRunning.new "Cursor isn't running... are you sure " +
91
+ "you're calling this from an action block?"
92
+ end
93
+ end
94
+
95
+ #
96
+ # Retrieves execution time information
97
+ #
98
+ def get_exec_time
99
+ begin
100
+ return { :started => @@start, :finished => @@end,
101
+ :elapsed => @@elapsed }
102
+ rescue NameError
103
+ raise NoTaskError.new "An execution hasn't started or finished."
104
+ end
105
+ end
106
+
107
+ class NoTaskError < Exception ; end
108
+ class CursorNotRunning < NoTaskError ; end
53
109
  end
@@ -1,10 +1,11 @@
1
1
  module SpinningCursor
2
2
  if RUBY_PLATFORM =~ /(win|w)32$/
3
+ # DOS
3
4
  # Contains a string to clear the line in the shell
4
5
  CLR = " \r"
5
- # Haven't yet found a good solution for Windows...
6
6
  else
7
7
  # Unix
8
+ # Contains a string to clear the line in the shell
8
9
  CLR = "\e[0K"
9
10
  end
10
11
 
@@ -19,16 +20,28 @@ module SpinningCursor
19
20
  # This class contains the cursor types (and their helper methods)
20
21
  #
21
22
  class Cursor
23
+ attr_accessor :banner
24
+
22
25
  #
23
- # Start the printing
26
+ # As of v0.1.0: only initializes the cursor class, use the print
27
+ # method to start the printing. Takes only the banner argument as
28
+ # a result of this.
24
29
  #
25
- def initialize(type = :spinner, banner = "Loading")
30
+ def initialize(banner = "Loading")
26
31
  @banner = banner
32
+ end
33
+
34
+ #
35
+ # Takes a cursor type symbol and starts the printing
36
+ #
37
+ def spin(type = :spinner)
27
38
  $stdout.sync = true
28
39
  print @banner
29
40
  send type
30
41
  end
31
42
 
43
+ private
44
+
32
45
  #
33
46
  # Prints three dots and clears the line
34
47
  #
@@ -41,6 +41,8 @@ module SpinningCursor
41
41
  end
42
42
  end
43
43
 
44
+ private
45
+
44
46
  #
45
47
  # Pass any other methods to the calling class
46
48
  #
@@ -0,0 +1,74 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "spinning_cursor"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Adnan Abdulhussein"]
12
+ s.date = "2012-04-10"
13
+ s.description = "Spinning Cursor is a flexible DSL that allows you to easily produce a customizable waiting/loading message for your Ruby command line program. Beautifully keep your users informed with what your program is doing when a more complex solution, such as a progress bar, doesn't fit your needs."
14
+ s.email = "adnan@prydoni.us"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md",
18
+ "TODO"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".yardopts",
23
+ "CHANGELOG",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE.txt",
27
+ "README.md",
28
+ "Rakefile",
29
+ "TODO",
30
+ "VERSION",
31
+ "lib/spinning_cursor.rb",
32
+ "lib/spinning_cursor/cursor.rb",
33
+ "lib/spinning_cursor/parser.rb",
34
+ "spinning_cursor.gemspec",
35
+ "test/helper.rb",
36
+ "test/test_cursors.rb",
37
+ "test/test_exceptions.rb",
38
+ "test/test_parser.rb",
39
+ "test/test_spinning_cursor.rb"
40
+ ]
41
+ s.homepage = "http://github.com/Prydonius/spinning_cursor"
42
+ s.licenses = ["MIT"]
43
+ s.require_paths = ["lib"]
44
+ s.rubygems_version = "1.8.21"
45
+ s.summary = "A DSL for adding animated loaders to your Ruby command line application."
46
+
47
+ if s.respond_to? :specification_version then
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
52
+ s.add_development_dependency(%q<bundler>, ["~> 1.1.3"])
53
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
54
+ s.add_development_dependency(%q<yard>, [">= 0"])
55
+ s.add_development_dependency(%q<redcarpet>, [">= 0"])
56
+ s.add_development_dependency(%q<github-markup>, [">= 0"])
57
+ else
58
+ s.add_dependency(%q<shoulda>, [">= 0"])
59
+ s.add_dependency(%q<bundler>, ["~> 1.1.3"])
60
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
61
+ s.add_dependency(%q<yard>, [">= 0"])
62
+ s.add_dependency(%q<redcarpet>, [">= 0"])
63
+ s.add_dependency(%q<github-markup>, [">= 0"])
64
+ end
65
+ else
66
+ s.add_dependency(%q<shoulda>, [">= 0"])
67
+ s.add_dependency(%q<bundler>, ["~> 1.1.3"])
68
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
69
+ s.add_dependency(%q<yard>, [">= 0"])
70
+ s.add_dependency(%q<redcarpet>, [">= 0"])
71
+ s.add_dependency(%q<github-markup>, [">= 0"])
72
+ end
73
+ end
74
+
data/test/test_cursors.rb CHANGED
@@ -5,7 +5,7 @@ class TestSpinningCursorCursor < Test::Unit::TestCase
5
5
  should "reset line after printing three dots" do
6
6
  capture_stdout do |out|
7
7
  dots = Thread.new do
8
- SpinningCursor::Cursor.new :dots, ""
8
+ SpinningCursor::Cursor.new("").spin :dots
9
9
  end
10
10
  sleep 5
11
11
  dots.kill
@@ -20,7 +20,7 @@ class TestSpinningCursorCursor < Test::Unit::TestCase
20
20
  should "cycle through correctly" do
21
21
  capture_stdout do |out|
22
22
  spinner = Thread.new do
23
- SpinningCursor::Cursor.new :spinner, ""
23
+ SpinningCursor::Cursor.new("").spin :spinner
24
24
  end
25
25
  sleep 0.1
26
26
  assert_equal "|", out.string
@@ -0,0 +1,26 @@
1
+ require 'helper'
2
+
3
+ class TestSpinningCursor < Test::Unit::TestCase
4
+ context "API" do
5
+ should "raise CursorNotRunning error for set_message, set_banner, and
6
+ stop methods" do
7
+ assert_raise SpinningCursor::CursorNotRunning do
8
+ SpinningCursor.set_message "Hi!"
9
+ end
10
+
11
+ assert_raise SpinningCursor::CursorNotRunning do
12
+ SpinningCursor.set_banner "Hi!"
13
+ end
14
+
15
+ assert_raise SpinningCursor::CursorNotRunning do
16
+ SpinningCursor.stop
17
+ end
18
+ end
19
+
20
+ should "raise NoTaskError when getting execution time if no task ran" do
21
+ assert_raise SpinningCursor::NoTaskError do
22
+ SpinningCursor.get_exec_time
23
+ end
24
+ end
25
+ end
26
+ end
@@ -54,5 +54,50 @@ class TestSpinningCursor < Test::Unit::TestCase
54
54
  assert_equal true, (out.string.end_with? "Failed!\n")
55
55
  end
56
56
  end
57
+
58
+ should "stop and display error if an unmanaged exception is thrown" do
59
+ capture_stdout do |out|
60
+ SpinningCursor.start do
61
+ action do
62
+ raise "An exception!"
63
+ end
64
+ end
65
+
66
+ assert_equal true, (out.string.end_with? "Task failed...\n")
67
+ end
68
+ end
69
+
70
+ should "not stop if an exception is handled" do
71
+ capture_stdout do |out|
72
+ SpinningCursor.start do
73
+ action do
74
+ begin
75
+ raise "An exception!"
76
+ rescue
77
+ # rescued!
78
+ end
79
+ end
80
+ end
81
+
82
+ assert_equal true, (out.string.end_with? "Done\n")
83
+ end
84
+ end
85
+
86
+ should "allow you to change the banner" do
87
+ capture_stdout do |out|
88
+ SpinningCursor.start do
89
+ action do
90
+ # Have to give it time to print the banners
91
+ sleep 0.1
92
+ assert_equal true, (out.string.include? "Loading")
93
+ sleep 0.1
94
+ SpinningCursor.set_banner "Finishing up"
95
+ sleep 0.5
96
+ assert_equal true, (out.string.include? "Finishing up")
97
+ sleep 0.1
98
+ end
99
+ end
100
+ end
101
+ end
57
102
  end
58
103
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spinning_cursor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.rc1
5
- prerelease: 6
4
+ version: 0.1.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Adnan Abdulhussein
@@ -28,13 +28,13 @@ dependencies:
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
- name: rdoc
31
+ name: bundler
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: '3.12'
37
+ version: 1.1.3
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,15 +42,15 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: '3.12'
45
+ version: 1.1.3
46
46
  - !ruby/object:Gem::Dependency
47
- name: bundler
47
+ name: jeweler
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
51
  - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: 1.1.3
53
+ version: 1.8.3
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,46 +58,84 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 1.1.3
61
+ version: 1.8.3
62
62
  - !ruby/object:Gem::Dependency
63
- name: jeweler
63
+ name: yard
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
- - - ~>
67
+ - - ! '>='
68
68
  - !ruby/object:Gem::Version
69
- version: 1.8.3
69
+ version: '0'
70
70
  type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
- - - ~>
75
+ - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
- version: 1.8.3
78
- description: ! 'Spinning Cursor is a tiny library that allows you to easily produce
79
- a
80
-
81
- waiting/loading message for your Ruby command line program.'
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: redcarpet
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: github-markup
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: Spinning Cursor is a flexible DSL that allows you to easily produce a
111
+ customizable waiting/loading message for your Ruby command line program. Beautifully
112
+ keep your users informed with what your program is doing when a more complex solution,
113
+ such as a progress bar, doesn't fit your needs.
82
114
  email: adnan@prydoni.us
83
115
  executables: []
84
116
  extensions: []
85
117
  extra_rdoc_files:
86
118
  - LICENSE.txt
87
- - README.rdoc
119
+ - README.md
120
+ - TODO
88
121
  files:
89
122
  - .document
123
+ - .yardopts
124
+ - CHANGELOG
90
125
  - Gemfile
91
126
  - Gemfile.lock
92
127
  - LICENSE.txt
93
- - README.rdoc
128
+ - README.md
94
129
  - Rakefile
130
+ - TODO
95
131
  - VERSION
96
132
  - lib/spinning_cursor.rb
97
133
  - lib/spinning_cursor/cursor.rb
98
134
  - lib/spinning_cursor/parser.rb
135
+ - spinning_cursor.gemspec
99
136
  - test/helper.rb
100
137
  - test/test_cursors.rb
138
+ - test/test_exceptions.rb
101
139
  - test/test_parser.rb
102
140
  - test/test_spinning_cursor.rb
103
141
  homepage: http://github.com/Prydonius/spinning_cursor
@@ -115,17 +153,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
115
153
  version: '0'
116
154
  segments:
117
155
  - 0
118
- hash: 837562280990932011
156
+ hash: 1396887062628828548
119
157
  required_rubygems_version: !ruby/object:Gem::Requirement
120
158
  none: false
121
159
  requirements:
122
- - - ! '>'
160
+ - - ! '>='
123
161
  - !ruby/object:Gem::Version
124
- version: 1.3.1
162
+ version: '0'
125
163
  requirements: []
126
164
  rubyforge_project:
127
165
  rubygems_version: 1.8.21
128
166
  signing_key:
129
167
  specification_version: 3
130
- summary: A loader for command line tools in Ruby.
168
+ summary: A DSL for adding animated loaders to your Ruby command line application.
131
169
  test_files: []
data/README.rdoc DELETED
@@ -1,111 +0,0 @@
1
- == Spinning Cursor
2
-
3
- Spinning Cursor is a tiny library that allows you to easily produce a
4
- waiting/loading message for your Ruby command line program, when a more
5
- complex solution, such as a progress bar, doesn't fit your needs.
6
-
7
- Inspired by Chris Wanstrath's Choice[http://https://github.com/defunkt/choice],
8
- Spinning Cursor provides you with a DSL for easy use of the library.
9
-
10
- == Installation
11
-
12
- As easy as RubyGems:
13
-
14
- $ gem install spinning_cursor --pre
15
-
16
- == Usage
17
-
18
- It's so simple it hurts!
19
-
20
- === Example
21
-
22
- # my_awesome_ruby_class.rb
23
-
24
- require 'spinning_cursor' # you'll definitely need this bit
25
-
26
- class MyAwesomeRubyClass
27
- def amazing_task
28
- SpinningCursor.start do
29
- banner "An amazing task is happening"
30
- type :spinner
31
- action do
32
- # Zzz
33
- sleep 10
34
- end
35
- message "Huh?! I'm awake!"
36
- end
37
- end
38
- end
39
-
40
- great_instance = MyAwesomeRubyClass.new
41
- great_instance.amazing_task
42
-
43
- It's as easy as that!
44
-
45
- === Options
46
-
47
- * +banner+ - This displays before the cursor. Defaults to "Loading".
48
- * +type+ - The type of spinner (currently only +:dots+ and +:spinner+).
49
- Defaults to +:spinner+.
50
- * +action+ - The stuff you want to do whilst the spinner is spinning.
51
- * +message+ - The message you want to show the user once the task is finished.
52
- Defaults to "Done".
53
-
54
- === But the +action+ block would get too messy!
55
-
56
- Fear not, lost soul. There are two ways to prevent messy code as a result of
57
- the block.
58
-
59
- 1. Call a method
60
- 2. Start and stop the cursor manually
61
-
62
- The first option is the simplest, but the second isn't so bad either.
63
- It's pretty simple, just do:
64
-
65
- SpinningCursor.start do
66
- banner "Loading"
67
- type :dots
68
- message "Done"
69
- end
70
-
71
- # Complex code that takes a long time
72
- sleep 20
73
-
74
- SpinningCursor.stop
75
-
76
- *Notice* the absense of the +action+ option. The start method will only keep
77
- the cursor running if an +action+ block isn't passed into it.
78
-
79
- === I want to be able to change the finish message conditionally!
80
-
81
- Do you? Well that's easy too (I'm starting to see a pattern here...)!
82
-
83
- Use the +set_message+ method to change the message during the execution:
84
-
85
- SpinningCursor.start do
86
- banner "Calculating your favour colour, please wait"
87
- type :dots
88
- action do
89
- sleep 20
90
- if you_are_romantic
91
- SpinningCursor.set_message "Your favourite colour is pink."
92
- elsif you_are_peaceful
93
- SpinningCursor.set_message "Your favourite colour is blue."
94
- else
95
- SpinningCursor.set_message "Can't figure it out =[!"
96
- end
97
- end
98
- end
99
-
100
- You get the +message+. (see what I did there?)
101
-
102
- == Contributing to Spinning Cursor
103
-
104
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
105
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
106
- * Fork the project.
107
- * Start a feature/bugfix branch.
108
- * Commit and push until you are happy with your contribution.
109
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
110
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
111
-