class Plate::CLI
Constants
- DEPENDENCIES
:nocov:
Public Instance Methods
compile(source)
click to toggle source
# File lib/plate/cli.rb, line 26 def compile(source) output = options[:o] skeleton = File.expand_path('../../../skeleton/app', __FILE__) vendor = File.expand_path('../../../skeleton/vendor', __FILE__) plt, dir = read_plt(source) compiler = Compiler.new compiler.compile(plt) directory(skeleton, output) DEPENDENCIES.each do |d| directory(File.join(vendor, d), File.join(output, 'vendor', d)) end build_html(output, compiler) build_js(output, compiler) build_css(output, compiler, vendor) if dir directory(File.join(Dir.pwd, source), output) remove_file(File.join(Dir.pwd, output, 'index.plt')) end end
version()
click to toggle source
:nocov:
# File lib/plate/cli.rb, line 11 def version say "Plate version #{Plate::VERSION}" end
Private Instance Methods
build(path, b)
click to toggle source
# File lib/plate/cli.rb, line 91 def build(path, b) erb = File.read(path) rendered = ERB.new(erb).result(b) File.write(path, rendered) end
build_css(output, compiler, vendor)
click to toggle source
# File lib/plate/cli.rb, line 75 def build_css(output, compiler, vendor) meta = compiler.meta bootstrap = meta['bootstrap'] || {} path = File.join(output, 'assets', 'css', 'app.css') build(path, binding) theme = bootstrap['theme'] unless theme.nil? name = 'bootstrap.min.css' path = File.join(Dir.pwd, output, 'vendor', 'bootstrap', 'dist', 'css', name) remove_file(path) copy_file(File.join(vendor, 'bootswatch', theme, name), path) end end
build_html(output, compiler)
click to toggle source
# File lib/plate/cli.rb, line 59 def build_html(output, compiler) body = compiler.body meta = compiler.meta title = meta['title'] data = JSON.dump(compiler.meta) head = compiler.fonts path = File.join(output, 'index.html') build(path, binding) end
build_js(output, compiler)
click to toggle source
# File lib/plate/cli.rb, line 70 def build_js(output, compiler) path = File.join(output, 'assets', 'js', 'app.js') build(path, binding) end
read_plt(source)
click to toggle source
# File lib/plate/cli.rb, line 53 def read_plt(source) dir = File.directory?(source) path = dir ? File.join(source, 'index.plt') : source [File.read(path), dir] end