Sha256: 0c91ff68e2132603e2473eea8dab9ea5873739b640b0701681db6a8653b6fd33

Contents?: true

Size: 1.13 KB

Versions: 18

Compression:

Stored size: 1.13 KB

Contents

module Pave
  class Remote
    include Pave::Shell

    def self.setup
      server = ask "Username and hostname of the remote server (e.g. user@server.com): "
      folder = ask "Name of the remote directory (e.g. ~/webapps/appname/): "
      remote = ask "Desired git remote name (e.g. live): "
      script = File.join(File.expand_path("../..", File.dirname(__FILE__)), "resources/deploy.sh")

      puts "Piping shell script to #{server} for setup."
      sh "ssh #{server} 'cd #{folder}; bash -s' < #{script}"

      sh "git remote remove #{remote}"
      sh "git remote add #{remote} #{server}:#{folder}/deploy.git"

      puts "Finished! You may now run `pave deploy` to deploy your application."
    end

    def self.deploy(remote="live", branch="master")
      sh "git push #{remote} #{branch}"
    end

    def self.url(remote="live")
      remotes = shell("git remote -v").output
      remotes.match(/#{remote}\s+(.*)\s+\(push\)/)[1]
    end

    def self.server(remote="live")
      self.url(remote).split(":").first
    end

    def self.directory(remote="live")
      self.url(remote).split(":").last.gsub("/deploy.git", "")
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
pave-0.11.1 lib/pave/remote.rb
pave-0.12.0.rc3 lib/pave/remote.rb
pave-0.12.0.rc2 lib/pave/remote.rb
pave-0.12.0.rc1 lib/pave/remote.rb
pave-0.11.0 lib/pave/remote.rb
pave-0.10.1 lib/pave/remote.rb
pave-0.10.0 lib/pave/remote.rb
pave-0.9.0 lib/pave/remote.rb
pave-0.8.0 lib/pave/remote.rb
pave-0.7.1 lib/pave/remote.rb
pave-0.7.0 lib/pave/remote.rb
pave-0.6.6 lib/pave/remote.rb
pave-0.6.5 lib/pave/remote.rb
pave-0.6.4 lib/pave/remote.rb
pave-0.6.3 lib/pave/remote.rb
pave-0.6.2 lib/pave/remote.rb
pave-0.6.1 lib/pave/remote.rb
pave-0.6.0 lib/pave/remote.rb