Skip to content

Commit

Permalink
Depend on external holiday file
Browse files Browse the repository at this point in the history
  • Loading branch information
jamie committed Nov 20, 2021
1 parent a7f4c04 commit b3d926a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 242 deletions.
8 changes: 3 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# frozen_string_literal: true

source "https://rubygems.org"
ruby "2.6.5"
ruby "2.7.4"

gem "sinatra"
gem "thin"

gem "activesupport"
gem "holidays"
gem "icalendar"
gem "platform-api" # Heroku

group :development do
gem "standard"
end

group :test do
gem "rspec"
end
34 changes: 19 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (6.1.4.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
ast (2.4.1)
concurrent-ruby (1.1.9)
daemons (1.3.1)
diff-lcs (1.4.4)
erubis (2.7.0)
eventmachine (1.2.7)
excon (0.75.0)
Expand All @@ -12,9 +18,13 @@ GEM
excon
moneta
multi_json (>= 1.9.2)
holidays (8.4.1)
i18n (1.8.11)
concurrent-ruby (~> 1.0)
icalendar (2.6.1)
ice_cube (~> 0.16)
ice_cube (0.16.3)
minitest (5.14.4)
moneta (1.0.0)
multi_json (1.15.0)
mustermann (1.1.1)
Expand All @@ -33,19 +43,6 @@ GEM
rate_throttle_client (0.1.2)
regexp_parser (1.7.1)
rexml (3.2.4)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.3)
rubocop (0.85.1)
parallel (~> 1.10)
parser (>= 2.7.0.1)
Expand Down Expand Up @@ -74,18 +71,25 @@ GEM
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
tilt (2.0.10)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode-display_width (1.7.0)
zeitwerk (2.5.1)

PLATFORMS
ruby

DEPENDENCIES
activesupport
holidays
icalendar
platform-api
rspec
sinatra
standard
thin

RUBY VERSION
ruby 2.7.4p191

BUNDLED WITH
2.1.4
17 changes: 8 additions & 9 deletions calendar.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
$LOAD_PATH << "lib"
require "active_support"
require "holidays"

require "icalendar"

require "sinatra"

get "/" do
Expand All @@ -11,13 +12,11 @@
get "/:province.ics" do
cal = Icalendar::Calendar.new

6.times do |i|
Holiday.all(Date.today.year + i, params[:province] || Holiday.provinces).each do |holiday|
cal.event do |e|
e.dtstart = Icalendar::Values::Date.new(holiday.date)
e.dtend = Icalendar::Values::Date.new(holiday.date)
e.summary = holiday.name
end
Holidays.between(8.months.ago, 66.months.from_now, :"ca_#{params[:province].downcase}").each do |holiday|
cal.event do |e|
e.dtstart = Icalendar::Values::Date.new(holiday[:date])
e.dtend = Icalendar::Values::Date.new(holiday[:date])
e.summary = holiday[:name]
end
end
cal.publish
Expand Down Expand Up @@ -60,7 +59,7 @@
<li><a href="/NU.ics">Nunavut</a></li>
</ul>

<p>Originally sourced from <a href="http://www.statutoryholidays.com/">Statutory Holidays Canada</a></p>
<p>Data via Ruby <a href="https://github.com/holidays/holidays/">Holidays gem</a></p>
</div>
</div>
</div>
Expand Down
203 changes: 0 additions & 203 deletions lib/holidays.rb

This file was deleted.

10 changes: 0 additions & 10 deletions spec/holidays_spec.rb

This file was deleted.

0 comments on commit b3d926a

Please sign in to comment.