Module: ActiverecordWithProgress
- Defined in:
- lib/activerecord_with_progress.rb,
lib/activerecord_with_progress/version.rb,
lib/activerecord_with_progress/activerecord_relation.rb
Defined Under Namespace
Modules: ActiverecordRelation
Constant Summary collapse
- DEFAULT_FORMAT =
Default progress bar format (see ruby-progressbar documentation).
"\e[36m%a \e[35m%e\e[0m \e[34m[\e[1m%B\e[0;34m] %c/%C %p%%\e[0m"
- VERSION =
"0.1.1"
Class Attribute Summary collapse
-
.progress_format ⇒ Object
Set or retrieve the format string used for progress bars.
Class Method Summary collapse
-
.create(options = nil) ⇒ Object
Creates a progress bar with our own default options and format, unless overrided by the options hash.
Class Attribute Details
.progress_format ⇒ Object
Set or retrieve the format string used for progress bars.
12 13 14 |
# File 'lib/activerecord_with_progress.rb', line 12 def progress_format @progress_format end |
Class Method Details
.create(options = nil) ⇒ Object
Creates a progress bar with our own default options and format, unless overrided by the options hash. Also works around Spring’s removal of IO.console for Rails apps that use Spring by setting :length.
17 18 19 20 21 22 23 24 |
# File 'lib/activerecord_with_progress.rb', line 17 def create(=nil) opts = { format: progress_format, length: (IO.console.winsize[1] rescue nil) || ENV['columns'] || `tput cols` } opts.merge!() if .is_a?(Hash) ProgressBar.create(opts) end |