simple_calendar 2.4.1 → 2.4.2

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
  SHA256:
3
- metadata.gz: 60dcc26bdf5d0e6bc7eed23fe0bf3d5c35977b8a189b9a045897410abc4ce36e
4
- data.tar.gz: cc92323a3b5766f2f428ff1e3adfa40641843ddd5fce25068aeb7eee224ca710
3
+ metadata.gz: 63d197eaa28493e06d8dc46901a694f045ab97828fe9d4aa15f464885ba111d3
4
+ data.tar.gz: 19142bc24ec86bde21bde2ecb016f45bff50d7980fdc34e662223ecc86d7baf6
5
5
  SHA512:
6
- metadata.gz: d7ad3f165f583b789c6b8f8300c8377eac55cac5cb138429435185a6f50ee4b4b276b4d56e75e396ff1bce3f612b9029f1aa69023e6464346de3118d1aa3d580
7
- data.tar.gz: 994a400d806c3a3c06939828d64254efad0dd04c34c00dab5a21a842e7ff7460d4e9bb2cb988cedeec0686360e91f53ebe99697979aaf5d23ab342136c771137
6
+ metadata.gz: b9b4785dd7284857513ae068d5400659dd81970169f2c1508fe85459a8ff1e48848f1157e11c6ce5fa1785f08eb12485d2f21e12e7f5ee2d2e08869d161ac8f0
7
+ data.tar.gz: a6329290641565e430a3f9ab089d1da639fe69a9d5b5715b9846b2b987dd0d8d8aa7c850b94c1238e21357a47a1c4bff9c39a9e76ecb0370bd29ef553c22394f
@@ -0,0 +1,43 @@
1
+ name: Tests
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - '*'
7
+ push:
8
+ branches:
9
+ - master
10
+ jobs:
11
+ tests:
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby: [ '2.6', '2.7', '3.0']
16
+ gemfile:
17
+ - rails_6
18
+ - rails_6_1
19
+ - rails_master
20
+ env:
21
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
22
+ BUNDLE_PATH_RELATIVE_TO_CWD: true
23
+
24
+ steps:
25
+ - uses: actions/checkout@master
26
+
27
+ - name: Set up Ruby
28
+ uses: ruby/setup-ruby@v1
29
+ with:
30
+ ruby-version: ${{ matrix.ruby }}
31
+ bundler: default
32
+ bundler-cache: true
33
+
34
+ - name: StandardRb check
35
+ run: bundle exec standardrb
36
+
37
+ - name: Run tests
38
+ env:
39
+ DATABASE_URL: "sqlite3:noticed_test"
40
+ RAILS_ENV: test
41
+ run: |
42
+ bundle exec rails db:test:prepare
43
+ bundle exec rails test
data/Appraisals ADDED
@@ -0,0 +1,11 @@
1
+ appraise "rails-6" do
2
+ gem "rails", "~> 6.0.0"
3
+ end
4
+
5
+ appraise "rails-6-1" do
6
+ gem "rails", "~> 6.1.0"
7
+ end
8
+
9
+ appraise "rails-master" do
10
+ gem "rails", github: "rails/rails"
11
+ end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 2.4.2
2
+
3
+ * Translation improvements - @fwolfst
4
+
1
5
  ### 2.4.1
2
6
 
3
7
  * [FIX] Use iso8601 format for start_date links in the header. Fixes any
