Sha256: e524997b49d4b3017ffd414f169d9f06fa2adf41f5496f201724712984e1d0dd

Contents?: true

Size: 1.25 KB

Versions: 9

Compression:

Stored size: 1.25 KB

Contents

require 'simultaneous'

module Spontaneous
  module Simultaneous

    class Error < Spontaneous::Error; end

    module ModuleMethods
      def simultaneous_setup
        ::Simultaneous.client_mode  = :async
        ::Simultaneous.connection   = ::Spontaneous.config.simultaneous_connection
        ::Simultaneous.domain       = ::Spontaneous.config.site_domain
      end

      def register(task_name, task, options = {}, params = {}, env = {})
        options.update({
          :pwd => root
        })
        params.update({
          "site" => root,
          "environment" => Spontaneous.env
        })
        ::Simultaneous.add_task(task_name, binary(task), options, params, env)
      end

      def fire(task_name, params = {})
        ::Simultaneous.fire(task_name, params)
      rescue => e
        raise Error, e
      end

      def spot_binary
        ::Spontaneous.config.spontaneous_binary || default_spot_binary
      end

      def default_spot_binary
        (Pathname.new(Spontaneous.gem_dir) + "bin/spot").expand_path.to_s
      end

      def binary(task)
        [spot_binary, task].join(" ")
      end

      def root
        Pathname.new(Spontaneous.root).expand_path.to_s
      end
    end

    extend ModuleMethods

    simultaneous_setup
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta10 lib/spontaneous/simultaneous.rb
spontaneous-0.2.0.beta9 lib/spontaneous/simultaneous.rb
spontaneous-0.2.0.beta8 lib/spontaneous/simultaneous.rb
spontaneous-0.2.0.beta7 lib/spontaneous/simultaneous.rb
spontaneous-0.2.0.beta6 lib/spontaneous/simultaneous.rb
spontaneous-0.2.0.beta5 lib/spontaneous/simultaneous.rb
spontaneous-0.2.0.beta4 lib/spontaneous/simultaneous.rb
spontaneous-0.2.0.beta3 lib/spontaneous/simultaneous.rb
spontaneous-0.2.0.beta2 lib/spontaneous/simultaneous.rb