[DRE-commits] [ruby-progressbar] 01/05: Imported Upstream version 0.21.0
Jonas Genannt
jonas at brachium-system.net
Fri Jan 17 10:52:08 UTC 2014
This is an automated email from the git hooks/post-receive script.
hggh-guest pushed a commit to branch master
in repository ruby-progressbar.
commit 61b8c16961802a51cb50c5019c8c5ab3c502ebc2
Author: Jonas Genannt <jonas at brachium-system.net>
Date: Fri Jan 17 11:45:06 2014 +0100
Imported Upstream version 0.21.0
---
.gitignore | 1 +
.ruby-version | 1 +
.rvmrc | 1 -
.travis.yml | 2 --
Gemfile | 2 +-
Gemfile.lock | 4 ++--
README.rdoc | 15 +++++++++++---
checksums.yaml.gz | Bin 0 -> 266 bytes
lib/progressbar.rb | 14 +++++++++++--
metadata.yml | 57 ++++++++++++++++++++--------------------------------
progressbar.gemspec | 1 +
test/test.rb | 18 +++++++++++++----
12 files changed, 66 insertions(+), 50 deletions(-)
diff --git a/.gitignore b/.gitignore
index ff6447d..9121e4b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,3 +20,4 @@ rdoc
pkg
## PROJECT::SPECIFIC
+/.rake_t_cache
diff --git a/.ruby-version b/.ruby-version
new file mode 100644
index 0000000..227cea2
--- /dev/null
+++ b/.ruby-version
@@ -0,0 +1 @@
+2.0.0
diff --git a/.rvmrc b/.rvmrc
deleted file mode 100644
index 321f4db..0000000
--- a/.rvmrc
+++ /dev/null
@@ -1 +0,0 @@
-rvm 1.9.3 at progressbar
diff --git a/.travis.yml b/.travis.yml
index d702d57..116b1ff 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,7 +2,5 @@ rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- - rbx-2.0
- jruby
- - ruby-head
- ree
diff --git a/Gemfile b/Gemfile
index b304fa7..a2c4139 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,4 +1,4 @@
-source :rubygems
+source "https://rubygems.org"
# Specify your gem's dependencies in ruby-duration.gemspec
gemspec
diff --git a/Gemfile.lock b/Gemfile.lock
index bd0c9c6..bec5b04 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,10 +1,10 @@
PATH
remote: .
specs:
- progressbar (0.10.0)
+ progressbar (0.21.0)
GEM
- remote: http://rubygems.org/
+ remote: https://rubygems.org/
specs:
bluecloth (2.1.0)
minitest (2.2.2)
diff --git a/README.rdoc b/README.rdoc
index e3e32fa..b78622e 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -28,10 +28,16 @@ The latest version of Ruby/ProgressBar is available at
=> (ProgressBar: 0/100)
>> (1..100).each{|x| sleep(0.1); pbar.set(x)}; pbar.finish
test: 67% |oooooooooooooooooooooooooo | ETA: 00:00:03
+
+ >> ProgressBar.new("test", 100) do |pbar|
+ >> 100.times { sleep(0.1); pbar.inc }
+ >> end
+ test: 100% |oooooooooooooooooooooooooooooooooooooooo| Time: 00:00:10
+
== API
---- ProgressBar#new (title, total, out = STDERR)
+--- ProgressBar#new (title, total, out = STDERR, &block)
Display the initial progress bar and return a
ProgressBar object. ((|title|)) specifies the title,
and ((|total|)) specifies the total cost of processing.
@@ -41,6 +47,9 @@ The latest version of Ruby/ProgressBar is available at
more percent is proceeded or one or more seconds are
elapsed from the previous display.
+ It also accepts a block in case you prefer not needing
+ to .finish the bar (see example above).
+
--- ProgressBar#inc (step = 1)
Increase the internal counter by ((|step|)) and update
the display of the progress bar. Display the estimated
@@ -77,8 +86,8 @@ The latest version of Ruby/ProgressBar is available at
transfered bytes and transfer rate.
--- ProgressBar#long_running
- Use adaptative running average ton compute ETA, more effective for
- long-running jobs of jobs whose pseed may vary.
+ Use adaptative running average to compute ETA, more effective for
+ long-running jobs or jobs whose speed may vary.
ReverseProgressBar class is also available. The
diff --git a/checksums.yaml.gz b/checksums.yaml.gz
new file mode 100644
index 0000000..d215438
Binary files /dev/null and b/checksums.yaml.gz differ
diff --git a/lib/progressbar.rb b/lib/progressbar.rb
index 40bf55a..e05a0ed 100644
--- a/lib/progressbar.rb
+++ b/lib/progressbar.rb
@@ -10,7 +10,7 @@
#
class ProgressBar
- VERSION = "0.11.0"
+ VERSION = "0.21.0"
def initialize (title, total, out = STDERR)
@title = title
@@ -28,6 +28,10 @@ class ProgressBar
@format_arguments = [:title, :percentage, :bar, :stat]
clear
show
+ if block_given?
+ yield(self)
+ finish
+ end
end
attr_reader :title
@@ -156,7 +160,7 @@ private
DEFAULT_WIDTH = 80
def get_term_width
- if ENV['COLUMNS'] =~ /^\d+$/
+ term_width = if ENV['COLUMNS'] =~ /^\d+$/
ENV['COLUMNS'].to_i
elsif (RUBY_PLATFORM =~ /java/ || (!STDIN.tty? && ENV['TERM'])) && shell_command_exists?('tput')
`tput cols`.to_i
@@ -165,6 +169,12 @@ private
else
DEFAULT_WIDTH
end
+
+ if term_width > 0
+ term_width
+ else
+ DEFAULT_WIDTH
+ end
rescue
DEFAULT_WIDTH
end
diff --git a/metadata.yml b/metadata.yml
index 0e1afac..c823b7d 100644
--- a/metadata.yml
+++ b/metadata.yml
@@ -1,8 +1,7 @@
--- !ruby/object:Gem::Specification
name: progressbar
version: !ruby/object:Gem::Version
- version: 0.11.0
- prerelease:
+ version: 0.21.0
platform: ruby
authors:
- Satoru Takabayashi
@@ -10,102 +9,90 @@ authors:
autorequire:
bindir: bin
cert_chain: []
-date: 2012-04-10 00:00:00.000000000 Z
+date: 2013-09-13 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: bundler
requirement: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - '>='
- !ruby/object:Gem::Version
version: 1.0.0
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - '>='
- !ruby/object:Gem::Version
version: 1.0.0
- !ruby/object:Gem::Dependency
name: minitest
requirement: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - '>='
- !ruby/object:Gem::Version
version: '0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - '>='
- !ruby/object:Gem::Version
version: '0'
- !ruby/object:Gem::Dependency
name: yard
requirement: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - '>='
- !ruby/object:Gem::Version
version: '0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - '>='
- !ruby/object:Gem::Version
version: '0'
- !ruby/object:Gem::Dependency
name: rake
requirement: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - '>='
- !ruby/object:Gem::Version
version: '0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - '>='
- !ruby/object:Gem::Version
version: '0'
- !ruby/object:Gem::Dependency
name: simplecov
requirement: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - '>='
- !ruby/object:Gem::Version
version: 0.3.5
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - '>='
- !ruby/object:Gem::Version
version: 0.3.5
- !ruby/object:Gem::Dependency
name: bluecloth
requirement: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - '>='
- !ruby/object:Gem::Version
version: 0.3.5
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - '>='
- !ruby/object:Gem::Version
version: 0.3.5
description: Ruby/ProgressBar is a text progress bar library for Ruby. It can indicate
@@ -118,7 +105,7 @@ extensions: []
extra_rdoc_files: []
files:
- .gitignore
-- .rvmrc
+- .ruby-version
- .travis.yml
- ChangeLog
- Gemfile
@@ -130,28 +117,28 @@ files:
- progressbar.gemspec
- test/test.rb
homepage: http://github.com/peleteiro/progressbar
-licenses: []
+licenses:
+- Ruby
+metadata: {}
post_install_message:
rdoc_options:
- --charset=UTF-8
require_paths:
- lib
required_ruby_version: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - '>='
- !ruby/object:Gem::Version
version: '0'
required_rubygems_version: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - '>='
- !ruby/object:Gem::Version
version: 1.3.6
requirements: []
rubyforge_project:
-rubygems_version: 1.8.18
+rubygems_version: 2.0.6
signing_key:
-specification_version: 3
+specification_version: 4
summary: Ruby/ProgressBar is a text progress bar library for Ruby.
test_files: []
diff --git a/progressbar.gemspec b/progressbar.gemspec
index 1f5d24e..7ab3af8 100644
--- a/progressbar.gemspec
+++ b/progressbar.gemspec
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
s.homepage = "http://github.com/peleteiro/progressbar"
s.summary = "Ruby/ProgressBar is a text progress bar library for Ruby."
s.description = "Ruby/ProgressBar is a text progress bar library for Ruby. It can indicate progress with percentage, a progress bar, and estimated remaining time."
+ s.license = "Ruby"
s.required_rubygems_version = ">= 1.3.6"
diff --git a/test/test.rb b/test/test.rb
index 0006396..0a6f47e 100644
--- a/test/test.rb
+++ b/test/test.rb
@@ -4,8 +4,8 @@ require 'progressbar'
class ProgressBarTest < Test::Unit::TestCase
SleepUnit = 0.01
- def do_make_progress_bar (title, total)
- ProgressBar.new(title, total)
+ def do_make_progress_bar(title, total, &block)
+ ProgressBar.new(title, total, &block)
end
def test_bytes
@@ -106,10 +106,20 @@ class ProgressBarTest < Test::Unit::TestCase
}
pbar.finish
end
+
+ def test_with_block
+ total = 100
+ do_make_progress_bar("test(block)", total) do |pbar|
+ total.times {
+ sleep(SleepUnit)
+ pbar.inc
+ }
+ end
+ end
end
class ReversedProgressBarTest < ProgressBarTest
- def do_make_progress_bar (title, total)
- ReversedProgressBar.new(title, total)
+ def do_make_progress_bar(title, total, &block)
+ ReversedProgressBar.new(title, total, &block)
end
end
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-progressbar.git
More information about the Pkg-ruby-extras-commits
mailing list