simple_calendar 2.0.3 → 2.0.5

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: cc01558b04833e1dde44995688b8237f19f4a985
4
- data.tar.gz: 584182fd18a1e913047d43b4db6f772c47469ac0
3
+ metadata.gz: 69891494cb62017e3108ade832d816c2fef2b021
4
+ data.tar.gz: f19a0f244c702b7aa4a0598793fa65a224905d71
5
5
  SHA512:
6
- metadata.gz: 8fe7ea4dea3cd558d4e966d4cdeb3c580cdf8ca59239846c5fd2db41fecd66e892e441b5e26487bcf109b2edf48c2b25855738b1abc6b358b40789a27732263b
7
- data.tar.gz: 9a43df2512a7e534589dd83e5de394ef6ff6ff4148754c7242253e80b615b9de766087bebf7c9a0de29e0ccc46a37713c94b3a57066a2aef3a82d30d31918d97
6
+ metadata.gz: 11c97daf53d52237fa6495af26fc1a6b630bd8879cc14d4dbd7cb0e72f8f9f388244a033e5c9348277cd2da095f160ae51516ba78b0c9856595d37304774b76a
7
+ data.tar.gz: f39d52be3eae79ea61b22cb814f53768a59a83c43ca1b6acfb3041ed16783a23d262b6ddcac1b4db90aaedd6aba7ca9cbc913f6e0690e390a6fa42f5aa5394db
data/.gitignore CHANGED
@@ -2,3 +2,5 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ .ruby-version
6
+ .ruby-gemset
data/README.md CHANGED
@@ -92,6 +92,16 @@ pass it in as the `attribute` option**
92
92
  <%= day %>
93
93
  <% end %>
94
94
  ```
95
+ **If you already have a model with a start time attribute called something other than `start_time` or accesses it through a relationship, you can alias the attribute by defining a `start_time` method in the my_model.rb file and not have to specify it separately as in the above example**
96
+ ```ruby
97
+ class MyModel
98
+ ## Other code related to your model lives here
99
+
100
+ def start_time
101
+ self.my_related_model.start ##Where 'start' is a attribute of type 'Date' accessible through MyModel's relationship
102
+ end
103
+ end
104
+ ```
95
105
 
96
106
  In your controller, query for these meetings and store them in an instance
97
107
  variable. Normally you'll want to search for the ones that only show up
@@ -298,7 +308,7 @@ To render this in the view, you can do:
298
308
 
299
309
  ```erb
300
310
  <%= SimpleCalendar::BusinessWeekCalendar.new(self).render do |date| %>
301
- <%= day %>
311
+ <%= date %>
302
312
  <% end %>
303
313
  ```
304
314
 
@@ -1,7 +1,7 @@
1
1
  <div class="simple-calendar">
2
- <%= link_to "Previous", start_date: date_range.first - 1.day %>
2
+ <%= link_to "Previous", url_for(params.merge(start_date: date_range.first - 1.day)) %>
3
3
  <%= I18n.t("date.month_names")[start_date.month] %> <%= start_date.year %>
4
- <%= link_to "Next", start_date: date_range.last + 1.day %>
4
+ <%= link_to "Next", url_for(params.merge(start_date: date_range.last + 1.day)) %>
5
5
 
6
6
  <table class="table table-striped">
7
7
  <thead>
@@ -1,7 +1,7 @@
1
1
  <div class="simple-calendar">
2
- <%= link_to "Previous", start_date: date_range.first - 1.day %>
2
+ <%= link_to "Previous", url_for(params.merge(start_date: date_range.first - 1.day)) %>
3
3
  <%= I18n.t("date.month_names")[start_date.month] %> <%= start_date.year %>
4
- <%= link_to "Next", start_date: date_range.last + 1.day %>
4
+ <%= link_to "Next", url_for(params.merge(start_date: date_range.last + 1.day)) %>
5
5
 
6
6
  <table class="table table-striped">
7
7
  <thead>
@@ -1,7 +1,7 @@
1
1
  <div class="simple-calendar">
2
- <%= link_to "Previous", start_date: date_range.first - 1.day %>
2
+ <%= link_to "Previous", url_for(params.merge(start_date: date_range.first - 1.day)) %>
3
3
  Week <%= start_date.strftime("%U").to_i %>
4
- <%= link_to "Next", start_date: date_range.last + 1.day %>
4
+ <%= link_to "Next", url_for(params.merge(start_date: date_range.last + 1.day)) %>
5
5
 
6
6
  <table class="table table-striped">
7
7
  <thead>
@@ -66,7 +66,11 @@ module SimpleCalendar
66
66
  end
67
67
 
68
68
  def start_date
69
- view_context.params.fetch(:start_date, Date.today).to_date
69
+ if options.has_key?(:start_date)
70
+ options.fetch(:start_date).to_date
71
+ else
72
+ view_context.params.fetch(:start_date, Date.today).to_date
73
+ end
70
74
  end
71
75
 
72
76
  def date_range
@@ -1,3 +1,3 @@
1
1
  module SimpleCalendar
2
- VERSION = "2.0.3"
2
+ VERSION = "2.0.5"
3
3
  end
@@ -45,11 +45,17 @@ describe SimpleCalendar::Calendar do
45
45
  expect(calendar.send(:start_date)).to eq(Date.today)
46
46
  end
47
47
 
48
- it "uses the params start_date to override" do
48
+ it "uses the view context's params start_date to override" do
49
49
  view_context = ViewContext.new(Date.yesterday)
50
50
  calendar = SimpleCalendar::Calendar.new(view_context)
51
51
  expect(calendar.send(:start_date)).to eq(Date.yesterday)
52
52
  end
53
+
54
+ it "uses the optional argument's start_date to override view_context's start_date" do
55
+ view_context = ViewContext.new(Date.yesterday)
56
+ calendar = SimpleCalendar::Calendar.new(view_context, start_date: Date.tomorrow)
57
+ expect(calendar.send(:start_date)).to eq(Date.tomorrow)
58
+ end
53
59
  end
54
60
 
55
61
  it 'has a param that determines the start date of the calendar'
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.0.3
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-05 00:00:00.000000000 Z
11
+ date: 2016-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails