module Smooster::Deploy::Pages

Public Instance Methods

all()
Alias for: collection
collection() click to toggle source
# File lib/smooster/deploy/pages.rb, line 5
def collection
  collection = []
  response.each do |file|
    body = File.read(file)
    template = SiteTemplate.new({:body => body, :path => file, :checksum => Digest::MD5.hexdigest(body)})
    template.smo_id = template.load_smo_id if template.load_smo_id.present?
    source = Nokogiri::HTML(body)
    if /^[a-z0-9\/\-]+$/.match(source.css('title').first)
      template.title = source.css('title').first.inner_html
      collection << template
    else
      puts "Couldn't create page, because the templates title-tag name must contain ONLY lower case letters, numbers and hyphens (-): #{source.css('title').first}".colorize(:red)
    end
  end
  collection
end
Also aliased as: all
method_missing(name, *args, &block) click to toggle source
Calls superclass method
# File lib/smooster/deploy/pages.rb, line 37
def method_missing(name, *args, &block)
  if collection.respond_to? name
    collection.send(name, *args)
  else
    super
  end
end
reload!() click to toggle source
# File lib/smooster/deploy/pages.rb, line 27
def reload!
  @response = initialize_collection
end
response() click to toggle source
# File lib/smooster/deploy/pages.rb, line 23
def response
  @response ||= initialize_collection
end
upload_all() click to toggle source
# File lib/smooster/deploy/pages.rb, line 31
def upload_all
  self.all.each do |template|
    template.upload
  end
end

Private Instance Methods

initialize_collection() click to toggle source
# File lib/smooster/deploy/pages.rb, line 46
def initialize_collection
  Dir.glob("#{Smooster::Application.instance.base_dir}/#{Smooster::Application.instance.html_folder()}/**/*.html")
end