Sha256: 5b546343f1eb963cccca57b76643fff8704ec3c478c62201a72e18ebbcd7c26b

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

require 'rake/clean'
require 'rake/tasklib'

Dir["#{File.dirname(__FILE__)}/msdeploy_support/*.rb"].each do |path|
  require path
end

module Rake::Funnel::Tasks
  class MSDeploy < Rake::TaskLib
    attr_accessor :name, :msdeploy, :log_file, :args

    def initialize(name = :msdeploy)
      @name = name
      @msdeploy = 'msdeploy'
      @args = {}

      yield self if block_given?
      define
    end

    def log_file
      @log_file || "#{@name}.log"
    end

    private
    def define
      CLEAN.include(log_file)

      desc "Deploy #{deploy_source(args)}"
      task @name do
        mapper = Rake::Funnel::Support::Mapper.new(:MSDeploy)
        cmd = [quote(msdeploy), mapper.map(args)]
          .flatten
          .join(' ')

        MSDeploySupport::RegistryPatch.new do
          shell(cmd, log_file: log_file, error_lines: /^(error|[\w\.]*exception)/i)
        end
      end

      self
    end

    def deploy_source(args)
      source = (args || {}).fetch(:source, {})
      path = source.first
      return if path.nil?

      Pathname.new(path[1]).relative_path_from(Pathname.new('.').realpath) rescue path[1]
    end

    def quote(value)
      value = value.gsub(/"/, '""') if value.kind_of?(String)
      return %Q{"#{value}"} if value =~ /\s/
      value
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rake-funnel-0.0.6.pre lib/rake/funnel/tasks/msdeploy.rb
rake-funnel-0.0.5.pre lib/rake/funnel/tasks/msdeploy.rb
rake-funnel-0.0.4.pre lib/rake/funnel/tasks/msdeploy.rb
rake-funnel-0.0.3.pre lib/rake/funnel/tasks/msdeploy.rb
rake-funnel-0.0.2.pre lib/rake/funnel/tasks/msdeploy.rb
rake-funnel-0.0.1.pre lib/rake/funnel/tasks/msdeploy.rb