bars 0.0.2 → 0.0.3
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 +14 -1
- data/lib/bars.rb +15 -11
- metadata +3 -3
data/bin/bars
CHANGED
@@ -4,5 +4,18 @@
|
|
4
4
|
|
5
5
|
require 'bars'
|
6
6
|
|
7
|
-
|
7
|
+
options = {}
|
8
|
+
ARGV.each_with_index do |arg, index|
|
9
|
+
if arg == '-p'
|
10
|
+
options[:print_mode] = :percentage
|
11
|
+
elsif arg == '-n'
|
12
|
+
if ARGV[index+1]
|
13
|
+
options[:bar_size] = ARGV[index+1]
|
14
|
+
else
|
15
|
+
raise "you need to enter a number"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
bars = Bars.new(options)
|
8
21
|
bars.print
|
data/lib/bars.rb
CHANGED
@@ -1,13 +1,9 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
|
3
3
|
class Bars
|
4
|
-
def initialize(
|
5
|
-
|
6
|
-
|
7
|
-
else
|
8
|
-
@print_mode = :bars
|
9
|
-
end
|
10
|
-
|
4
|
+
def initialize(options={})
|
5
|
+
@print_mode = options.delete(:print_mode) { :bars }
|
6
|
+
@bar_size = options.delete(:bar_size) { 20 }
|
11
7
|
@timeframes = YAML.load(File.open(File.expand_path('~/bars.yml')))
|
12
8
|
end
|
13
9
|
|
@@ -16,13 +12,21 @@ class Bars
|
|
16
12
|
@timeframes.each do |timeframe, tasks|
|
17
13
|
puts " #{timeframe.capitalize} ".center(30, "*")
|
18
14
|
tasks.each do |task, done, goal|
|
15
|
+
done_percent = (done.to_f/goal)
|
19
16
|
if @print_mode == :percentage
|
20
|
-
puts "--> #{task}: #{(
|
17
|
+
puts "--> #{task}: #{(done_percent * 100).floor}%"
|
21
18
|
else
|
22
19
|
puts "--> #{task}:"
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
done_string = "+" * (done_percent * @bar_size)
|
21
|
+
todo_string = "-" * (@bar_size - done_string.length)
|
22
|
+
if done == 0
|
23
|
+
splitter = '-'
|
24
|
+
elsif done == goal
|
25
|
+
splitter = '+'
|
26
|
+
else
|
27
|
+
splitter = '|'
|
28
|
+
end
|
29
|
+
puts " |#{done_string}#{splitter}#{todo_string}|"
|
26
30
|
end
|
27
31
|
end
|
28
32
|
puts
|
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: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Robert Fletcher
|