habiter 0.1.5 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README +20 -2
  2. data/bin/habiter +24 -5
  3. metadata +2 -2
data/README CHANGED
@@ -13,8 +13,24 @@ clean_room is not a habit yet. create and complete it? (y/n) y
13
13
  ~$ habiter did jog
14
14
  jog is not a habit yet. create and complete it? (y/n) y
15
15
  ~$ habiter log
16
- jog | ------------------------------+
17
- clean_room | ------------------------------+
16
+ jog |----------------------------+|(1/28)
17
+ project |-------------------------++-+|(3/28)
18
+ practice_music |-----------------------+++++-|(5/28)
19
+ read_30m |-----------------------+--++-|(3/28)
20
+ clean_room |-----------------------+-+---|(2/28)
21
+
22
+ Scalars
23
+ -------
24
+
25
+ Habiter also now supports scalars: you can input a value for your
26
+ activity, like
27
+
28
+ habiter did jog 5.5
29
+ habiter did heartbeat 78
30
+
31
+ And it will be recorded. There is no representation of this data yet,
32
+ and the representation within habiter will be minimal, only good output to
33
+ formats which are easily visualized.
18
34
 
19
35
  Install
20
36
  -------
@@ -34,3 +50,5 @@ Edit ~/.habiter.yaml
34
50
  * How do I reset habiter?
35
51
 
36
52
  echo > ~/.habiter.yaml
53
+
54
+ Dedicated to Bryn Bellomy :)
data/bin/habiter CHANGED
@@ -36,21 +36,26 @@ end
36
36
  options = {}
37
37
 
38
38
  optparse = OptionParser.new do |opts|
39
- opts.banner = "Usage: habiter.rb did your_habit"
39
+ opts.banner =
40
+ "Usage:
41
+ habiter did your_habit
42
+ habiter log"
40
43
  options[:verbose] = false
41
44
  opts.on('-v', '--verbose', "Show weekday letters for log") do
42
45
  options[:verbose] = true
43
46
  end
44
47
  end
45
48
 
46
- def did(key)
49
+ def did(args)
50
+ key = args[1]
51
+ new_record = (args.length > 2) ? {Time.now => args[2]} : Time.now
47
52
  if not @habits.has_key?(key)
48
53
  print "#{key} is not a habit yet. create and complete it? (y/n) "
49
54
  if STDIN.gets.chomp == 'y'
50
- @habits[key] = [Time.now]
55
+ @habits[key] = [new_record]
51
56
  end
52
57
  else
53
- @habits[key] << Time.now
58
+ @habits[key] << new_record
54
59
  end
55
60
  File.open(@habiter_file, 'w') do |f|
56
61
  YAML.dump(@habits, f)
@@ -69,13 +74,19 @@ def log(options={})
69
74
  end
70
75
  puts
71
76
  end
77
+ daily_counts = Array.new(29, 0)
72
78
  @habits.each do |habit, times|
73
79
  day = Date.today - (options[:days])
74
80
  print (sprintf("%#{name_column_width}s ", habit) + "|").colorize(37)
75
81
  times.collect! do |time|
82
+ if time.is_a? Hash
83
+ # For scalar values, normalize
84
+ time = time.keys.first
85
+ end
76
86
  if time.is_a? Time
77
87
  time.to_date
78
88
  elsif time.is_a? Date
89
+ # For user-inputted values, normalize
79
90
  time
80
91
  end
81
92
  end
@@ -83,6 +94,7 @@ def log(options={})
83
94
  (0..options[:days]).each do |i|
84
95
  if times.include? day
85
96
  print "+".colorize(47)
97
+ daily_counts[i] += 1
86
98
  done_in_last_28 += 1
87
99
  pre_week += 1 unless i >= 20
88
100
  week += 1 unless i < 20
@@ -100,12 +112,19 @@ def log(options={})
100
112
  end
101
113
  puts
102
114
  end
115
+ if options[:verbose]
116
+ print " " * (name_column_width + 2)
117
+ (0..options[:days]).each do |i|
118
+ print (daily_counts[i] > 0) ? daily_counts[i] : " "
119
+ end
120
+ puts
121
+ end
103
122
  end
104
123
 
105
124
  optparse.parse!
106
125
 
107
126
  if ARGV[0] == 'did'
108
- did(ARGV[1])
127
+ did(ARGV)
109
128
  elsif ARGV[0] == 'log'
110
129
  log(options)
111
130
  else
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: habiter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: "0.2"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom MacWright
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-03 00:00:00 -05:00
12
+ date: 2009-11-06 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15