Sha256: a0bbcdf8c4eac770d795aa7a4ee2ed395e56139445acecb6eb7d495bcd3a95c4

Contents?: true

Size: 996 Bytes

Versions: 6

Compression:

Stored size: 996 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative '../lib/conductor'

# raise 'No input on STDIN' unless Conductor.stdin

include Conductor

config = Config.new

def conduct(tracks, res = nil, condition = nil)
  tracks.each do |track|
    cond = Condition.new(track[:condition])

    next unless cond.true?

    if track[:tracks]
      ts = track[:tracks].symbolize_keys

      res, condition = conduct(ts, res, condition)

      next if res.nil?
    end

    condition = condition.nil? ? track[:condition] : "#{track[:condition]} > #{condition}"

    if track[:script]
      script = Script.new(track[:script])

      res = script.run
    elsif track[:command]
      command = Command.new(track[:command])

      res = command.run
    end

    break
  end

  [res, condition]
end

tracks = config.tracks
res, condition = conduct(tracks)

if res.nil?
  $stderr.puts('No conditions satisfied')
  puts 'NOCUSTOM'
else
  $stderr.puts("Met condition: #{condition}")
  puts res
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
marked-conductor-1.0.5 bin/conductor
marked-conductor-1.0.4 bin/conductor
marked-conductor-1.0.3 bin/conductor
marked-conductor-1.0.2 bin/conductor
marked-conductor-1.0.1 bin/conductor
marked-conductor-1.0.0 bin/conductor