Sha256: b1f35c20b058bf96ace16bc9dc3c733b7a1ab5646ca4a5625c28c4af9a8aad8a
Contents?: true
Size: 1.95 KB
Versions: 2
Compression:
Stored size: 1.95 KB
Contents
if ! defined?(Already_publish) Already_publish = nil require 'pathmagic' require 'processing' class RuneBlog::Publishing attr_reader :user, :server, :docroot, :path BadRemoteLogin = Exception.new("Can't login remotely") BadRemotePerms = Exception.new("Bad remote permissions") def initialize(view) log!(enter: __method__, args: [view.to_s]) @blog = RuneBlog.blog dir = @blog.root/:views/view/"themes/standard/" gfile = dir/"global.lt3" live = get_live_vars(gfile) @user = live.vars["publish.user"] @server = live.vars["publish.server"] @docroot = live.vars["publish.docroot"] @path = live.vars["publish.path"] @proto = live.vars["publish.proto"] end def to_h log!(enter: __method__, level: 3) {user: @user, server: @server, docroot: @docroot, path: @path, proto: @proto} end def url log!(enter: __method__, level: 3) vname = @blog.view.name # .gsub(/_/, "\\_") url = "#@proto://#@server/#@path" # /#{vname}" end def publish log!(enter: __method__, level: 1) dir = @docroot/@path view_name = @blog.view.name viewpath = dir # /view_name # FIXME rsync doesn't work cmd = "rsync -r -z #{@blog.root}/views/#{@blog.view}/remote/ #@user@#@server:#{viewpath}/" system!(cmd) dump("#{@blog.view} at #{Time.now}", "#{@blog.view.dir}/last_published") true end def remote_login? log!(enter: __method__) cmd = "ssh -o BatchMode=yes #@user@#@server -x date >/dev/null 2>&1" result = system(cmd) return nil unless result true end def remote_permissions? log!(enter: __method__) dir = @docroot/@path temp = @path/"__only_testing" try1 = system("ssh -o BatchMode=yes -o ConnectTimeout=1 #@user@#@server -x mkdir -p #{temp} >/dev/null 2>&1") return nil unless try1 try2 = system("ssh -o BatchMode=yes -o ConnectTimeout=1 #@user@#@server -x rmdir #{temp} >/dev/null 2>&1") return nil unless try2 true end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
runeblog-0.2.99 | lib/publish.rb |
runeblog-0.2.98 | lib/publish.rb |