class Smooster::Cli::Executable
Public Instance Methods
configure()
click to toggle source
# File lib/smooster/cli/executable.rb, line 144 def configure() if File.exists?("#{Smooster::Application.instance.base_dir}/site_config.yml") Smooster::Deploy::Setting.upload() puts "done!" else puts "no site_config.yml could be found in your project root folder. Please use 'smooster setup SITE_ID' to create site_config.yml".colorize(:red) end end
deploy(type="assets")
click to toggle source
# File lib/smooster/cli/executable.rb, line 58 def deploy(type="assets") unless File.directory?("#{Smooster::Application.instance.base_dir}/#{Smooster::Application.instance.html_folder()}") puts "ERROR: There is no #{Smooster::Application.instance.html_folder()}/ folder, please call smooster deploy from a folder including a folder named #{Smooster::Application.instance.html_folder()}/".colorize(:red) return false end puts "Starting push to smooster..." if type == "assets" || type == "all" || type == "initial" Smooster::Deploy::MediaAsset.all.each do |ma| status = "[deployed]".colorize(:blue) status = "[unchanged]".colorize(:green) if ma.checksum.to_s == ma.load_checksum.to_s puts "#{ma.file_path} #{status}" ma.upload end end if type == "templates" || type == "all" || type == "initial" Smooster::Deploy::SiteTemplate.all.each do |st| status = "[deployed]".colorize(:blue) status = "[unchanged]".colorize(:green) if st.checksum.to_s == st.load_checksum.to_s st.upload puts "#{st.path} #{status}" end end if type == "initial" urls = [] Smooster::Deploy::SiteTemplate.all.each do |st| status = "[create]".colorize(:blue) #status = "[exists]".colorize(:green) if st.checksum.to_s == st.load_checksum.to_s p = Smooster::Deploy::Page.new({:title => st.title, :filename => st.title, :site_template_id => st.smo_id}) p.upload urls << p.url puts "#{p.filename} #{status}" end puts "Starting validation of #{urls.count} pages" return if urls.count == 0 urls.each do |url| begin puts "#{url}" url_encoded = CGI.escape(url) if options[:validator] Launchy.open("http://validator.w3.org/check?uri=#{url_encoded}&charset=%28detect+automatically%29&doctype=Inline&group=0") sleep 1 end rescue => e Smooster::Application.instance.logger.error "Error in page validation for #{url}!: #{e} / #{e.backtrace.inspect}" puts "This url failed to be validated: #{url}".colorize(:red) end end end puts "#{type} done!" end
load(type="assets")
click to toggle source
# File lib/smooster/cli/executable.rb, line 117 def load(type="assets") unless File.directory?("#{Smooster::Application.instance.base_dir}/#{Smooster::Application.instance.html_folder()}") puts "ERROR: There is no #{Smooster::Application.instance.html_folder()}/ folder, please call smooster load from a folder including a folder named #{Smooster::Application.instance.html_folder()}/".colorize(:red) return false end puts "Starting loading from smooster..." if type == "assets" || type == "all" Smooster::Deploy::MediaAsset.all.each do |ma| status = "[loading]".colorize(:blue) status = "[unchanged]".colorize(:green) if ma.checksum.to_s == ma.load_checksum.to_s puts "#{ma.file_path} #{status}" ma.download(options[:keep]) end end if type == "templates" || type == "all" puts "NOTICE: This feature is not yet implemented".colorize(:blue) return false end puts "#{type} done!" end
register(api_key)
click to toggle source
# File lib/smooster/cli/executable.rb, line 18 def register(api_key) unless File.directory?("#{Dir.home}/.smo") FileUtils.mkdir_p("#{Dir.home}/.smo") end Smooster::Application.instance.update_api_key(api_key) puts Smooster::Application.instance.api_key() puts "done!" end
setup(site_id, api_url="http://cms.smooster.com/api", html_folder="html")
click to toggle source
method_options :force => :boolean, :alias => :string
# File lib/smooster/cli/executable.rb, line 31 def setup(site_id, api_url="http://cms.smooster.com/api", html_folder="html") unless File.directory?("#{Smooster::Application.instance.base_dir}/#{html_folder}") puts "ERROR: There is no #{html_folder}/ folder, please call smooster setup from a folder including a folder named #{html_folder}/".colorize(:red) return false end unless File.directory?("#{Smooster::Application.instance.base_dir}/.smo") FileUtils.mkdir_p("#{Smooster::Application.instance.base_dir}/.smo") end config_store = Smooster::Application.instance.config config_store.transaction do config_store[:api_url] = api_url config_store[:html_folder] = html_folder config_store[:site_id] = site_id end #if ([(print 'Create a site_config.yml file? [y]: '), gets.rstrip][1] == "y") unless File.exists?("#{Smooster::Application.instance.base_dir}/site_config.yml") File.open("#{Smooster::Application.instance.base_dir}/site_config.yml", "w+") { |file| file.write(File.read(File.expand_path('../../templates/site_config.yml', __FILE__))) } end #end end
test()
click to toggle source
# File lib/smooster/cli/executable.rb, line 11 def test puts "smooster Gem Version: #{Gem.loaded_specs["smooster"].version}" puts Smooster::Application.instance.api_key() puts Dir.pwd end