bars 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/bars +3 -3
  2. data/lib/bars.rb +6 -4
  3. metadata +3 -3
data/bin/bars CHANGED
@@ -6,9 +6,9 @@ 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
- opt :bar_size, "Set bar size", :short => 'b', :type => :int, :default => 20
11
- opt :file_path, "File path, default ~/bars.yml", :short => '-f', :default => '~/bars.yml'
9
+ opt :print_mode, "Output format, percent or bars", :short => 'p', :default => 'bars'
10
+ opt :line_width, "Set bar size", :short => 'w', :type => :int, :default => 20
11
+ opt :file_path, "File path, default ~/bars.yml", :short => 'f', :default => '~/bars.yml'
12
12
  end
13
13
 
14
14
  bars = Bars.new(options)
@@ -8,7 +8,7 @@ class Bars
8
8
 
9
9
  def print(options={})
10
10
  print_mode = options.delete(:print_mode) { 'bars' }
11
- bar_size = options.delete(:bar_size) { 20 } - 1
11
+ line_width = options.delete(:line_width) { 20 } - 1
12
12
 
13
13
  puts
14
14
  @timeframes.each do |timeframe, tasks|
@@ -16,11 +16,13 @@ class Bars
16
16
  tasks.each do |task, done, goal|
17
17
  done_percent = (done.to_f/goal)
18
18
  if print_mode == 'percent'
19
- puts "--> #{task}: #{(done_percent * 100).floor}%"
19
+ left_side = "#{task}:".ljust(line_width)
20
+ right_side = "#{(done_percent * 100).floor}%".rjust(4)
21
+ puts "--> #{left_side}#{right_side}"
20
22
  else
21
23
  puts "--> #{task}:"
22
- done_string = "+" * (done_percent * bar_size)
23
- todo_string = "-" * (bar_size - done_string.length)
24
+ done_string = "+" * (done_percent * line_width)
25
+ todo_string = "-" * (line_width - done_string.length)
24
26
  if done == 0
25
27
  splitter = '-'
26
28
  elsif done == goal
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: 17
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 7
10
- version: 0.0.7
9
+ - 8
10
+ version: 0.0.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Robert Fletcher