bars 0.0.5 → 0.0.6
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.
- data/bin/bars +3 -2
- data/lib/bars.rb +9 -7
- metadata +6 -6
data/bin/bars
CHANGED
@@ -6,9 +6,10 @@ require 'bars'
|
|
6
6
|
require 'trollop'
|
7
7
|
|
8
8
|
options = Trollop::options do
|
9
|
-
opt :
|
9
|
+
opt :print_mode, "Output format, percent or bars", :short => '-p', :default => 'bars'
|
10
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'
|
11
12
|
end
|
12
13
|
|
13
14
|
bars = Bars.new(options)
|
14
|
-
bars.print
|
15
|
+
bars.print(options)
|
data/lib/bars.rb
CHANGED
@@ -2,23 +2,25 @@ require 'yaml'
|
|
2
2
|
|
3
3
|
class Bars
|
4
4
|
def initialize(options={})
|
5
|
-
|
6
|
-
@
|
7
|
-
@timeframes = YAML.load(File.open(File.expand_path('~/bars.yml')))
|
5
|
+
file_path = options.delete(:file_path) { '~/bars.yml' }
|
6
|
+
@timeframes = YAML.load(File.open(File.expand_path(file_path)))
|
8
7
|
end
|
9
8
|
|
10
|
-
def print
|
9
|
+
def print(options={})
|
10
|
+
print_mode = options.delete(:print_mode) { 'bars' }
|
11
|
+
bar_size = options.delete(:bar_size) { 20 } - 1
|
12
|
+
|
11
13
|
puts
|
12
14
|
@timeframes.each do |timeframe, tasks|
|
13
15
|
puts " #{timeframe.capitalize} ".center(30, "*")
|
14
16
|
tasks.each do |task, done, goal|
|
15
17
|
done_percent = (done.to_f/goal)
|
16
|
-
if
|
18
|
+
if print_mode == 'percent'
|
17
19
|
puts "--> #{task}: #{(done_percent * 100).floor}%"
|
18
20
|
else
|
19
21
|
puts "--> #{task}:"
|
20
|
-
done_string = "+" * (done_percent *
|
21
|
-
todo_string = "-" * (
|
22
|
+
done_string = "+" * (done_percent * bar_size)
|
23
|
+
todo_string = "-" * (bar_size - done_string.length)
|
22
24
|
if done == 0
|
23
25
|
splitter = '-'
|
24
26
|
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:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 6
|
10
|
+
version: 0.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Robert Fletcher
|
@@ -15,11 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-15 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
22
|
-
description: bars reads ~/
|
22
|
+
description: bars reads ~/bars.yml and outputs the result in bar format
|
23
23
|
email: lobatifricha@gmail.com
|
24
24
|
executables:
|
25
25
|
- bars
|
@@ -31,7 +31,7 @@ files:
|
|
31
31
|
- lib/bars.rb
|
32
32
|
- bin/bars
|
33
33
|
has_rdoc: true
|
34
|
-
homepage:
|
34
|
+
homepage: https://github.com/mockdeep/bars
|
35
35
|
licenses: []
|
36
36
|
|
37
37
|
post_install_message:
|