![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
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.
Inspired by Chris Wanstrath's Choice, Spinning Cursor provides you with a sexy DSL for easy use of the library.
As easy as RubyGems:
$ gem install spinning_cursor
It's so simple it hurts!
require 'spinning_cursor' # you'll definitely need this bit
SpinningCursor.run do
banner "An amazing task is happening"
type :spinner
action do
# Zzz
sleep 10
end
message "Huh?! I'm awake!"
end
# [OUPUT]
# The cursor can't be shown but it would look like this:
# An amazing task is happening \ <= that's the 'cursor', it animates!
#
# Huh?! I'm awake!
# => {:started=>2012-04-10 17:01:07 +0100,
# :finished=>2012-04-10 17:01:17 +0100, :elapsed=>10.000513}
It's as easy as that!
banner
- This displays before the cursor. Defaults to "Loading".type
- The type of cursor (currently only :dots
and :spinner
).
Defaults to :spinner
.action
- The stuff you want to do whilst the cursor is spinning.message
- The message you want to show the user once the task is finished.
Defaults to "Done".delay
- Sets the delay in seconds between the frames of the animation.
Defaults depend on type of cursor animation (spinner 0.5s, dots 1s)output
- Sets how to display program output during cursor animation
(:inline
or :at_stop
).
Defaults to :inline
.Fear not, lost soul. There are two ways to prevent messy code as a result of the block.
action my_awesome_method
The first option is the simplest, but the second isn't so bad either. It's pretty simple, just do:
SpinningCursor.run do
banner "Loading"
type :dots
message "Done"
end
# Complex code that takes a long time
sleep 20
SpinningCursor.stop
Notice the absence of the action
option. The run method will only keep
the cursor running if an action
block isn't passed to it.
Do you? Well that's easy too (I'm starting to see a pattern here...)!
Use the set_message
method to change the message during the execution:
SpinningCursor.run do
banner "Calculating your favour colour, please wait"
type :dots
action do
sleep 20
if you_are_romantic
SpinningCursor.set_message "Your favourite colour is pink."
elsif you_are_peaceful
SpinningCursor.set_message "Your favourite colour is blue."
else
SpinningCursor.set_message "Can't figure it out =[!"
end
end
end
You get the message. (see what I did there?)
Yay! All you need is the new version of the gem (v0.1.0) and you can change
the banner message in the same way you would the finish message, using
set_banner
:
SpinningCursor.run do
banner "Stealing your food"
action do
sleep 10
SpinningCursor.set_banner "Now eating your food"
sleep 10
end
message "Thanks for the free food!"
end
Spinning Cursor will return a hash with the execution times. If an action
block is passed, it will be returned in the SpinningCursor.start
method.
Otherwise, it will be returned once you call SpinningCursor.stop
. You can
also get it with SpinningCursor.get_exec_time
.
The hash contains the following, self-explanatory keys:
:started
:finished
:elapsed
There isn't much this library should do, but a good suggestion is always welcome. Make sure to use the issue tracker on GitHub to make suggestions -- and fork & pull request if you want to implement it yourself, of course.
Spinning Cursor could always use some cooler animated cursors, you can add a cursor easily by creating a new method in the Cursor class that runs your custom cursor.
I'm pretty new to Ruby and this is my first attempt at a DSL. If you could have a look at the source and offer any optimisations I would be greatly indebted to you. It's a learning experience for me!
A massive thanks to those who have taken some time out to help improve Spinning Cursor!
FAQs
Unknown package
We found that spinning_cursor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.