habits 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/habits/habit.rb +10 -4
  2. metadata +5 -7
data/lib/habits/habit.rb CHANGED
@@ -76,6 +76,7 @@ module Habits
76
76
  end
77
77
 
78
78
  def save
79
+ validate_zones
79
80
  @@all = nil
80
81
  FileUtils.rm_f(file_path(@old_title)) if @old_title
81
82
  FileUtils.mkdir_p HABITS_DIR
@@ -96,10 +97,11 @@ module Habits
96
97
  end
97
98
 
98
99
  def activities_on_week(week, day=nil)
99
- activities = @events.select do |e|
100
- e.is_a?(Events::Activity) and Date.new(e.applied_at.year,
101
- e.applied_at.month,
102
- e.applied_at.day).cweek == week
100
+ activities = @events.select do |e|
101
+ e.is_a?(Events::Activity) and e.applied_at.year == Date.today.year and
102
+ Date.new(e.applied_at.year,
103
+ e.applied_at.month,
104
+ e.applied_at.day).cweek == week
103
105
  end
104
106
  activities = activities.select{|a| a.applied_at.strftime('%a') == day} if day
105
107
  activities
@@ -162,6 +164,10 @@ module Habits
162
164
  save
163
165
  end
164
166
 
167
+ def validate_zones
168
+ raise "Yellow zone must be before red zone." if self.yellow_zone <= self.red_zone
169
+ end
170
+
165
171
  end
166
172
 
167
173
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: habits
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Antti Hakala
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-14 00:00:00 +03:00
19
- default_executable:
18
+ date: 2011-09-27 00:00:00 Z
20
19
  dependencies: []
21
20
 
22
21
  description: A habit tracker. Tracks habits in weekly cycles.Each habit has a day or days associated with it.Habits expects activity on the habit on those days. If no activity is registered, habit goes first into yellow zone (e.g. 20 hours before deadline) and then into red zone (e.g. 6 hours). And finally into missed state.Transfer into each state can be used to trigger commands.
@@ -41,7 +40,6 @@ files:
41
40
  - lib/habits/subcommand.rb
42
41
  - lib/habits/whip.rb
43
42
  - lib/habits.rb
44
- has_rdoc: true
45
43
  homepage: http://github.com/ander/habits
46
44
  licenses: []
47
45
 
@@ -71,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
69
  requirements: []
72
70
 
73
71
  rubyforge_project:
74
- rubygems_version: 1.5.0
72
+ rubygems_version: 1.8.10
75
73
  signing_key:
76
74
  specification_version: 3
77
75
  summary: A habit tracker.