progressbar 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ .document
18
+ coverage
19
+ rdoc
20
+ pkg
21
+
22
+ ## PROJECT::SPECIFIC
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.2@progressbar
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ # Specify your gem's dependencies in ruby-duration.gemspec
4
+ gemspec
@@ -0,0 +1,27 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ progressbar (0.9.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ bluecloth (2.1.0)
10
+ minitest (2.2.2)
11
+ rake (0.9.2)
12
+ simplecov (0.4.2)
13
+ simplecov-html (~> 0.4.4)
14
+ simplecov-html (0.4.5)
15
+ yard (0.7.1)
16
+
17
+ PLATFORMS
18
+ ruby
19
+
20
+ DEPENDENCIES
21
+ bluecloth (>= 0.3.5)
22
+ bundler (>= 1.0.0)
23
+ minitest
24
+ progressbar!
25
+ rake
26
+ simplecov (>= 0.3.5)
27
+ yard
File without changes
@@ -0,0 +1,14 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ task :default => :test
5
+
6
+ require 'rake/testtask'
7
+ Rake::TestTask.new(:test) do |test|
8
+ test.libs << 'lib' << 'test'
9
+ test.pattern = 'test/test.rb'
10
+ test.verbose = true
11
+ end
12
+
13
+ require 'yard'
14
+ YARD::Rake::YardocTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.9.0
@@ -33,12 +33,13 @@ class ProgressBar
33
33
  attr_reader :current
34
34
  attr_reader :total
35
35
  attr_accessor :start_time
36
+ attr_writer :bar_mark
36
37
 
37
38
  private
38
39
  def fmt_bar
39
40
  bar_width = do_percentage * @terminal_width / 100
40
- sprintf("|%s%s|",
41
- @bar_mark * bar_width,
41
+ sprintf("|%s%s|",
42
+ @bar_mark * bar_width,
42
43
  " " * (@terminal_width - bar_width))
43
44
  end
44
45
 
@@ -51,9 +52,9 @@ class ProgressBar
51
52
  end
52
53
 
53
54
  def fmt_stat_for_file_transfer
54
- if @finished_p then
55
+ if @finished_p then
55
56
  sprintf("%s %s %s", bytes, transfer_rate, elapsed)
56
- else
57
+ else
57
58
  sprintf("%s %s %s", bytes, transfer_rate, eta)
58
59
  end
59
60
  end
@@ -106,7 +107,7 @@ class ProgressBar
106
107
  elapsed = Time.now - @start_time
107
108
  sprintf("Time: %s", format_time(elapsed))
108
109
  end
109
-
110
+
110
111
  def eol
111
112
  if @finished_p then "\n" else "\r" end
112
113
  end
@@ -137,14 +138,14 @@ class ProgressBar
137
138
  end
138
139
 
139
140
  def show
140
- arguments = @format_arguments.map {|method|
141
+ arguments = @format_arguments.map {|method|
141
142
  method = sprintf("fmt_%s", method)
142
143
  send(method)
143
144
  }
144
145
  line = sprintf(@format, *arguments)
145
146
 
146
147
  width = get_width
147
- if line.length == width - 1
148
+ if line.length == width - 1
148
149
  @out.print(line + eol)
149
150
  @out.flush
150
151
  elsif line.length >= width
@@ -167,7 +168,7 @@ class ProgressBar
167
168
  end
168
169
 
169
170
  # Use "!=" instead of ">" to support negative changes
170
- if cur_percentage != prev_percentage ||
171
+ if cur_percentage != prev_percentage ||
171
172
  Time.now - @previous_time >= 1 || @finished_p
172
173
  show
173
174
  end
@@ -233,4 +234,3 @@ class ReversedProgressBar < ProgressBar
233
234
  100 - super
234
235
  end
235
236
  end
236
-
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "progressbar"
5
+ s.version = "0.9.1"
6
+ s.platform = Gem::Platform::RUBY
7
+ s.authors = ["Satoru Takabayashi", "Jose Peleteiro"]
8
+ s.email = ["satoru@0xcc.net", "jose@peleteiro.net"]
9
+ s.homepage = "http://github.com/peleteiro/progressbar"
10
+ s.summary = "Ruby/ProgressBar is a text progress bar library for Ruby."
11
+ 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."
12
+
13
+ s.required_rubygems_version = ">= 1.3.6"
14
+
15
+ s.add_development_dependency "bundler", ">= 1.0.0"
16
+ s.add_development_dependency "minitest", ">= 0"
17
+ s.add_development_dependency "yard", ">= 0"
18
+ s.add_development_dependency "rake", ">= 0"
19
+ s.add_development_dependency "simplecov", ">= 0.3.5"
20
+ s.add_development_dependency "bluecloth", ">= 0.3.5"
21
+
22
+ s.files = `git ls-files`.split("\n")
23
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
24
+ s.require_path = 'lib'
25
+
26
+ s.rdoc_options = ["--charset=UTF-8"]
27
+ end
@@ -51,9 +51,9 @@ class ProgressBarTest < Test::Unit::TestCase
51
51
  end
52
52
 
53
53
  def test_inc_x
54
- total = File.size("../lib/progressbar.rb")
54
+ total = File.size("lib/progressbar.rb")
55
55
  pbar = do_make_progress_bar("test(inc(x))", total)
56
- File.new("../lib/progressbar.rb").each {|line|
56
+ File.new("lib/progressbar.rb").each {|line|
57
57
  sleep(SleepUnit)
58
58
  pbar.inc(line.length)
59
59
  }
@@ -95,6 +95,17 @@ class ProgressBarTest < Test::Unit::TestCase
95
95
  pbar = do_make_progress_bar("test(total=0)", total)
96
96
  pbar.finish
97
97
  end
98
+
99
+ def test_custom_bar_mark
100
+ total = 100
101
+ pbar = do_make_progress_bar("test(custom)", total)
102
+ pbar.bar_mark = '='
103
+ total.times {
104
+ sleep(SleepUnit)
105
+ pbar.inc
106
+ }
107
+ pbar.finish
108
+ end
98
109
  end
99
110
 
100
111
  class ReversedProgressBarTest < ProgressBarTest
@@ -102,4 +113,3 @@ class ReversedProgressBarTest < ProgressBarTest
102
113
  ReversedProgressBar.new(title, total)
103
114
  end
104
115
  end
105
-
metadata CHANGED
@@ -1,63 +1,129 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: progressbar
3
- version: !ruby/object:Gem::Version
4
- version: 0.9.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.1
5
+ prerelease:
5
6
  platform: ruby
6
- authors:
7
+ authors:
7
8
  - Satoru Takabayashi
8
9
  - Jose Peleteiro
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
-
13
- date: 2009-11-24 00:00:00 -02:00
13
+ date: 2011-06-08 00:00:00.000000000 -07:00
14
14
  default_executable:
15
- dependencies: []
16
-
17
- description: Ruby/ProgressBar is a text progress bar library for Ruby. It can indicate progress with percentage, a progress bar, and estimated remaining time.
18
- email: satoru@0xcc.net
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: bundler
18
+ requirement: &2157497740 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
23
+ version: 1.0.0
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: *2157497740
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: &2157497280 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: *2157497280
38
+ - !ruby/object:Gem::Dependency
39
+ name: yard
40
+ requirement: &2157496820 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: *2157496820
49
+ - !ruby/object:Gem::Dependency
50
+ name: rake
51
+ requirement: &2157496360 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: *2157496360
60
+ - !ruby/object:Gem::Dependency
61
+ name: simplecov
62
+ requirement: &2157495900 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: 0.3.5
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: *2157495900
71
+ - !ruby/object:Gem::Dependency
72
+ name: bluecloth
73
+ requirement: &2157495440 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: 0.3.5
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: *2157495440
82
+ description: Ruby/ProgressBar is a text progress bar library for Ruby. It can indicate
83
+ progress with percentage, a progress bar, and estimated remaining time.
84
+ email:
85
+ - satoru@0xcc.net
86
+ - jose@peleteiro.net
19
87
  executables: []
20
-
21
88
  extensions: []
22
-
23
- extra_rdoc_files:
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - .rvmrc
24
93
  - ChangeLog
94
+ - Gemfile
95
+ - Gemfile.lock
25
96
  - LICENSE
26
- - README.en.rd
27
- - README.ja.rd
28
- files:
97
+ - README.rd
98
+ - Rakefile
99
+ - VERSION
29
100
  - lib/progressbar.rb
30
- - ChangeLog
31
- - LICENSE
32
- - README.en.rd
33
- - README.ja.rd
101
+ - progressbar.gemspec
102
+ - test/test.rb
34
103
  has_rdoc: true
35
104
  homepage: http://github.com/peleteiro/progressbar
36
105
  licenses: []
37
-
38
106
  post_install_message:
39
- rdoc_options:
107
+ rdoc_options:
40
108
  - --charset=UTF-8
41
- require_paths:
109
+ require_paths:
42
110
  - lib
43
- required_ruby_version: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: "0"
48
- version:
49
- required_rubygems_version: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: "0"
54
- version:
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: 1.3.6
55
123
  requirements: []
56
-
57
124
  rubyforge_project:
58
- rubygems_version: 1.3.5
125
+ rubygems_version: 1.6.2
59
126
  signing_key:
60
127
  specification_version: 3
61
128
  summary: Ruby/ProgressBar is a text progress bar library for Ruby.
62
- test_files:
63
- - test/test.rb
129
+ test_files: []
@@ -1,100 +0,0 @@
1
- =begin
2
- index:eJ
3
-
4
- = Ruby/ProgressBar: �ץ����쥹�С���ƥ����Ȥ�ɽ������ Ruby�ѤΥ饤�֥��
5
-
6
- �ǽ�������: 2005-05-22 00:28:53
7
-
8
-
9
- --
10
-
11
- Ruby/ProgressBar �ϥץ����쥹�С���ƥ����Ȥ�ɽ������ Ruby��
12
- �Υ饤�֥��Ǥ��������ο�Ľ������ѡ�����ȡ��ץ����쥹�С���
13
- ����ӿ���Ĥ���֤Ȥ���ɽ�����ޤ���
14
-
15
- �ǿ��Ǥ�
16
- ((<URL:http://namazu.org/~satoru/ruby-progressbar/>))
17
- ���������ǽ�Ǥ�
18
-
19
- == ������
20
-
21
- % irb --simple-prompt -r progressbar
22
- >> pbar = ProgressBar.new("test", 100)
23
- => (ProgressBar: 0/100)
24
- >> 100.times {sleep(0.1); pbar.inc}; pbar.finish
25
- test: 100% |oooooooooooooooooooooooooooooooooooooooo| Time: 00:00:10
26
- => nil
27
-
28
- >> pbar = ProgressBar.new("test", 100)
29
- => (ProgressBar: 0/100)
30
- >> (1..100).each{|x| sleep(0.1); pbar.set(x)}; pbar.finish
31
- test: 67% |oooooooooooooooooooooooooo | ETA: 00:00:03
32
-
33
- == API
34
-
35
- --- ProgressBar#new (title, total, out = STDERR)
36
- �ץ����쥹�С��ν�����֤�ɽ������������ ProgressBar����
37
- �������Ȥ��֤���((|title|)) �Ǹ��Ф���((|total|)) �ǽ�
38
- �������פ�((|out|)) �ǽ������ IO �����ꤹ�롣
39
-
40
- �ץ����쥹�С���ɽ���ϡ������ɽ�������Ľ�� 1%�ʾ夢��
41
- ���Ȥ������뤤�� 1�ðʾ�вᤷ�����˹�������ޤ���
42
-
43
- --- ProgressBar#inc (step = 1)
44
- �����Υ����󥿤� ((|step|)) �������ʤ�ơ��ץ����쥹�С�
45
- ��ɽ���򹹿����롣�С��α�¦�ˤϿ���Ĥ���֤�ɽ�����롣
46
- �����󥿤� ((|total|)) ��ۤ��ƿʤळ�ȤϤʤ���
47
-
48
- --- ProgressBar#set (count)
49
- �����󥿤��ͤ� ((|count|)) �����ꤷ���ץ����쥹�С���
50
- ɽ���򹹿����롣�С��α�¦�ˤϿ���Ĥ���֤�ɽ�����롣
51
- ((|count|)) �˥ޥ��ʥ����ͤ��뤤�� ((|total|)) ����礭
52
- ���ͤ��Ϥ����㳰��ȯ�����롣
53
-
54
- --- ProgressBar#finish
55
- �ץ����쥹�С�����ߤ����ץ����쥹�С���ɽ���򹹿����롣
56
- �ץ����쥹�С��α�¦�ˤϷв���֤�ɽ�����롣
57
- ���ΤȤ����ץ����쥹�С��� 100% �ǽ�λ���롣
58
-
59
- --- ProgressBar#halt
60
- �ץ����쥹�С�����ߤ����ץ����쥹�С���ɽ���򹹿����롣
61
- �ץ����쥹�С��α�¦�ˤϷв���֤�ɽ�����롣
62
- ���ΤȤ����ץ����쥹�С��Ϥ��λ����Υѡ�����ơ����ǽ�λ���롣
63
-
64
- --- ProgressBar#format=
65
- �ץ����쥹�С�ɽ���Υե����ޥåȤ����ꤹ�롣
66
- ̤�ѹ����� "%-14s %3d%% %s %s"
67
-
68
- --- ProgressBar#format_arguments=
69
- �ץ����쥹�С�ɽ���˻Ȥ��ؿ������ꤹ�롣
70
- ̤�ѹ����� [:title, :percentage, :bar, :stat]
71
- �ե�����ž�����ˤ� :stat ���Ѥ��� :stat_for_file_transfer
72
- ��Ȥ���ž���Х��ȿ���ž��®�٤�ɽ���Ǥ��롣
73
-
74
- --- ProgressBar#file_transfer_mode
75
- �ץ����쥹�С�ɽ���� :stat ���Ѥ��� :stat_for_file_transfer
76
- ��Ȥ���ž���Х��ȿ���ž��®�٤�ɽ�����롣
77
-
78
-
79
- ReverseProgressBar �Ȥ������饹���󶡤���ޤ�����ǽ��
80
- ProgressBar �Ȥޤä���Ʊ���Ǥ������ץ����쥹�С��οʹ�������
81
- �դˤʤäƤ��ޤ���
82
-
83
- == ���»���
84
-
85
- ��Ľ��������������פ��Ф�����Ȥ��Ʒ׻����뤿�ᡢ��������
86
- �פ������ˤ狼��ʤ������ǤϻȤ��ޤ��󡣤ޤ�����Ľ��ή�줬��
87
- ��Ǥʤ��Ȥ��ˤϻĤ���֤ο�����������Ԥ��ޤ���
88
-
89
- == �����������
90
-
91
- Ruby �Υ饤���󥹤˽��ä��ե꡼���եȥ������Ȥ��Ƹ������ޤ���
92
- ������̵�ݾڤǤ���
93
-
94
- * ((<URL:http://namazu.org/~satoru/ruby-progressbar/ruby-progressbar-0.9.tar.gz>))
95
- * ((<URL:http://cvs.namazu.org/ruby-progressbar/>))
96
-
97
- --
98
-
99
- - ((<Satoru Takabayashi|URL:http://namazu.org/~satoru/>)) -
100
- =end