Sha256: a19d622a02740b52f547bd2e3a253b75dd8cbe7b4adf3da593135d8c1a4dac76

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

module Bailiff
  class Runner < Thor

    method_option :remote, :default => "user@server"
    desc "execute [file]", "Executes configuration from Bailfile"
    def execute(file = 'Bailfile')
      verify_bailfile(file)
      context = load_bailfile(file)
      opts = {}
      if options[:remote] != "user@server"
        data = options[:remote].split("@")
        Net::SSH.start(data[1], data[0]) do |ssh|
          opts[:ssh] = ssh
          context.execute(opts)
        end
      else
        context.execute(opts)
      end
    end

    desc "verify [file]", "Prints commands that would be run for Bailfile"
    def verify(file = 'Bailfile')
      verify_bailfile(file)
      context = load_bailfile(file)
      puts context.resolve
    end

    no_tasks do
      def verify_bailfile(file)
        unless File.exists?(file)
          puts "No Bailfile found."
          exit(1)
        end
      end

      def load_bailfile(file)
        file = "Bailfile" unless file
        code = File.read(file)
        context = Context.new
        context.bailfile(code)
        context
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bailiff-0.1 lib/bailiff/runner.rb