Sha256: 0fe180b41377cd2b84787f1f27bd2f91e04db9c1f92d5ae2bd141dd44bcff399
Contents?: true
Size: 682 Bytes
Versions: 5
Compression:
Stored size: 682 Bytes
Contents
# frozen_string_literal: true class PageBuilder ROOT = Pages::ApplicationPage def self.build_all FileUtils.mkdir_p("#{__dir__}/dist") FileUtils.cp_r("#{__dir__}/assets", "#{__dir__}/dist") ROOT.subclasses.each { |page| new(page).call } end def initialize(page) @page = page end def call puts "Building #{@page.name}" FileUtils.mkdir_p(directory) File.write(file, @page.new.call) end private def file "#{directory}/index.html" end def directory if path == "index" "#{__dir__}/dist" else "#{__dir__}/dist/#{path}" end end def path @page.name.split("::")[1..].map { _1.gsub(/(.)([A-Z])/, '\1-\2') }.map(&:downcase).join("/") end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
phlex-0.5.3 | docs/page_builder.rb |
phlex-0.5.2 | docs/page_builder.rb |
phlex-0.5.1 | docs/page_builder.rb |
phlex-0.5.0 | docs/page_builder.rb |
phlex-0.4.0 | docs/page_builder.rb |