Add Coop.all method to return all co-ops for migration
This commit is contained in:
parent
5ca9d98343
commit
23251e7ba2
@ -4,10 +4,16 @@ require 'active_support/inflector'
|
||||
class Coop
|
||||
attr_reader :doc
|
||||
|
||||
def initialize(html)
|
||||
def initialize(fn)
|
||||
html = File.read(fn)
|
||||
@fn = fn
|
||||
@doc = Nokogiri::HTML(html)
|
||||
end
|
||||
|
||||
def slug
|
||||
File.basename(@fn, '.html')
|
||||
end
|
||||
|
||||
def name
|
||||
doc.xpath('//*[@id="page-banner"]/div/div/h2').text
|
||||
end
|
||||
@ -79,9 +85,9 @@ class Coop
|
||||
def erb_binding
|
||||
binding
|
||||
end
|
||||
end
|
||||
|
||||
source_pages = %w(
|
||||
def self.all
|
||||
%w(
|
||||
agile-collective.html
|
||||
alpha-communication.html
|
||||
animorph.html
|
||||
@ -117,15 +123,18 @@ source_pages = %w(
|
||||
wave.html
|
||||
we-are-open.html
|
||||
webarchitects.html
|
||||
)
|
||||
).map do |page|
|
||||
|
||||
fn = File.join(File.dirname(__FILE__), 'mirror', 'coops.tech.archived.website', 'co-op', page)
|
||||
new(fn)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
require 'erb'
|
||||
|
||||
source_pages.each do |page|
|
||||
fn = File.join(File.dirname(__FILE__), 'mirror', 'coops.tech.archived.website', 'co-op', page)
|
||||
output_fn = File.join(File.dirname(__FILE__), '..', '_coops', page.gsub('.html','.md'))
|
||||
|
||||
coop = Coop.new(File.read(fn))
|
||||
Coop.all.each do |coop|
|
||||
output_fn = File.join(File.dirname(__FILE__), '..', '_coops', coop.slug + '.md')
|
||||
|
||||
renderer = ERB.new(File.read('coop.erb.md'), nil, '<>')
|
||||
result = renderer.result(coop.erb_binding)
|
||||
|
Loading…
Reference in New Issue
Block a user