progress 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README +4 -0
- data/Rakefile +47 -0
- data/TODO +1 -0
- data/lib/enumerable.rb +10 -0
- data/lib/integer.rb +10 -0
- data/lib/progress.rb +42 -0
- metadata +61 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 YOUR NAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'rubygems/specification'
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
GEM = "progress"
|
7
|
+
GEM_VERSION = "0.0.1"
|
8
|
+
AUTHOR = "toy"
|
9
|
+
EMAIL = "ivan@workisfun.ru"
|
10
|
+
HOMEPAGE = ""
|
11
|
+
SUMMARY = "Class to show progress during script run"
|
12
|
+
|
13
|
+
spec = Gem::Specification.new do |s|
|
14
|
+
s.name = GEM
|
15
|
+
s.version = GEM_VERSION
|
16
|
+
s.platform = Gem::Platform::RUBY
|
17
|
+
s.has_rdoc = true
|
18
|
+
s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
|
19
|
+
s.summary = SUMMARY
|
20
|
+
s.description = s.summary
|
21
|
+
s.author = AUTHOR
|
22
|
+
s.email = EMAIL
|
23
|
+
s.homepage = HOMEPAGE
|
24
|
+
|
25
|
+
# Uncomment this to add a dependency
|
26
|
+
# s.add_dependency "foo"
|
27
|
+
|
28
|
+
s.require_path = 'lib'
|
29
|
+
s.autorequire = GEM
|
30
|
+
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,specs}/**/*")
|
31
|
+
end
|
32
|
+
|
33
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
34
|
+
pkg.gem_spec = spec
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "install the gem locally"
|
38
|
+
task :install => [:package] do
|
39
|
+
sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "create a gemspec file"
|
43
|
+
task :make_spec do
|
44
|
+
File.open("#{GEM}.gemspec", "w") do |file|
|
45
|
+
file.puts spec.to_ruby
|
46
|
+
end
|
47
|
+
end
|
data/lib/enumerable.rb
ADDED
data/lib/integer.rb
ADDED
data/lib/progress.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
class Progress
|
2
|
+
def self.start(name, total = 100)
|
3
|
+
@io ||= $stdout
|
4
|
+
@io.sync = true
|
5
|
+
|
6
|
+
@each = total / 1000
|
7
|
+
@count = 0
|
8
|
+
|
9
|
+
@current = 0
|
10
|
+
@total = total
|
11
|
+
@name = name + ': %s'
|
12
|
+
message highight('...')
|
13
|
+
yield
|
14
|
+
message percent
|
15
|
+
@io.puts
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.step
|
19
|
+
@current += 1
|
20
|
+
if (@count += 1) >= @each
|
21
|
+
message highight(percent)
|
22
|
+
@count = 0
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def self.percent
|
29
|
+
'%5.1f%%' % (@current * 100.0 / @total)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.message(s)
|
33
|
+
@io.print "\r\e[0K#{@name % s}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.highight(s)
|
37
|
+
"\e[1m#{s}\e[0m"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
require 'enumerable'
|
42
|
+
require 'integer'
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: progress
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- toy
|
8
|
+
autorequire: progress
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-08-11 00:00:00 +04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Class to show progress during script run
|
17
|
+
email: ivan@workisfun.ru
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
- LICENSE
|
25
|
+
- TODO
|
26
|
+
files:
|
27
|
+
- LICENSE
|
28
|
+
- README
|
29
|
+
- Rakefile
|
30
|
+
- TODO
|
31
|
+
- lib/enumerable.rb
|
32
|
+
- lib/integer.rb
|
33
|
+
- lib/progress.rb
|
34
|
+
has_rdoc: true
|
35
|
+
homepage: ""
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
version:
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "0"
|
52
|
+
version:
|
53
|
+
requirements: []
|
54
|
+
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 1.2.0
|
57
|
+
signing_key:
|
58
|
+
specification_version: 2
|
59
|
+
summary: Class to show progress during script run
|
60
|
+
test_files: []
|
61
|
+
|