quirk 0.0.3 → 0.0.4

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.
Files changed (3) hide show
  1. data/quirk.rb +3 -3
  2. data/quirk_test.rb +13 -0
  3. metadata +2 -2
data/quirk.rb CHANGED
@@ -2,7 +2,7 @@ require 'date'
2
2
  require 'colorize'
3
3
 
4
4
  module Quirk
5
- VERSION = '0.0.3'
5
+ VERSION = '0.0.4'
6
6
  QUIRKFILE = ENV['QUIRKFILE'] || "#{ENV['HOME']}/.quirk"
7
7
  EDITOR = ENV['EDITOR'] || 'vi'
8
8
 
@@ -82,8 +82,8 @@ module Quirk
82
82
  def color_on(date)
83
83
  hit_color = quitting? ? :light_red : :light_green
84
84
  miss_color = quitting? ? :light_green : :light_red
85
- last_date = quitting? ? (Quirk.today + 1) : Quirk.today
86
- if @marks.empty? ||
85
+ last_date = Quirk.today
86
+ if first_date.nil? ||
87
87
  date < first_date ||
88
88
  date > last_date ||
89
89
  !days.include?(date.wday)
data/quirk_test.rb CHANGED
@@ -47,11 +47,24 @@ class QuirkHabitTest < MiniTest::Unit::TestCase
47
47
  assert_equal(:white, quit.color_on(Date.new(2012, 1, 3)))
48
48
  assert_equal(:light_green, quit.color_on(Date.new(2012, 1, 4)))
49
49
  assert_equal(:light_green, quit.color_on(Date.new(2012, 1, 5)))
50
+ assert_equal(:white, quit.color_on(Date.new(2012, 1, 6)))
50
51
 
51
52
  quit.mark_first!(Date.new(2012, 1, 1))
52
53
  assert_equal(:light_green, quit.color_on(Date.new(2012, 1, 1)))
53
54
  end
54
55
 
56
+ def test_color_on_empty_quit
57
+ quit = Quirk::Habit.parse('^quit-tv: everyday')
58
+ quit.mark_first!(Date.new(2012, 1, 1))
59
+ assert_equal(:white, quit.color_on(Date.new(2011, 12, 31)))
60
+ assert_equal(:light_green, quit.color_on(Date.new(2012, 1, 1)))
61
+ assert_equal(:light_green, quit.color_on(Date.new(2012, 1, 2)))
62
+ assert_equal(:light_green, quit.color_on(Date.new(2012, 1, 3)))
63
+ assert_equal(:light_green, quit.color_on(Date.new(2012, 1, 4)))
64
+ assert_equal(:light_green, quit.color_on(Date.new(2012, 1, 5)))
65
+ assert_equal(:white, quit.color_on(Date.new(2012, 1, 6)))
66
+ end
67
+
55
68
  def test_streak
56
69
  missing = Quirk::Habit.parse('running: everyday')
57
70
  assert_equal(0, missing.streak)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quirk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: .
11
11
  cert_chain: []
12
- date: 2012-05-29 00:00:00.000000000 Z
12
+ date: 2012-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest