Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Quick rake task to dump out all artefacts with their sections

This was requested by designers to help understand the shape of the content as
they revisit the navigation for GOV.UK
  • Loading branch information...
commit 37ce461d4c64a8399d441cd83a8b80e15b075bad 1 parent fe3ce13
@jystewart jystewart authored
Showing with 30 additions and 0 deletions.
  1. +30 −0 lib/tasks/reports.rake
View
30 lib/tasks/reports.rake
@@ -0,0 +1,30 @@
+namespace :reports do
+ desc "Generate CSV file of all live artefacts"
+ task live_artefacts: :environment do
+ unless ENV['filename']
+ puts "Please specify an output filename, eg: rake reports:live_artefacts filename=blah.csv"
+ exit(1)
+ end
+
+ column_headings = [:name, :format, :url, :sections]
+
+ require 'csv'
+
+ puts "Generating CSV"
+
+ CSV.open(ENV['filename'], 'w') do |csv|
+ csv << column_headings.collect { |ch| ch.to_s.humanize }
+ Artefact.where(state: 'live').each do |a|
+ row = [
+ a.name,
+ a.kind,
+ "https://www.gov.uk/#{a.slug}"
+ ]
+ row += a.sections.collect { |t| t.title }
+ csv << row
+ print "."
+ end
+ end
+ puts
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.