bars 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/bin/bars +0 -1
  2. data/lib/bars.rb +9 -21
  3. 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
@@ -7,31 +7,19 @@ class Bars
7
7
  end
8
8
 
9
9
  def print(options={})
10
- print_mode = options.delete(:print_mode) { 'bars' }
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
- done_percent = (done.to_f/goal)
18
- if print_mode == 'percent'
19
- left_side = "#{task}:".ljust(line_width)
20
- right_side = "#{(done_percent * 100).floor}%".rjust(4)
21
- puts "--> #{left_side}#{right_side}"
22
- else
23
- puts "--> #{task}:"
24
- done_string = "+" * (done_percent * line_width)
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: 13
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 9
10
- version: 0.0.9
9
+ - 10
10
+ version: 0.0.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Robert Fletcher