Sha256: afc63cd7a40ca99d008ea672baeb4905b76bfcefc9bd8fa805cd31d473f1c3ff

Contents?: true

Size: 886 Bytes

Versions: 1

Compression:

Stored size: 886 Bytes

Contents

require 'minitest/mock'
module Lobstr
  class Base
    attr_accessor :app, :branch, :environment, :config, :ssh
    def parse_target(target)
      branch,environment = target.split('@', 2)
 
      if environment.nil? # e.g. production
        environment = branch
        branch = 'master'
      end

      branch = "master" if branch.empty? # e.g. @production
      environment = "production" if environment.empty? # e.g. master@
      [branch,environment]
    end

    def connect(&block)
      @ssh = ::Net::SSH.start(@config['ssh_host'], 
                              @config['ssh_user'], 
                              :keys => [@config['ssh_key']],
                              :auth_methods => %w{ publickey })
      instance_eval(&block) if block_given? 
    end

    def remote_task(cmd)
      @ssh.exec! cmd
    end

    def local_task(cmd)
      `#{cmd}`
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lobstr-0.0.2 lib/lobstr/base.rb