Sha256: 74e0a0671cf2ffddf8a8a490bc9c9490eaa38b95897c94da9b55408225703673
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
# frozen_string_literal: true module Mina class Commands extend Forwardable include Helpers::Internal include Configuration::DSL attr_reader :queue attr_accessor :stage def initialize(stage = :default) @stage = stage @queue = Hash.new { |hash, key| hash[key] = [] } end def command(code, strip: true, quiet: false, indent: nil) code = unindent(code) if strip code = indent(indent, code) if indent queue[stage] << (quiet ? code : echo_cmd(code)) end def comment(code, indent: nil) queue[stage] << if indent indent(indent, %(echo "-----> #{code}")) else %(echo "-----> #{code}") end end def delete(stage) queue.delete(stage) || [] end def empty(stage = :default) queue[stage] = [] end def process(path = nil) # rubocop:disable Metrics/AbcSize if path && !queue[stage].empty? queue[stage].unshift(%(echo "$ cd #{path}")) if fetch(:verbose) %{(cd #{path} && #{queue[stage].join(' && ')} && cd -)} else queue[stage].join("\n") end end def run_default? !queue.empty? && stage == :default end def run(backend) return if queue.empty? report_time do status = Mina::Runner.new(process, backend).run error! 'Run Error' unless status end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mina-1.2.5 | lib/mina/commands.rb |