simple_calendar 2.2.6 → 2.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d48c34ef8c59455fb303e967c9974f5fe8f8cd8e
4
- data.tar.gz: ddb4c3b79eed4ce5c40b699720e81e7008f1e4f5
3
+ metadata.gz: 7f4f3e0cb295f0632eee3bac373fecfabfa70643
4
+ data.tar.gz: 013c371f81fe1487985b52dd3f33d9eadafa493f
5
5
  SHA512:
6
- metadata.gz: f62df456ab1f6cd88d39c47ca837da47e5fdc8e25c5ec3c509fa31181bc60a4fd8eb361debadd006b97bf98a891af7bf2734383a4e032994fd7d24c6eae6d30d
7
- data.tar.gz: 10dfbc74095af375642fcda64b032f153d3284257bd71531bb0c3c73a0b13da819fc2a857318e89cf4cb5afd195fa3ae0703cf147abb9e26caf9647d921eff3d
6
+ metadata.gz: 98ffbd3a7116c88b0e4d3d474f473c338378e8e7b4567f0a7c0bc2bd4dc9fc34479b68035c6b0f8234f956df911b8e8b52ff68cb425531562a61cad07c7698b9
7
+ data.tar.gz: 2a9ee6d963304596ae166bf2413a7bc352a81f0bccd65ba05599119f5ff2726842a3b1bf59104a9670f8270eb2f425473c2a3efd2a4f421783c9945f63aeae28
@@ -16,7 +16,7 @@
16
16
 
17
17
  <tbody>
18
18
  <% date_range.each_slice(7) do |week| %>
19
- <tr>
19
+ <%= content_tag :tr, class: calendar.tr_classes_for(week) do %>
20
20
  <% week.each do |day| %>
21
21
  <%= content_tag :td, class: calendar.td_classes_for(day) do %>
22
22
  <% if defined?(Haml) && respond_to?(:block_is_haml?) && block_is_haml?(block) %>
@@ -26,7 +26,7 @@
26
26
  <% end %>
27
27
  <% end %>
28
28
  <% end %>
29
- </tr>
29
+ <% end %>
30
30
  <% end %>
31
31
  </tbody>
32
32
  </table>
@@ -49,6 +49,14 @@ module SimpleCalendar
49
49
  td_class
50
50
  end
51
51
 
52
+ def tr_classes_for(week)
53
+ today = Date.current
54
+ tr_class = ['week']
55
+ tr_class << 'current-week' if week.include?(today)
56
+
57
+ tr_class
58
+ end
59
+
52
60
  def url_for_next_view
53
61
  view_context.url_for(@params.merge(start_date_param => date_range.last + 1.day))
54
62
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleCalendar
2
- VERSION = "2.2.6"
2
+ VERSION = "2.2.7"
3
3
  end
@@ -113,6 +113,20 @@ describe SimpleCalendar::Calendar do
113
113
  end
114
114
  end
115
115
 
116
+ describe 'current week class' do
117
+ it 'should have the current week' do
118
+ calendar = SimpleCalendar::Calendar.new(ViewContext.new)
119
+ week = calendar.send(:date_range).each_slice(7).to_a[0]
120
+ expect(calendar.send(:tr_classes_for, week)).to include('current-week')
121
+ end
122
+
123
+ it 'should not have the current week if it does not contain today' do
124
+ calendar = SimpleCalendar::MonthCalendar.new(ViewContext.new)
125
+ week = calendar.send(:date_range).each_slice(7).to_a[0]
126
+ expect(calendar.send(:tr_classes_for, week)).to_not include('current-week')
127
+ end
128
+ end
129
+
116
130
  it 'has a param that determines the start date of the calendar'
117
131
  it 'generates a default date if no start date is present'
118
132
  it 'has a range of dates'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_calendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.6
4
+ version: 2.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-01 00:00:00.000000000 Z
11
+ date: 2017-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  requirements: []
94
94
  rubyforge_project: simple_calendar
95
- rubygems_version: 2.5.1
95
+ rubygems_version: 2.6.11
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: A simple Rails calendar