-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3621 from DFE-Digital/improve-internship-generati…
…on-process Create new rake task that utilizes an ERB file to generate the teaching internship providers page and update the documentation
- Loading branch information
Showing
7 changed files
with
811 additions
and
645 deletions.
There are no files selected for viewing
1,246 changes: 624 additions & 622 deletions
1,246
app/views/content/is-teaching-right-for-me/teaching-internship-providers.md
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require "csv" | ||
require "yaml" | ||
require "internship_provider" | ||
|
||
namespace :teaching_internship_providers do | ||
desc "Generate the teaching internship providers page" | ||
task generate: :environment do | ||
csv = CSV.read("lib/tasks/support/internship_providers.csv", headers: true) | ||
|
||
providers = csv.each.with_object({}) do |r, h| | ||
ip = InternshipProvider.new(r) | ||
h[ip.region.to_s] ||= {} | ||
h[ip.region.to_s]["providers"] ||= [] | ||
h[ip.region.to_s]["providers"] << ip.to_h | ||
end | ||
|
||
providers.transform_values! { |v| v["providers"].sort_by { |a| a["header"] } } | ||
provider_groups = providers.sort | ||
|
||
File.open("app/views/content/is-teaching-right-for-me/teaching-internship-providers.md", "w") do |f| | ||
f.write ERB.new(File.read("lib/tasks/support/teaching-internship-providers.md.erb"), trim_mode: "<>").result(binding) | ||
end | ||
end | ||
end |
Oops, something went wrong.