class Ruhoh::Resources::Layouts::Client
Constants
- Help
Public Class Methods
new(collection, data)
click to toggle source
# File lib/ruhoh/resources/layouts/client.rb, line 10 def initialize(collection, data) @ruhoh = collection.ruhoh @collection = collection @args = data[:args] @options = data[:options] end
Public Instance Methods
new()
click to toggle source
Public: Create a new layout file for the active theme.
# File lib/ruhoh/resources/layouts/client.rb, line 18 def new ruhoh = @ruhoh name = @args[2] Ruhoh::Friend.say { red "Please specify a layout name." cyan "ex: ruhoh layouts new splash" exit } if name.nil? filename = File.join((@ruhoh.cascade.theme || @ruhoh.cascade.base), "layouts", name.gsub(/\s/, '-').downcase) + ".html" if File.exist?(filename) abort("Create new layout: aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n' end FileUtils.mkdir_p File.dirname(filename) File.open(filename, 'w:UTF-8') do |page| page.puts (@collection.scaffold || '') end Ruhoh::Friend.say { green "New layout:" plain ruhoh.relative_path(filename) } end