Browse Source

Simplify write_page and write_csv method names

main
Adrian Short 6 years ago
parent
commit
c2f8851d74
2 changed files with 8 additions and 8 deletions
  1. +2
    -2
      lib/petrify.rb
  2. +6
    -6
      lib/site.rb

+ 2
- 2
lib/petrify.rb View File

@@ -12,7 +12,7 @@ class Petrify
@@log = Logger.new($stdout) @@log = Logger.new($stdout)
@@log.level = Logger::INFO @@log.level = Logger::INFO


def self.write_page(path_items, template, locals = {})
def self.page(path_items, template, locals = {})
dir = create_path(path_items) dir = create_path(path_items)
fn = File.join(dir, 'index.html') fn = File.join(dir, 'index.html')
@@ -27,7 +27,7 @@ class Petrify
# https://support.google.com/webmasters/answer/183668?hl=en&ref_topic=4581190 # https://support.google.com/webmasters/answer/183668?hl=en&ref_topic=4581190
end end


def self.write_csv(path_items, filename, data)
def self.csv(path_items, filename, data)
dir = create_path(path_items) dir = create_path(path_items)
fn = File.join(dir, filename + '.csv') fn = File.join(dir, filename + '.csv')


+ 6
- 6
lib/site.rb View File

@@ -8,18 +8,18 @@ class Site
from applications from applications
group by authority_name, status, decision, appeal_status, appeal_decision group by authority_name, status, decision, appeal_status, appeal_decision
") ")
Petrify.write_page('.', 'index', { summary: summary })
Petrify.page('.', 'index', { summary: summary })


# Summary CSV file # Summary CSV file
Petrify.write_csv('.', 'inlink-summary', summary)
Petrify.csv('.', 'inlink-summary', summary)


# New applications page # New applications page
apps = ScraperWiki.select("* from `applications` order by date_received desc limit 30") apps = ScraperWiki.select("* from `applications` order by date_received desc limit 30")
Petrify.write_page('new-applications', 'new-applications', { apps: apps })
Petrify.page('new-applications', 'new-applications', { apps: apps })


# Latest decisions page # Latest decisions page
apps = ScraperWiki.select("* from `applications` order by date_decision desc limit 30") apps = ScraperWiki.select("* from `applications` order by date_decision desc limit 30")
Petrify.write_page('decisions', 'decisions', { apps: apps })
Petrify.page('decisions', 'decisions', { apps: apps })


# Page and CSV file for each authority # Page and CSV file for each authority
auths = ScraperWiki.select("distinct(authority_name) as authority_name from applications") auths = ScraperWiki.select("distinct(authority_name) as authority_name from applications")
@@ -34,8 +34,8 @@ class Site


apps = ScraperWiki.select("* from applications where authority_name = ? order by date_received", auth['authority_name']) apps = ScraperWiki.select("* from applications where authority_name = ? order by date_received", auth['authority_name'])
path = ['authorities', slug(auth['authority_name'])] path = ['authorities', slug(auth['authority_name'])]
Petrify.write_page(path, 'authority', { apps: apps, auth: auth, summary: summary })
Petrify.write_csv(path, slug(auth['authority_name']), apps)
Petrify.page(path, 'authority', { apps: apps, auth: auth, summary: summary })
Petrify.csv(path, slug(auth['authority_name']), apps)
end end
end end
end end

Loading…
Cancel
Save