lib/whirly.rb in whirly-0.1.0 vs lib/whirly.rb in whirly-0.1.1

- old
+ new

@@ -28,13 +28,14 @@ interval: nil, spinner: "whirly", use_color: defined?(Paint), color_change_rate: 30, status: nil, - hide_cursor: true) - # only actviate if we are on a real terminal - return false unless stream.tty? + hide_cursor: true, + non_tty: false) + # only actviate if we are on a real terminal (or forced) + return false unless stream.tty? || non_tty # ensure cursor is visible after exit at_exit{ @stream.print CLI_COMMANDS[:show_cursor] } if !defined?(@enabled) && hide_cursor # only activate once @@ -43,10 +44,14 @@ # save options and preprocess @enabled = true @paused = false @stream = stream @status = status - @spinner = SPINNERS[spinner.to_s] + if spinner.is_a? Hash + @spinner = spinner + else + @spinner = SPINNERS[spinner.to_s] + end raise(ArgumentError, "Whirly: Invalid spinner given") if !@spinner || (!@spinner["frames"] && !@spinner["proc"]) @hide_cursor = hide_cursor @interval = (interval || @spinner["interval"] || 100) * 0.001 @frames = @spinner["frames"] && @spinner["frames"].cycle @proc = @spinner["proc"]