bars 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/bars +0 -1
- data/lib/bars.rb +9 -21
- metadata +3 -3
data/bin/bars
CHANGED
@@ -6,7 +6,6 @@ require 'bars'
|
|
6
6
|
require 'trollop'
|
7
7
|
|
8
8
|
options = Trollop::options do
|
9
|
-
opt :print_mode, "Output format, percent or bars", :short => 'p', :default => 'bars'
|
10
9
|
opt :line_width, "Set bar size", :short => 'w', :type => :int, :default => 20
|
11
10
|
opt :file_path, "File path, default ~/bars.yml", :short => 'f', :default => '~/bars.yml'
|
12
11
|
end
|
data/lib/bars.rb
CHANGED
@@ -7,31 +7,19 @@ class Bars
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def print(options={})
|
10
|
-
|
11
|
-
line_width = options.delete(:line_width) { 20 } - 1
|
10
|
+
line_width = options.delete(:line_width) { 25 } - 1
|
12
11
|
|
13
12
|
puts
|
14
13
|
@timeframes.each do |timeframe, tasks|
|
15
|
-
puts " #{timeframe.capitalize} ".center(30, "*")
|
16
14
|
tasks.each do |task, done, goal|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
todo_string = "-" * (line_width - done_string.length)
|
26
|
-
if done == 0
|
27
|
-
splitter = '-'
|
28
|
-
elsif done == goal
|
29
|
-
splitter = '+'
|
30
|
-
else
|
31
|
-
splitter = '|'
|
32
|
-
end
|
33
|
-
puts " |#{done_string}#{splitter}#{todo_string}|"
|
34
|
-
end
|
15
|
+
percent = (done.to_f/goal)
|
16
|
+
count = (percent * line_width.to_f).round
|
17
|
+
done_string = "█" * (count)
|
18
|
+
todo_string = "┅" * (line_width - count)
|
19
|
+
percent_string = sprintf("%.1f%", (percent * 100)).rjust(6)
|
20
|
+
goal_string = "#{done}/#{goal}".rjust(7)
|
21
|
+
puts "#{task.ljust(line_width - 7)}#{goal_string}"
|
22
|
+
puts "#{done_string}#{todo_string}#{percent_string}"
|
35
23
|
end
|
36
24
|
puts
|
37
25
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bars
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 10
|
10
|
+
version: 0.0.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Robert Fletcher
|