progress-bar 0.3.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +11 -0
- data/Gemfile +3 -12
- data/Gemfile.lock +29 -75
- data/LICENSE.txt +165 -20
- data/README.md +53 -20
- data/Rakefile +2 -51
- data/lib/progress-bar.rb +161 -42
- data/lib/progress-bar/version.rb +3 -0
- data/progress-bar.gemspec +21 -60
- metadata +27 -73
- data/.document +0 -5
- data/VERSION +0 -1
- data/test/helper.rb +0 -34
- data/test/test_progress-bar.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 418c16be9ef733a3d968eeeeba7d786c634f55443b7e25fb5ff6cc612d7a258f
|
4
|
+
data.tar.gz: ed8c34644353846ef1190f9412c9669ac4047576b55cfa64712bf65047e1cbe9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00afdaed674191311bb652f64f2459f831dd7a599dbe3bbb13620f3f62751348518dcbb6d10c3ea6e3a9f218342f049ca1fdb237b0ed7ac07510c30dbef67dbe
|
7
|
+
data.tar.gz: 1acad6c43d132077e3dfff52dcfcd50ae0db893b476e1c28783fcee896ed11da7eb6546b3728e0de84acaf4c177cb75b3ca5f8f293e0ad9702507165abb2e700
|
data/.gitignore
ADDED
data/Gemfile
CHANGED
@@ -1,13 +1,4 @@
|
|
1
|
-
source "
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
|
-
gem
|
4
|
-
|
5
|
-
# Add dependencies to develop your gem here.
|
6
|
-
# Include everything needed to run rake, tests, features, etc.
|
7
|
-
group :development do
|
8
|
-
gem "shoulda", ">= 0"
|
9
|
-
gem "rdoc", "~> 3.12"
|
10
|
-
gem "bundler", "~> 1.0"
|
11
|
-
gem "jeweler", "~> 2.0.1"
|
12
|
-
gem "simplecov", ">= 0"
|
13
|
-
end
|
3
|
+
# Specify your gem's dependencies in progress-bar.gemspec
|
4
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,82 +1,36 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
progress-bar (0.5.0)
|
5
|
+
ruby-dbus (~> 0)
|
6
|
+
|
1
7
|
GEM
|
2
|
-
remote:
|
8
|
+
remote: https://rubygems.org/
|
3
9
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
descendants_tracker (~> 0.0.4)
|
21
|
-
faraday (~> 0.8, < 0.10)
|
22
|
-
hashie (>= 3.3)
|
23
|
-
multi_json (>= 1.7.5, < 2.0)
|
24
|
-
nokogiri (~> 1.6.3)
|
25
|
-
oauth2
|
26
|
-
hashie (3.3.2)
|
27
|
-
highline (1.6.21)
|
28
|
-
i18n (0.7.0)
|
29
|
-
jeweler (2.0.1)
|
30
|
-
builder
|
31
|
-
bundler (>= 1.0)
|
32
|
-
git (>= 1.2.5)
|
33
|
-
github_api
|
34
|
-
highline (>= 1.6.15)
|
35
|
-
nokogiri (>= 1.5.10)
|
36
|
-
rake
|
37
|
-
rdoc
|
38
|
-
json (1.8.1)
|
39
|
-
jwt (1.2.0)
|
40
|
-
mini_portile (0.6.1)
|
41
|
-
minitest (5.5.0)
|
42
|
-
multi_json (1.10.1)
|
43
|
-
multi_xml (0.5.5)
|
44
|
-
multipart-post (2.0.0)
|
45
|
-
nokogiri (1.6.5)
|
46
|
-
mini_portile (~> 0.6.0)
|
47
|
-
oauth2 (1.0.0)
|
48
|
-
faraday (>= 0.8, < 0.10)
|
49
|
-
jwt (~> 1.0)
|
50
|
-
multi_json (~> 1.3)
|
51
|
-
multi_xml (~> 0.5)
|
52
|
-
rack (~> 1.2)
|
53
|
-
rack (1.6.0)
|
54
|
-
rake (10.4.2)
|
55
|
-
rdoc (3.12.2)
|
56
|
-
json (~> 1.4)
|
57
|
-
ruby-dbus (0.11.0)
|
58
|
-
shoulda (3.5.0)
|
59
|
-
shoulda-context (~> 1.0, >= 1.0.1)
|
60
|
-
shoulda-matchers (>= 1.4.1, < 3.0)
|
61
|
-
shoulda-context (1.2.1)
|
62
|
-
shoulda-matchers (2.7.0)
|
63
|
-
activesupport (>= 3.0.0)
|
64
|
-
simplecov (0.9.1)
|
65
|
-
docile (~> 1.1.0)
|
66
|
-
multi_json (~> 1.0)
|
67
|
-
simplecov-html (~> 0.8.0)
|
68
|
-
simplecov-html (0.8.0)
|
69
|
-
thread_safe (0.3.4)
|
70
|
-
tzinfo (1.2.2)
|
71
|
-
thread_safe (~> 0.1)
|
10
|
+
diff-lcs (1.4.4)
|
11
|
+
rake (12.3.3)
|
12
|
+
rspec (3.10.0)
|
13
|
+
rspec-core (~> 3.10.0)
|
14
|
+
rspec-expectations (~> 3.10.0)
|
15
|
+
rspec-mocks (~> 3.10.0)
|
16
|
+
rspec-core (3.10.1)
|
17
|
+
rspec-support (~> 3.10.0)
|
18
|
+
rspec-expectations (3.10.1)
|
19
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
20
|
+
rspec-support (~> 3.10.0)
|
21
|
+
rspec-mocks (3.10.2)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.10.0)
|
24
|
+
rspec-support (3.10.2)
|
25
|
+
ruby-dbus (0.16.0)
|
72
26
|
|
73
27
|
PLATFORMS
|
74
28
|
ruby
|
75
29
|
|
76
30
|
DEPENDENCIES
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
31
|
+
progress-bar!
|
32
|
+
rake (~> 12)
|
33
|
+
rspec (~> 3)
|
34
|
+
|
35
|
+
BUNDLED WITH
|
36
|
+
2.2.11
|
data/LICENSE.txt
CHANGED
@@ -1,20 +1,165 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
the
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
6
|
+
of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
data/README.md
CHANGED
@@ -1,23 +1,56 @@
|
|
1
1
|
ProgressBar
|
2
2
|
===========
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
4
|
+
Installation
|
5
|
+
------------
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'progress-bar'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install progress-bar
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
There exist three different handlers for ProgressBar: `ProgressBar::KDE`, `ProgressBar::KDialog` and `ProgressBar::Console`.
|
24
|
+
These can be used directly, or you can use `ProgressBar.new` to determine the best solution.
|
25
|
+
|
26
|
+
If the process runs in a terminal, the `ProgressBar::Console` would be the best solution.
|
27
|
+
If you run KDE, `ProgressBar::KDE`, which uses JobViewer via DBUS, would be nice.
|
28
|
+
Else `ProgressBar::KDialog` will be tried.
|
29
|
+
Other handlers could be added in future.
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
pb = ProgressBar.new 100, 'Initialization...' # You expect 100 units (eg. percent)
|
33
|
+
ph.start
|
34
|
+
pb.i += 5 # 5 units done
|
35
|
+
pb.inc! 5 # additional 5 units done
|
36
|
+
pb.text = "Working..."
|
37
|
+
pb.i += 80
|
38
|
+
pb.text = "Last steps"
|
39
|
+
pb.i += 10
|
40
|
+
pb.text = "Done!"
|
41
|
+
pb.finish
|
42
|
+
```
|
43
|
+
|
44
|
+
## Development
|
45
|
+
|
46
|
+
After checking out the repo, run `bundle install` to install dependencies. Then, run `rake test` to run the tests.
|
47
|
+
|
48
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
Bug reports and pull requests are welcome on [https://git.denkn.at/deac/progress-bar]().
|
53
|
+
|
54
|
+
## License
|
55
|
+
|
56
|
+
The gem is available as open source under the terms of the [LGPL-3.0 License](https://opensource.org/licenses/LGPL-3.0).
|
data/Rakefile
CHANGED
@@ -1,51 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'bundler'
|
5
|
-
begin
|
6
|
-
Bundler.setup(:default, :development)
|
7
|
-
rescue Bundler::BundlerError => e
|
8
|
-
$stderr.puts e.message
|
9
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
-
exit e.status_code
|
11
|
-
end
|
12
|
-
require 'rake'
|
13
|
-
|
14
|
-
require 'jeweler'
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
|
-
gem.name = "progress-bar"
|
18
|
-
gem.homepage = "http://github.com/DenisKnauf/progress-bar"
|
19
|
-
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{Progress Bar for terminal and KDE}
|
21
|
-
gem.description = %Q{Displays a Progress Bar in terminal or via kdialog}
|
22
|
-
gem.email = %q{#{"de"}nis}+?@+'den'+%Q{kn}+"#{?.}at"
|
23
|
-
gem.authors = ["Denis Knauf"]
|
24
|
-
# dependencies defined in Gemfile
|
25
|
-
end
|
26
|
-
Jeweler::RubygemsDotOrgTasks.new
|
27
|
-
|
28
|
-
require 'rake/testtask'
|
29
|
-
Rake::TestTask.new(:test) do |test|
|
30
|
-
test.libs << 'lib' << 'test'
|
31
|
-
test.pattern = 'test/**/test_*.rb'
|
32
|
-
test.verbose = true
|
33
|
-
end
|
34
|
-
|
35
|
-
desc "Code coverage detail"
|
36
|
-
task :simplecov do
|
37
|
-
ENV['COVERAGE'] = "true"
|
38
|
-
Rake::Task['test'].execute
|
39
|
-
end
|
40
|
-
|
41
|
-
task :default => :test
|
42
|
-
|
43
|
-
require 'rdoc/task'
|
44
|
-
Rake::RDocTask.new do |rdoc|
|
45
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
46
|
-
|
47
|
-
rdoc.rdoc_dir = 'rdoc'
|
48
|
-
rdoc.title = "progress-bar #{version}"
|
49
|
-
rdoc.rdoc_files.include('README*')
|
50
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
51
|
-
end
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
task :default => :spec
|
data/lib/progress-bar.rb
CHANGED
@@ -1,22 +1,31 @@
|
|
1
1
|
require 'dbus'
|
2
|
+
require 'pathname'
|
2
3
|
|
3
4
|
module ProgressBar
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
@klasses ||= []
|
6
|
+
|
7
|
+
class <<self
|
8
|
+
def register klass
|
9
|
+
@klasses.push klass
|
10
|
+
end
|
11
|
+
|
12
|
+
def new *a, **o
|
13
|
+
@klasses.map {|cl| cl.new *a, **o}.find &:possible?
|
11
14
|
end
|
12
15
|
end
|
13
16
|
end
|
14
17
|
|
15
18
|
class ProgressBar::Base
|
16
|
-
attr_reader :max, :i, :text
|
17
|
-
attr_accessor :
|
18
|
-
def initialize max = nil, text = nil
|
19
|
-
@
|
19
|
+
attr_reader :max, :i, :text
|
20
|
+
attr_accessor :startts
|
21
|
+
def initialize max = nil, text = nil, **_options
|
22
|
+
@startts, @max, @i, @text = nil, max || 100, 0, text || ''
|
23
|
+
end
|
24
|
+
|
25
|
+
def start
|
26
|
+
at_exit {finish}
|
27
|
+
@startts = Time.now
|
28
|
+
self
|
20
29
|
end
|
21
30
|
|
22
31
|
def i= x
|
@@ -33,7 +42,7 @@ class ProgressBar::Base
|
|
33
42
|
alias to_i i
|
34
43
|
alias inc! increment!
|
35
44
|
def done_rel() 100.0*i/max end
|
36
|
-
def done_dur() Time.now-@
|
45
|
+
def done_dur() Time.now-@startts end
|
37
46
|
|
38
47
|
def total_dur
|
39
48
|
done_dur * max / i
|
@@ -44,21 +53,30 @@ class ProgressBar::Base
|
|
44
53
|
change_text
|
45
54
|
end
|
46
55
|
|
47
|
-
def error
|
48
|
-
@error = x
|
49
|
-
change_error
|
50
|
-
end
|
51
|
-
|
56
|
+
def error( text) end
|
52
57
|
def change_progress() end
|
53
58
|
def change_text() end
|
54
|
-
def change_error() end
|
55
59
|
def finish() end
|
60
|
+
def possible?() false end
|
56
61
|
end
|
57
62
|
|
58
63
|
class ProgressBar::Console < ProgressBar::Base
|
59
|
-
|
60
|
-
|
64
|
+
attr_reader :outfd, :errfd
|
65
|
+
|
66
|
+
def initialize *a, outfd: nil, errfd: nil, **options
|
67
|
+
@outfd = outfd || STDERR
|
68
|
+
@errfd = errfd || @outfd
|
69
|
+
super *a, **options
|
70
|
+
end
|
71
|
+
|
72
|
+
def possible?
|
73
|
+
@outfd.tty?
|
74
|
+
end
|
75
|
+
|
76
|
+
def start
|
77
|
+
super
|
61
78
|
change_text
|
79
|
+
self
|
62
80
|
end
|
63
81
|
|
64
82
|
def format_time t
|
@@ -70,31 +88,126 @@ class ProgressBar::Console < ProgressBar::Base
|
|
70
88
|
end
|
71
89
|
|
72
90
|
def change_text
|
73
|
-
l =
|
91
|
+
l = [[100.0*i/max, 0].max, 100].min.to_i
|
74
92
|
dd, td = done_dur, total_dur
|
75
|
-
|
93
|
+
b = ?= * l
|
94
|
+
b[-1] = ?> unless 0 == l or 100 == l
|
95
|
+
@outfd.printf "\r\e[J%s / %s [%-*s] %s", format_time(dd), format_time(td), 100, b, text
|
76
96
|
end
|
77
97
|
alias change_progress change_text
|
78
98
|
|
79
|
-
def
|
80
|
-
|
81
|
-
|
99
|
+
def error text
|
100
|
+
@errfd.printf "\r\e[J%s\n", text
|
101
|
+
@errfd.flush
|
102
|
+
end
|
103
|
+
|
104
|
+
def finish
|
105
|
+
@outfd.puts
|
106
|
+
@outfd.flush
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
class ProgressBar::KDE < ProgressBar::Base
|
111
|
+
attr_reader :bus, :service, :view
|
112
|
+
|
113
|
+
def initialize max, text = nil, title: nil,
|
114
|
+
app_name: nil,
|
115
|
+
app_icon_name: nil,
|
116
|
+
unit: nil,
|
117
|
+
is_cancable: nil,
|
118
|
+
is_suspendable: nil,
|
119
|
+
**_options
|
120
|
+
|
121
|
+
super max, text
|
122
|
+
text = @text
|
123
|
+
text = nil if text.nil? or text.empty?
|
124
|
+
title = nil if title.nil? or title.empty?
|
125
|
+
unit = '' if unit.nil? or unit.empty?
|
126
|
+
@title, @text, @unit, @app_name, @app_icon_name, @is_cancable, @is_suspendable =
|
127
|
+
title, text, unit, app_name || $0, app_icon_name || '', is_cancable, is_suspendable
|
128
|
+
@errors = []
|
129
|
+
end
|
130
|
+
|
131
|
+
def possible?
|
132
|
+
'KDE' == ENV['XDG_CURRENT_DESKTOP']
|
133
|
+
end
|
134
|
+
|
135
|
+
def start
|
136
|
+
@finished = false
|
137
|
+
@bus = DBus::SessionBus.instance
|
138
|
+
@service = @bus['org.kde.JobViewServer']
|
139
|
+
jvs = @service['/JobViewServer'] #['org.kde.JobViewServer']
|
140
|
+
jvs.introspect
|
141
|
+
flags = (@is_cancable ? 0x1 : 0) | (@is_suspendable ? 0x2 : 0)
|
142
|
+
view_path = jvs.requestView @app_name, @app_icon_name, flags
|
143
|
+
@view = @service[view_path] #['org.kde.JobViewV2']
|
144
|
+
@view.introspect
|
145
|
+
super
|
146
|
+
@view.setTotalAmount @max, @unit
|
147
|
+
self
|
148
|
+
end
|
149
|
+
|
150
|
+
def change_text
|
151
|
+
@view.setInfoMessage text
|
152
|
+
end
|
153
|
+
|
154
|
+
def change_progress
|
155
|
+
@view.setProcessedAmount i, @unit
|
156
|
+
@view.setPercent done_rel
|
157
|
+
end
|
158
|
+
|
159
|
+
def error text
|
160
|
+
#STDERR.puts @view.object.introspect
|
161
|
+
#@view.setError text
|
162
|
+
@view.setDescriptionField 0, "Error", text
|
163
|
+
#@view.setInfoMessage "#{text}\nError: #{error}"
|
164
|
+
end
|
165
|
+
|
166
|
+
def finish
|
167
|
+
return if @finished
|
168
|
+
@view.terminate ''
|
169
|
+
@finished = true
|
170
|
+
end
|
171
|
+
|
172
|
+
def max= value
|
173
|
+
super value
|
174
|
+
@view.setTotalAmount value, @unit
|
82
175
|
end
|
83
176
|
end
|
84
177
|
|
85
178
|
class ProgressBar::KDialog < ProgressBar::Base
|
86
179
|
attr_reader :dialog_service_path, :dialog_object_path, :errors, :dialog_object
|
87
|
-
|
180
|
+
|
181
|
+
def initialize max, text = nil, title: nil, **_options
|
88
182
|
super max, text
|
183
|
+
text = @text
|
184
|
+
text = nil if text.nil? or text.empty?
|
185
|
+
title = nil if title.nil? or title.empty?
|
186
|
+
@title = title
|
89
187
|
@errors = []
|
90
|
-
|
91
|
-
|
188
|
+
end
|
189
|
+
|
190
|
+
def possible?
|
191
|
+
path = Pathname.new `which kdialog`.chomp
|
192
|
+
$?.exitstatus and path.executable?
|
193
|
+
end
|
194
|
+
|
195
|
+
def start
|
196
|
+
@finished = false
|
197
|
+
args = ['kdialog', @title ? ['--title', @title] : [], '--progressbar', @text || '.', @max].flatten.compact.map &:to_s
|
198
|
+
@dialog_service_path, @dialog_object_path =
|
199
|
+
IO.popen( args, 'r', &:readlines).join( "\n").split ' '
|
92
200
|
@dialog_bus = DBus.session_bus
|
93
201
|
@dialog_service = @dialog_bus[@dialog_service_path]
|
94
|
-
@dialog_object = @dialog_service
|
95
|
-
|
96
|
-
|
202
|
+
@dialog_object = @dialog_service[ @dialog_object_path]
|
203
|
+
#STDERR.puts "%p" %
|
204
|
+
@dialog_object.introspect
|
205
|
+
@dialog_object.showCancelButton 1
|
206
|
+
super
|
207
|
+
change_text if text.nil?
|
97
208
|
change_progress
|
209
|
+
self
|
210
|
+
|
98
211
|
rescue DBus::Error
|
99
212
|
raise Interrupt if $!.name == 'org.freedesktop.DBus.Error.ServiceUnknown'
|
100
213
|
raise
|
@@ -108,8 +221,9 @@ class ProgressBar::KDialog < ProgressBar::Base
|
|
108
221
|
def kdialog(*a) self.class.kdialog *a end
|
109
222
|
|
110
223
|
def change_progress()
|
111
|
-
|
112
|
-
|
224
|
+
#@dialog_object.Set 'org.kde.kdialog.ProgressDialog', 'value', i
|
225
|
+
@dialog_object['value'] = i
|
226
|
+
raise Interrupt if @dialog_object.wasCancelled
|
113
227
|
rescue DBus::Error
|
114
228
|
raise Interrupt if $!.name == 'org.freedesktop.DBus.Error.ServiceUnknown'
|
115
229
|
raise
|
@@ -117,23 +231,28 @@ class ProgressBar::KDialog < ProgressBar::Base
|
|
117
231
|
|
118
232
|
def change_text()
|
119
233
|
@dialog_object.setLabelText text
|
120
|
-
raise Interrupt if @dialog_object.wasCancelled
|
234
|
+
raise Interrupt if @dialog_object.wasCancelled
|
121
235
|
rescue DBus::Error
|
122
236
|
raise Interrupt if $!.name == 'org.freedesktop.DBus.Error.ServiceUnknown'
|
123
237
|
raise
|
124
238
|
end
|
125
239
|
|
126
|
-
def
|
127
|
-
|
128
|
-
@dialog_object.close rescue DBus::Error
|
129
|
-
kdialog '--detailederror', "Some errors occured:", errors.join( "<br/>\n") unless errors.empty?
|
240
|
+
def error text
|
241
|
+
kdialog '--error', text
|
130
242
|
end
|
131
243
|
|
132
|
-
def
|
133
|
-
@
|
244
|
+
def finish()
|
245
|
+
return if @finished
|
246
|
+
@dialog_object.close rescue DBus::Error
|
247
|
+
@finished = true
|
134
248
|
end
|
135
249
|
|
136
|
-
def max
|
137
|
-
|
250
|
+
def max= val
|
251
|
+
super val
|
252
|
+
@dialog_object['maximum'] = val
|
138
253
|
end
|
139
254
|
end
|
255
|
+
|
256
|
+
ProgressBar.register ProgressBar::Console
|
257
|
+
ProgressBar.register ProgressBar::KDE
|
258
|
+
ProgressBar.register ProgressBar::KDialog
|
data/progress-bar.gemspec
CHANGED
@@ -1,65 +1,26 @@
|
|
1
|
-
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
1
|
+
require_relative "lib/progress-bar/version"
|
5
2
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "progress-bar"
|
5
|
+
spec.version = ProgressBar::VERSION
|
6
|
+
spec.authors = ["Denis Knauf"]
|
7
|
+
spec.email = ["denis+gems@denkn.at"]
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
s.email = "\#{\"de\"}nis@denkn.at"
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE.txt",
|
17
|
-
"README.md"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
"Gemfile",
|
22
|
-
"Gemfile.lock",
|
23
|
-
"LICENSE.txt",
|
24
|
-
"README.md",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"lib/progress-bar.rb",
|
28
|
-
"progress-bar.gemspec",
|
29
|
-
"test/helper.rb",
|
30
|
-
"test/test_progress-bar.rb"
|
31
|
-
]
|
32
|
-
s.homepage = "http://github.com/DenisKnauf/progress-bar"
|
33
|
-
s.licenses = ["MIT"]
|
34
|
-
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = "2.0.14"
|
36
|
-
s.summary = "Progress Bar for terminal and KDE"
|
9
|
+
spec.summary = %q{Progress Bar for terminal and KDE}
|
10
|
+
spec.description = %q{Displays a Progress Bar in terminal, via KDE-JobViewer or via kdialog}
|
11
|
+
spec.homepage = "https://git.denkn.at/deac/progress-bar"
|
12
|
+
spec.licenses = ["LGPL-3.0"]
|
37
13
|
|
38
|
-
|
39
|
-
|
14
|
+
# Specify which files should be added to the gem when it is released.
|
15
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
16
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
17
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
end
|
19
|
+
#spec.bindir = "bin"
|
20
|
+
#spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
40
22
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
45
|
-
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
46
|
-
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
47
|
-
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
48
|
-
else
|
49
|
-
s.add_dependency(%q<ruby-dbus>, [">= 0"])
|
50
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
51
|
-
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
52
|
-
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
53
|
-
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
54
|
-
s.add_dependency(%q<simplecov>, [">= 0"])
|
55
|
-
end
|
56
|
-
else
|
57
|
-
s.add_dependency(%q<ruby-dbus>, [">= 0"])
|
58
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
59
|
-
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
60
|
-
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
61
|
-
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
62
|
-
s.add_dependency(%q<simplecov>, [">= 0"])
|
63
|
-
end
|
23
|
+
spec.add_development_dependency "rake", "~> 12"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3"
|
25
|
+
spec.add_dependency "ruby-dbus", '~> 0'
|
64
26
|
end
|
65
|
-
|
metadata
CHANGED
@@ -1,121 +1,76 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: progress-bar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Knauf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - '>='
|
17
|
+
- - "~>"
|
25
18
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: shoulda
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
19
|
+
version: '12'
|
34
20
|
type: :development
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
|
-
- -
|
24
|
+
- - "~>"
|
39
25
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
26
|
+
version: '12'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
28
|
+
name: rspec
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
|
-
- - ~>
|
31
|
+
- - "~>"
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3
|
33
|
+
version: '3'
|
48
34
|
type: :development
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- - ~>
|
38
|
+
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3
|
40
|
+
version: '3'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: jeweler
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ~>
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 2.0.1
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ~>
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 2.0.1
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: simplecov
|
42
|
+
name: ruby-dbus
|
85
43
|
requirement: !ruby/object:Gem::Requirement
|
86
44
|
requirements:
|
87
|
-
- -
|
45
|
+
- - "~>"
|
88
46
|
- !ruby/object:Gem::Version
|
89
47
|
version: '0'
|
90
|
-
type: :
|
48
|
+
type: :runtime
|
91
49
|
prerelease: false
|
92
50
|
version_requirements: !ruby/object:Gem::Requirement
|
93
51
|
requirements:
|
94
|
-
- -
|
52
|
+
- - "~>"
|
95
53
|
- !ruby/object:Gem::Version
|
96
54
|
version: '0'
|
97
|
-
description: Displays a Progress Bar in terminal or via kdialog
|
98
|
-
email:
|
55
|
+
description: Displays a Progress Bar in terminal, via KDE-JobViewer or via kdialog
|
56
|
+
email:
|
57
|
+
- denis+gems@denkn.at
|
99
58
|
executables: []
|
100
59
|
extensions: []
|
101
|
-
extra_rdoc_files:
|
102
|
-
- LICENSE.txt
|
103
|
-
- README.md
|
60
|
+
extra_rdoc_files: []
|
104
61
|
files:
|
105
|
-
- .
|
62
|
+
- ".gitignore"
|
106
63
|
- Gemfile
|
107
64
|
- Gemfile.lock
|
108
65
|
- LICENSE.txt
|
109
66
|
- README.md
|
110
67
|
- Rakefile
|
111
|
-
- VERSION
|
112
68
|
- lib/progress-bar.rb
|
69
|
+
- lib/progress-bar/version.rb
|
113
70
|
- progress-bar.gemspec
|
114
|
-
|
115
|
-
- test/test_progress-bar.rb
|
116
|
-
homepage: http://github.com/DenisKnauf/progress-bar
|
71
|
+
homepage: https://git.denkn.at/deac/progress-bar
|
117
72
|
licenses:
|
118
|
-
-
|
73
|
+
- LGPL-3.0
|
119
74
|
metadata: {}
|
120
75
|
post_install_message:
|
121
76
|
rdoc_options: []
|
@@ -123,17 +78,16 @@ require_paths:
|
|
123
78
|
- lib
|
124
79
|
required_ruby_version: !ruby/object:Gem::Requirement
|
125
80
|
requirements:
|
126
|
-
- -
|
81
|
+
- - ">="
|
127
82
|
- !ruby/object:Gem::Version
|
128
83
|
version: '0'
|
129
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
85
|
requirements:
|
131
|
-
- -
|
86
|
+
- - ">="
|
132
87
|
- !ruby/object:Gem::Version
|
133
88
|
version: '0'
|
134
89
|
requirements: []
|
135
|
-
|
136
|
-
rubygems_version: 2.0.14
|
90
|
+
rubygems_version: 3.1.2
|
137
91
|
signing_key:
|
138
92
|
specification_version: 4
|
139
93
|
summary: Progress Bar for terminal and KDE
|
data/.document
DELETED
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.3.3
|
data/test/helper.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
|
3
|
-
module SimpleCov::Configuration
|
4
|
-
def clean_filters
|
5
|
-
@filters = []
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
SimpleCov.configure do
|
10
|
-
clean_filters
|
11
|
-
load_adapter 'test_frameworks'
|
12
|
-
end
|
13
|
-
|
14
|
-
ENV["COVERAGE"] && SimpleCov.start do
|
15
|
-
add_filter "/.rvm/"
|
16
|
-
end
|
17
|
-
require 'rubygems'
|
18
|
-
require 'bundler'
|
19
|
-
begin
|
20
|
-
Bundler.setup(:default, :development)
|
21
|
-
rescue Bundler::BundlerError => e
|
22
|
-
$stderr.puts e.message
|
23
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
24
|
-
exit e.status_code
|
25
|
-
end
|
26
|
-
require 'test/unit'
|
27
|
-
require 'shoulda'
|
28
|
-
|
29
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
30
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
31
|
-
require 'progress-bar'
|
32
|
-
|
33
|
-
class Test::Unit::TestCase
|
34
|
-
end
|
data/test/test_progress-bar.rb
DELETED