data/Gemfile CHANGED
@@ -1,3 +1,6 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
+
5
+ gem "appraisal"
6
+ gem "standard"
data/README.md CHANGED
@@ -1,16 +1,17 @@
1
- ![travis ci](https://travis-ci.org/excid3/simple_calendar.svg?branch=master)
1
+ # Simple Calendar
2
2
 
3
- Simple Calendar
4
- ===============
3
+ ### 📆 A calendar for your Ruby on Rails app.
5
4
 
6
- Simple Calendar is designed to do one thing really really well: render a
7
- calendar. It lets you render a calendar of any size. Maybe you want a
5
+ [![Build Status](https://github.com/excid3/simple_calendar/workflows/Tests/badge.svg)](https://github.com/excid3/simple_calendar/actions) [![Gem Version](https://badge.fury.io/rb/simple_calendar.svg)](https://badge.fury.io/rb/simple_calendar)
6
+
7
+ Simple Calendar is designed to do one thing really really well: render a calendar.
8
+
9
+ It lets you render a calendar of any size. Maybe you want a
8
10
  day view, a 4 day agenda, a week view, a month view, or a 6 week
9
11
  calendar. You can do all of that with the new gem, just give it a range
10
12
  of dates to render.
11
13
 
12
- It doesn't depend on any ORM so you're free to use it with ActiveRecord,
13
- Mongoid, any other ORM, or pure Ruby objects.
14
+ It doesn't depend on any ORM so you're free to use it with ActiveRecord, Mongoid, any other ORM, or pure Ruby objects.
14
15
 
15
16
  Thanks to all contributors for your wonderful help!
16
17
 
@@ -21,7 +22,7 @@ Installation
21
22
 
22
23
  Just add this into your Gemfile followed by a bundle install:
23
24
  ```ruby
24
- gem "simple_calendar", "~> 2.0"
25
+ gem "simple_calendar", "~> 2.4"
25
26
  ```
26
27
 
27
28
  If you're using Bootstrap, the calendar should already have a border and
@@ -34,6 +35,13 @@ your `app/assets/stylesheets/application.css` file:
34
35
  *= require simple_calendar
35
36
  ```
36
37
 
38
+ or in your SCSS `app/assets/stylesheets/application.scss` file:
39
+
40
+ ```scss
41
+ @import "simple_calendar";
42
+ ```
43
+
44
+
37
45
  Usage
38
46
  -----
39
47
 
@@ -62,7 +70,7 @@ To show the day of the month instead of the date, use `<%= date.day %>`
62
70
  You can generate a week calendar with the `week_calendar` method.
63
71
 
64
72
  ```erb
65
- <%= week_calendar number_of_weeks: 2 do |date| %>
73
+ <%= week_calendar(number_of_weeks: 2) do |date| %>
66
74
  <%= date %>
67
75
  <% end %>
68
76
  ```
@@ -74,7 +82,7 @@ Setting `number_of_weeks` is optional and defaults to 1.
74
82
  You can generate calendars of any length by passing in the number of days you want to render.
75
83
 
76
84
  ```erb
77
- <%= calendar number_of_days: 4 do |date| %>
85
+ <%= calendar(number_of_days: 4) do |date| %>
78
86
  <%= date %>
79
87
  <% end %>
80
88
  ```
@@ -87,7 +95,7 @@ You can pass in `start_date_param` to change the name of the parameter
87
95
  in the URL for the current calendar view.
88
96
 
89
97
  ```erb
90
- <%= calendar start_date_param: :my_date do |date| %>
98
+ <%= calendar(start_date_param: :my_date) do |date| %>
91
99
  <%= date %>
92
100
  <% end %>
93
101
  ```
@@ -97,11 +105,38 @@ in the URL for the current calendar view.
97
105
  You can set a different partial name for calendars by passing the partial path.
98
106
 
99
107
  ```erb
100
- <%= calendar partial: 'products/calendar' do |date| %>
108
+ <%= calendar(partial: 'products/calendar') do |date| %>
101
109
  <%= date %>
102
110
  <% end %>
103
111
  ```
104
112
 
113
+ ### Internationalization (I18n)
114
+
115
+ The default views are prepared to do translation lookups for month names and weekdays.
116
+
117
+ To profit from that, you can take advantage of the [`rails-i18n`](https://github.com/svenfuchs/rails-i18n/) gem which comes with translations for many languages already.
118
+
119
+ In a Rails 6 app, the configuration could look like the following:
120
+
121
+ * Add `gem 'rails-i18n'` to your `Gemfile` and run `bundle`.
122
+ * Define the available and default locale e.g. in `config/application.rb`:
123
+ ```ruby
124
+ # config/application.rb
125
+ config.i18n.available_locales = [:en, :de, :fr]
126
+ config.i18n.default_locale = :en
127
+ ```
128
+ * Define the following translation keys:
129
+ ```yaml
130
+ # e.g. config/locales/de.yml
131
+ de:
132
+ simple_calendar:
133
+ previous: "<<"
134
+ next: ">>"
135
+ week: Woche
136
+ ```
137
+
138
+ See the [Rails I18n Guide](https://guides.rubyonrails.org/i18n.html) for further information.
139
+
105
140
  ## Rendering Events
106
141
 
107
142
  What's a calendar without events in it? There are two simple steps for creating
@@ -120,7 +155,7 @@ $ rails g scaffold Meeting name start_time:datetime
120
155
  $ rails g scaffold Meeting name start_time:datetime end_time:datetime
121
156
  ```
122
157
 
123
- By default it uses `start_time` as the attribute name.
158
+ By default it uses `start_time` as the attribute name.
124
159
  **If you'd like to use another attribute other than start_time, just
125
160
  pass it in as the `attribute`**
126
161
 
@@ -160,7 +195,9 @@ We'll just load up all the meetings for this example.
160
195
 
161
196
  ```ruby
162
197
  def index
163
- @meetings = Meeting.all
198
+ # Scope your query to the dates being shown:
199
+ start_date = params.fetch(:start_date, Date.today).to_date
200
+ @meetings = Meeting.where(starts_at: start_date.beginning_of_month.beginning_of_week..start_date.end_of_month.end_of_week)
164
201
  end
165
202
  ```
166
203
 
@@ -168,7 +205,7 @@ Then in your view, you can pass in the `events` option to render. The
168
205
  meetings will automatically be filtered out by day for you.
169
206
 
170
207
  ```erb
171
- <%= month_calendar events: @meetings do |date, meetings| %>
208
+ <%= month_calendar(events: @meetings) do |date, meetings| %>
172
209
  <%= date %>
173
210
 
174
211
  <% meetings.each do |meeting| %>
@@ -383,6 +420,10 @@ Chris Oliver <chris@gorails.com>
383
420
 
384
421
  [@excid3](https://twitter.com/excid3)
385
422
 
423
+ ## License
424
+
425
+ Simple Calendar is licensed under the [MIT License](LICENSE.txt).
426
+
386
427
  ## Support
387
428
 
388
429
  Need help
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
3
  begin
4
- require 'rspec/core/rake_task'
4
+ require "rspec/core/rake_task"
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
  task default: :spec
7
7
  rescue LoadError
@@ -2,11 +2,11 @@
2
2
  <div class="calendar-heading">
3
3
  <%= link_to t('simple_calendar.previous', default: 'Previous'), calendar.url_for_previous_view %>
4
4
  <% if calendar.number_of_weeks == 1 %>
5
- <span class="calendar-title">Week <%= calendar.week_number %></span>
6
- <%else%>
7
- <span class="calendar-title">Week <%= calendar.week_number %> - <%= calendar.end_week %></span>
8
- <%end%>
9
- <%= link_to t('simple_calendar.next', default: 'Next'), calendar.url_for_next_view %>
5
+ <span class="calendar-title"><%= t('simple_calendar.week', default: 'Week') %> <%= calendar.week_number %></span>
6
+ <% else %>
7
+ <span class="calendar-title"><%= t('simple_calendar.week', default: 'Week') %> <%= calendar.week_number %> - <%= calendar.end_week %></span>
8
+ <% end %>
9
+ <%= link_to t('simple_calendar.next', default: 'Next'), calendar.url_for_next_view %>
10
10
  </div>
11
11
 
12
12
  <table class="table table-striped">
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "standard"
7
+ gem "rails", "~> 6.0.0"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,197 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ simple_calendar (2.4.2)
5
+ rails (>= 3.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actioncable (6.0.3.4)
11
+ actionpack (= 6.0.3.4)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailbox (6.0.3.4)
15
+ actionpack (= 6.0.3.4)
16
+ activejob (= 6.0.3.4)
17
+ activerecord (= 6.0.3.4)
18
+ activestorage (= 6.0.3.4)
19
+ activesupport (= 6.0.3.4)
20
+ mail (>= 2.7.1)
21
+ actionmailer (6.0.3.4)
22
+ actionpack (= 6.0.3.4)
23
+ actionview (= 6.0.3.4)
24
+ activejob (= 6.0.3.4)
25
+ mail (~> 2.5, >= 2.5.4)
26
+ rails-dom-testing (~> 2.0)
27
+ actionpack (6.0.3.4)
28
+ actionview (= 6.0.3.4)
29
+ activesupport (= 6.0.3.4)
30
+ rack (~> 2.0, >= 2.0.8)
31
+ rack-test (>= 0.6.3)
32
+ rails-dom-testing (~> 2.0)
33
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
34
+ actiontext (6.0.3.4)
35
+ actionpack (= 6.0.3.4)
36
+ activerecord (= 6.0.3.4)
37
+ activestorage (= 6.0.3.4)
38
+ activesupport (= 6.0.3.4)
39
+ nokogiri (>= 1.8.5)
40
+ actionview (6.0.3.4)
41
+ activesupport (= 6.0.3.4)
42
+ builder (~> 3.1)
43
+ erubi (~> 1.4)
44
+ rails-dom-testing (~> 2.0)
45
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
46
+ activejob (6.0.3.4)
47
+ activesupport (= 6.0.3.4)
48
+ globalid (>= 0.3.6)
49
+ activemodel (6.0.3.4)
50
+ activesupport (= 6.0.3.4)
51
+ activerecord (6.0.3.4)
52
+ activemodel (= 6.0.3.4)
53
+ activesupport (= 6.0.3.4)
54
+ activestorage (6.0.3.4)
55
+ actionpack (= 6.0.3.4)
56
+ activejob (= 6.0.3.4)
57
+ activerecord (= 6.0.3.4)
58
+ marcel (~> 0.3.1)
59
+ activesupport (6.0.3.4)
60
+ concurrent-ruby (~> 1.0, >= 1.0.2)
61
+ i18n (>= 0.7, < 2)
62
+ minitest (~> 5.1)
63
+ tzinfo (~> 1.1)
64
+ zeitwerk (~> 2.2, >= 2.2.2)
65
+ appraisal (2.3.0)
66
+ bundler
67
+ rake
68
+ thor (>= 0.14.0)
69
+ ast (2.4.2)
70
+ builder (3.2.4)
71
+ concurrent-ruby (1.1.8)
72
+ crass (1.0.6)
73
+ diff-lcs (1.4.4)
74
+ erubi (1.10.0)
75
+ globalid (0.4.2)
76
+ activesupport (>= 4.2.0)
77
+ i18n (1.8.8)
78
+ concurrent-ruby (~> 1.0)
79
+ loofah (2.9.0)
80
+ crass (~> 1.0.2)
81
+ nokogiri (>= 1.5.9)
82
+ mail (2.7.1)
83
+ mini_mime (>= 0.1.1)
84
+ marcel (0.3.3)
85
+ mimemagic (~> 0.3.2)
86
+ method_source (1.0.0)
87
+ mimemagic (0.3.6)
88
+ mini_mime (1.0.2)
89
+ mini_portile2 (2.5.0)
90
+ minitest (5.14.3)
91
+ nio4r (2.5.4)
92
+ nokogiri (1.11.1)
93
+ mini_portile2 (~> 2.5.0)
94
+ racc (~> 1.4)
95
+ nokogiri (1.11.1-x86_64-darwin)
96
+ racc (~> 1.4)
97
+ nokogiri (1.11.1-x86_64-linux)
98
+ racc (~> 1.4)
99
+ parallel (1.20.1)
100
+ parser (3.0.0.0)
101
+ ast (~> 2.4.1)
102
+ racc (1.5.2)
103
+ rack (2.2.3)
104
+ rack-test (1.1.0)
105
+ rack (>= 1.0, < 3)
106
+ rails (6.0.3.4)
107
+ actioncable (= 6.0.3.4)
108
+ actionmailbox (= 6.0.3.4)
109
+ actionmailer (= 6.0.3.4)
110
+ actionpack (= 6.0.3.4)
111
+ actiontext (= 6.0.3.4)
112
+ actionview (= 6.0.3.4)
113
+ activejob (= 6.0.3.4)
114
+ activemodel (= 6.0.3.4)
115
+ activerecord (= 6.0.3.4)
116
+ activestorage (= 6.0.3.4)
117
+ activesupport (= 6.0.3.4)
118
+ bundler (>= 1.3.0)
119
+ railties (= 6.0.3.4)
120
+ sprockets-rails (>= 2.0.0)
121
+ rails-dom-testing (2.0.3)
122
+ activesupport (>= 4.2.0)
123
+ nokogiri (>= 1.6)
124
+ rails-html-sanitizer (1.3.0)
125
+ loofah (~> 2.3)
126
+ railties (6.0.3.4)
127
+ actionpack (= 6.0.3.4)
128
+ activesupport (= 6.0.3.4)
129
+ method_source
130
+ rake (>= 0.8.7)
131
+ thor (>= 0.20.3, < 2.0)
132
+ rainbow (3.0.0)
133
+ rake (13.0.3)
134
+ regexp_parser (2.0.3)
135
+ rexml (3.2.4)
136
+ rspec (3.10.0)
137
+ rspec-core (~> 3.10.0)
138
+ rspec-expectations (~> 3.10.0)
139
+ rspec-mocks (~> 3.10.0)
140
+ rspec-core (3.10.1)
141
+ rspec-support (~> 3.10.0)
142
+ rspec-expectations (3.10.1)
143
+ diff-lcs (>= 1.2.0, < 2.0)
144
+ rspec-support (~> 3.10.0)
145
+ rspec-mocks (3.10.2)
146
+ diff-lcs (>= 1.2.0, < 2.0)
147
+ rspec-support (~> 3.10.0)
148
+ rspec-support (3.10.2)
149
+ rubocop (1.8.1)
150
+ parallel (~> 1.10)
151
+ parser (>= 3.0.0.0)
152
+ rainbow (>= 2.2.2, < 4.0)
153
+ regexp_parser (>= 1.8, < 3.0)
154
+ rexml
155
+ rubocop-ast (>= 1.2.0, < 2.0)
156
+ ruby-progressbar (~> 1.7)
157
+ unicode-display_width (>= 1.4.0, < 3.0)
158
+ rubocop-ast (1.4.1)
159
+ parser (>= 2.7.1.5)
160
+ rubocop-performance (1.9.2)
161
+ rubocop (>= 0.90.0, < 2.0)
162
+ rubocop-ast (>= 0.4.0)
163
+ ruby-progressbar (1.11.0)
164
+ sprockets (4.0.2)
165
+ concurrent-ruby (~> 1.0)
166
+ rack (> 1, < 3)
167
+ sprockets-rails (3.2.2)
168
+ actionpack (>= 4.0)
169
+ activesupport (>= 4.0)
170
+ sprockets (>= 3.0.0)
171
+ standard (0.12.0)
172
+ rubocop (= 1.8.1)
173
+ rubocop-performance (= 1.9.2)
174
+ thor (1.1.0)
175
+ thread_safe (0.3.6)
176
+ tzinfo (1.2.9)
177
+ thread_safe (~> 0.1)
178
+ unicode-display_width (2.0.0)
179
+ websocket-driver (0.7.3)
180
+ websocket-extensions (>= 0.1.0)
181
+ websocket-extensions (0.1.5)
182
+ zeitwerk (2.4.2)
183
+
184
+ PLATFORMS
185
+ ruby
186
+ x86_64-darwin-20
187
+ x86_64-linux
188
+
189
+ DEPENDENCIES
190
+ appraisal
191
+ rails (~> 6.0.0)
192
+ rspec
193
+ simple_calendar!
194
+ standard
195
+
196
+ BUNDLED WITH
197
+ 2.2.13