chronomize 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/chronomize.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "chronomize"
6
- s.version = "0.0.1"
6
+ s.version = "0.0.2"
7
7
  s.authors = ["Katrina Owen"]
8
8
  s.email = ["katrina.owen@gmail.com"]
9
9
  s.homepage = ""
data/lib/chronomize.rb CHANGED
@@ -31,7 +31,8 @@ class Chronomize
31
31
  end
32
32
 
33
33
  def label_for(date, direction = nil)
34
- pieces = [] << format(date) << chronicality(date)
34
+ label = chronicality(date)
35
+ pieces = label ? [label] : [format(date)]
35
36
  pieces.push forward if direction == :forward
36
37
  pieces.unshift backward if direction == :backward
37
38
  pieces.compact.join(" ")
@@ -43,11 +44,11 @@ class Chronomize
43
44
 
44
45
  def chronicality(date)
45
46
  if Date.yesterday?(date)
46
- "(#{yesterday})" if yesterday
47
+ yesterday
47
48
  elsif Date.today?(date)
48
- "(#{today})" if today
49
+ today
49
50
  elsif Date.tomorrow?(date)
50
- "(#{tomorrow})" if tomorrow
51
+ tomorrow
51
52
  end
52
53
  end
53
54
 
@@ -11,20 +11,21 @@ describe Chronomize do
11
11
  let(:feb9) { Date.new(2012, 2, 9) }
12
12
 
13
13
  before(:each) { Timecop.freeze(feb7) }
14
+ after(:each) { Timecop.return }
14
15
 
15
16
  context "today" do
16
17
  subject { Chronomize.new(feb7) }
17
18
 
18
- its(:previous) { should eq('February 6, 2012 (yesterday)') }
19
- its(:current) { should eq('February 7, 2012 (today)') }
20
- its(:next) { should eq('February 8, 2012 (tomorrow)') }
19
+ its(:previous) { should eq('yesterday') }
20
+ its(:current) { should eq('today') }
21
+ its(:next) { should eq('tomorrow') }
21
22
  end
22
23
 
23
24
  context "tomorrow" do
24
25
  subject { Chronomize.new(feb8) }
25
26
 
26
- its(:previous) { should eq('February 7, 2012 (today)') }
27
- its(:current) { should eq('February 8, 2012 (tomorrow)') }
27
+ its(:previous) { should eq('today') }
28
+ its(:current) { should eq('tomorrow') }
28
29
  its(:next) { should eq('February 9, 2012') }
29
30
  end
30
31
 
@@ -32,8 +33,8 @@ describe Chronomize do
32
33
  subject { Chronomize.new(feb6) }
33
34
 
34
35
  its(:previous) { should eq('February 5, 2012') }
35
- its(:current) { should eq('February 6, 2012 (yesterday)') }
36
- its(:next) { should eq('February 7, 2012 (today)') }
36
+ its(:current) { should eq('yesterday') }
37
+ its(:next) { should eq('today') }
37
38
  end
38
39
 
39
40
  context "last week" do
@@ -46,16 +47,16 @@ describe Chronomize do
46
47
  context "with symbols" do
47
48
  subject { Chronomize.new(feb6, :previous => '<~', :next => '~>') }
48
49
  its(:previous) { should eq('<~ February 5, 2012') }
49
- its(:current) { should eq('February 6, 2012 (yesterday)') }
50
- its(:next) { should eq('February 7, 2012 (today) ~>') }
50
+ its(:current) { should eq('yesterday') }
51
+ its(:next) { should eq('today ~>') }
51
52
  end
52
53
 
53
54
  context "with alternate day names" do
54
55
  subject { Chronomize.new(feb7, :today => "aujourd'hui", :yesterday => 'hier', :tomorrow => 'demain') }
55
56
 
56
- its(:previous) { should eq('February 6, 2012 (hier)') }
57
- its(:current) { should eq('February 7, 2012 (aujourd\'hui)') }
58
- its(:next) { should eq('February 8, 2012 (demain)') }
57
+ its(:previous) { should eq('hier') }
58
+ its(:current) { should eq('aujourd\'hui') }
59
+ its(:next) { should eq('demain') }
59
60
  end
60
61
 
61
62
  context "without day names" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chronomize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-07 00:00:00.000000000 Z
12
+ date: 2012-03-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70312046276940 !ruby/object:Gem::Requirement
16
+ requirement: &70305360568220 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70312046276940
24
+ version_requirements: *70305360568220
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: timecop
27
- requirement: &70312046276420 !ruby/object:Gem::Requirement
27
+ requirement: &70305360567780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70312046276420
35
+ version_requirements: *70305360567780
36
36
  description: Creates labels for a window of dates, with knowledge about it's relationship
37
37
  to the current date.
38
38
  email:
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  version: '0'
71
71
  requirements: []
72
72
  rubyforge_project: chronomize
73
- rubygems_version: 1.8.15
73
+ rubygems_version: 1.8.10
74
74
  signing_key:
75
75
  specification_version: 3
76
76
  summary: Simple dateful navigation.