class Smooster::Deploy::SiteTemplate
Attributes
body[RW]
checksum[RW]
path[RW]
smo_id[RW]
title[RW]
Public Instance Methods
attributes()
click to toggle source
# File lib/smooster/deploy/site_template.rb, line 10 def attributes {'title' => title, 'body' => body, 'path' => path, 'checksum' => checksum, 'smo_id' => smo_id} end
load_checksum()
click to toggle source
# File lib/smooster/deploy/site_template.rb, line 18 def load_checksum store.transaction { store[self.short_path][:checksum] if store[self.short_path].present? } end
load_smo_id()
click to toggle source
# File lib/smooster/deploy/site_template.rb, line 22 def load_smo_id store.transaction { store[self.short_path][:smo_id] if store[self.short_path].present? } end
save()
click to toggle source
# File lib/smooster/deploy/site_template.rb, line 44 def save store.transaction do store[self.short_path] = {:checksum => self.checksum.to_s, :smo_id => self.smo_id} end end
short_path()
click to toggle source
# File lib/smooster/deploy/site_template.rb, line 26 def short_path self.path.gsub("#{Smooster::Application.instance.base_dir}/#{Smooster::Application.instance.html_folder()}","") end
store()
click to toggle source
# File lib/smooster/deploy/site_template.rb, line 14 def store Smooster::Application.instance.site_templates_store end
upload()
click to toggle source
# File lib/smooster/deploy/site_template.rb, line 30 def upload return false if self.checksum.to_s == self.load_checksum.to_s if self.smo_id.present? response = RestClient.put "#{Smooster::Application.instance.api_url()}/#{Smooster::Application.instance.site_id()}/site_templates/#{self.smo_id}", {:site_template => {:body => self.body, :title => self.title}}, {"Authorization" => 'Token token="'+ Smooster::Application.instance.api_key() +'"', "Accept" => 'application/vnd.smoosterid.v2'} else response = RestClient.post "#{Smooster::Application.instance.api_url()}/#{Smooster::Application.instance.site_id()}/site_templates", {:body => self.body, :title => self.title}, {"Authorization" => 'Token token="'+ Smooster::Application.instance.api_key() +'"', "Accept" => 'application/vnd.smoosterid.v2'} end data = JSON.parse(response) self.smo_id = data['smo_id'] self.save end