formatador 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/CONTRIBUTING.md +18 -0
- data/CONTRIBUTORS.md +16 -0
- data/LICENSE.md +20 -0
- data/README.rdoc +28 -2
- data/changelog.txt +14 -0
- data/formatador.gemspec +5 -2
- data/lib/formatador.rb +2 -1
- data/lib/formatador/progressbar.rb +31 -0
- metadata +8 -13
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZmFhYzcyNjZlYTkzM2RmZTBhYmY1OWJmN2ViOWUyMzYyNmIyYzdiMw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MGRkYmM5ZGM0OTliYjI4NjEwY2M3NDZmYWI2NWYwOTZjM2ZkOWExMw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Y2VhYjM0NzZkYmExYmQ5OTMwZjI5ZmZhYTllNTBmNzdlMDEzNDk4NWVmZTVj
|
10
|
+
MmU0ZjEwZTVhOTdlZWU3ZGYyOTE5YTc3YTA4Y2MxNDM3MDQyYmY0ZjMzNmY3
|
11
|
+
YTIxNDY1MDMwM2ZiOGI1MzQ3ODJiYWRlZmNiMzIyOWFmNzBiZDY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YzcyNzFhYTk2ODI2YjUzZTlhZTAxNWI0MTYzZmJlNGY2MjU2Y2M5MTAxY2Fl
|
14
|
+
OTViZGRlMWVlODgwMWNmOWExNTZlYWY5YzFhNjc4Yzg3Y2IxZDQ5YjJjN2Iw
|
15
|
+
OWUyYjI5ZjAyNDg3Mzk0YmVlMDA5MmU0ZDU3ZmMxOTUyYzRjNjI=
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
## Getting Involved
|
2
|
+
|
3
|
+
New contributors are always welcome, when it doubt please ask questions. We strive to be an open and welcoming community. Please be nice to one another.
|
4
|
+
|
5
|
+
### Coding
|
6
|
+
|
7
|
+
* Pick a task:
|
8
|
+
* Offer feedback on open [pull requests](https://github.com/geemus/formatador/pulls).
|
9
|
+
* Review open [issues](https://github.com/geemus/formatador/issues) for things to help on.
|
10
|
+
* [Create an issue](https://github.com/geemus/formatador/issues/new) to start a discussion on additions or features.
|
11
|
+
* Fork the project, add your changes and tests to cover them in a topic branch.
|
12
|
+
* Commit your changes and rebase against `geemus/formatador` to ensure everything is up to date.
|
13
|
+
* [Submit a pull request](https://github.com/geemus/formatador/compare/).
|
14
|
+
|
15
|
+
### Non-Coding
|
16
|
+
|
17
|
+
* Offer feedback on open [issues](https://github.com/geemus/formatador/issues).
|
18
|
+
* Organize or volunteer at events.
|
data/CONTRIBUTORS.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
* Bohuslav Kabrda <bkabrda@redhat.com>
|
2
|
+
* Chris Howe <chris@howeville.com>
|
3
|
+
* Damien Pollet <damien.pollet@gmail.com>
|
4
|
+
* Daniel Lv <lgn21st@gmail.com>
|
5
|
+
* Gabe Martin-Dempesy <gabe@mudbugmedia.com>
|
6
|
+
* Kevin Menard <nirvdrum@gmail.com>
|
7
|
+
* Mal Curtis <mal@sitepoint.com>
|
8
|
+
* Matt Bridges <mbridges.91@gmail.com>
|
9
|
+
* Matt Petty <matt@kizmeta.com>
|
10
|
+
* Nathaniel Eliot <temujin9@t9productions.com>
|
11
|
+
* Wesley Beary <geemus@engineyard.com>
|
12
|
+
* Wesley Beary <geemus@gmail.com>
|
13
|
+
* Wesley Beary <wbeary@engineyard.com>
|
14
|
+
* Wesley Beary <wesley@heroku.com>
|
15
|
+
* geemus (Wesley Beary) <wbeary@engineyard.com>
|
16
|
+
* geemus <geemus@gmail.com>
|
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2009-2013 [CONTRIBUTORS.md](https://github.com/geemus/formatador/blob/master/CONTRIBUTORS.md)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -27,6 +27,32 @@ You use tags, similar to html, to set formatting options:
|
|
27
27
|
* display_compact_table: Same as display_table, execpt that split lines are not drawn by default in the body of the table. If you need a split line, put a :split constant in the body array.
|
28
28
|
* redisplay_progressbar: takes the current and total values as its first two arguments and redisplays a progressbar (until current = total and then it display_lines). An optional third argument represents the start time and will add an elapsed time counter.
|
29
29
|
|
30
|
+
=== Progress Bar examples
|
31
|
+
|
32
|
+
total = 1000
|
33
|
+
progress = ProgressBar.new(total)
|
34
|
+
1000.times do
|
35
|
+
progress.increment
|
36
|
+
end
|
37
|
+
|
38
|
+
978/1000 |************************************************* |
|
39
|
+
|
40
|
+
# Change the color of the bar
|
41
|
+
|
42
|
+
total = 1000
|
43
|
+
progress = ProgressBar.new(total, :color => "light_blue")
|
44
|
+
1000.times do
|
45
|
+
progress.increment
|
46
|
+
end
|
47
|
+
|
48
|
+
# Change the color of a completed progress bar
|
49
|
+
|
50
|
+
total = 1000
|
51
|
+
progress = ProgressBar.new(total) { |b| b.opts[:color] = "green" }
|
52
|
+
1000.times do
|
53
|
+
progress.increment
|
54
|
+
end
|
55
|
+
|
30
56
|
=== Table examples
|
31
57
|
|
32
58
|
table_data = [{:name => "Joe", :food => "Burger"}, {:name => "Bill", :food => "French fries"}]
|
@@ -41,8 +67,8 @@ You use tags, similar to html, to set formatting options:
|
|
41
67
|
+------+--------------+
|
42
68
|
|
43
69
|
table_data = [
|
44
|
-
{:name => "Joe", :meal => {:main_dish => "Burger", :drink => "water"},
|
45
|
-
{:name => "Bill", :meal => {:main_dish => "Chicken", drink => "soda"}
|
70
|
+
{:name => "Joe", :meal => {:main_dish => "Burger", :drink => "water"}},
|
71
|
+
{:name => "Bill", :meal => {:main_dish => "Chicken", :drink => "soda"}}
|
46
72
|
]
|
47
73
|
Formatador.display_table(table_data, [:name, :"meal.drink"])
|
48
74
|
|
data/changelog.txt
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
v0.2.5 05/23/14
|
2
|
+
===============
|
3
|
+
|
4
|
+
* fix typo in readme
|
5
|
+
* ensure indent is reset
|
6
|
+
* add progress bar object
|
7
|
+
* improve thread safety for progress bar
|
8
|
+
|
9
|
+
v0.2.4 10/26/12
|
10
|
+
===============
|
11
|
+
|
12
|
+
* sort background colors higher
|
13
|
+
* fix homepage link in gem metadata
|
14
|
+
|
1
15
|
v0.2.3 05/18/12
|
2
16
|
===============
|
3
17
|
|
data/formatador.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'formatador'
|
16
|
-
s.version = '0.2.
|
17
|
-
s.date = '
|
16
|
+
s.version = '0.2.5'
|
17
|
+
s.date = '2014-05-23'
|
18
18
|
s.rubyforge_project = 'formatador'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
@@ -60,7 +60,10 @@ Gem::Specification.new do |s|
|
|
60
60
|
## THE MANIFEST COMMENTS, they are used as delimiters by the task.
|
61
61
|
# = MANIFEST =
|
62
62
|
s.files = %w[
|
63
|
+
CONTRIBUTING.md
|
64
|
+
CONTRIBUTORS.md
|
63
65
|
Gemfile
|
66
|
+
LICENSE.md
|
64
67
|
README.rdoc
|
65
68
|
Rakefile
|
66
69
|
changelog.txt
|
data/lib/formatador.rb
CHANGED
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), 'formatador', 'progressbar')
|
|
3
3
|
|
4
4
|
class Formatador
|
5
5
|
|
6
|
-
VERSION = '0.2.
|
6
|
+
VERSION = '0.2.5'
|
7
7
|
|
8
8
|
STYLES = {
|
9
9
|
:"\/" => "0",
|
@@ -90,6 +90,7 @@ class Formatador
|
|
90
90
|
def indent(&block)
|
91
91
|
@indent += 1
|
92
92
|
yield
|
93
|
+
ensure
|
93
94
|
@indent -= 1
|
94
95
|
end
|
95
96
|
|
@@ -1,5 +1,36 @@
|
|
1
|
+
require 'thread'
|
2
|
+
|
1
3
|
class Formatador
|
2
4
|
|
5
|
+
class ProgressBar
|
6
|
+
|
7
|
+
attr_accessor :current, :total, :opts
|
8
|
+
|
9
|
+
def initialize(total, opts = {}, &block)
|
10
|
+
@current = opts.delete(:start) || 0
|
11
|
+
@total = total.to_i
|
12
|
+
@opts = opts
|
13
|
+
@lock = Mutex.new
|
14
|
+
@complete_proc = block_given? ? block : Proc.new { }
|
15
|
+
end
|
16
|
+
|
17
|
+
def increment(increment = 1)
|
18
|
+
@lock.synchronize do
|
19
|
+
return if complete?
|
20
|
+
@current += increment.to_i
|
21
|
+
@complete_proc.call(self) if complete?
|
22
|
+
Formatador.redisplay_progressbar(current, total, opts)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def complete?
|
29
|
+
current == total
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
3
34
|
def redisplay_progressbar(current, total, options = {})
|
4
35
|
options = { :color => 'white', :width => 50, :new_line => true }.merge!(options)
|
5
36
|
data = progressbar(current, total, options)
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formatador
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- geemus (Wesley Beary)
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-05-23 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ! '>='
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: shindo
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ! '>='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ! '>='
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -50,7 +45,10 @@ extensions: []
|
|
50
45
|
extra_rdoc_files:
|
51
46
|
- README.rdoc
|
52
47
|
files:
|
48
|
+
- CONTRIBUTING.md
|
49
|
+
- CONTRIBUTORS.md
|
53
50
|
- Gemfile
|
51
|
+
- LICENSE.md
|
54
52
|
- README.rdoc
|
55
53
|
- Rakefile
|
56
54
|
- changelog.txt
|
@@ -63,30 +61,27 @@ files:
|
|
63
61
|
- tests/tests_helper.rb
|
64
62
|
homepage: http://github.com/geemus/formatador
|
65
63
|
licenses: []
|
64
|
+
metadata: {}
|
66
65
|
post_install_message:
|
67
66
|
rdoc_options:
|
68
67
|
- --charset=UTF-8
|
69
68
|
require_paths:
|
70
69
|
- lib
|
71
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
-
none: false
|
73
71
|
requirements:
|
74
72
|
- - ! '>='
|
75
73
|
- !ruby/object:Gem::Version
|
76
74
|
version: '0'
|
77
|
-
segments:
|
78
|
-
- 0
|
79
|
-
hash: 26397976056427726
|
80
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
76
|
requirements:
|
83
77
|
- - ! '>='
|
84
78
|
- !ruby/object:Gem::Version
|
85
79
|
version: '0'
|
86
80
|
requirements: []
|
87
81
|
rubyforge_project: formatador
|
88
|
-
rubygems_version:
|
82
|
+
rubygems_version: 2.2.2
|
89
83
|
signing_key:
|
90
84
|
specification_version: 2
|
91
85
|
summary: Ruby STDOUT text formatting
|
92
86
|
test_files: []
|
87
|
+
has_rdoc:
|