Sha256: 872ae5e42a40911e958bbdb07e04b1a2c8313ebcb3493a5c77b29889e662e23a

Contents?: true

Size: 991 Bytes

Versions: 1

Compression:

Stored size: 991 Bytes

Contents

require "predrags_dummy_pipelines/version"
require "predrags_dummy_pipelines/exec"
require "psych"

module PredragsDummyPipelines
  # Your code goes here...

  def new(file)
      actions = parse(file)
      #Pipelines::Pipeline.new(actions)
      Pipeline.new(actions)
  end

  def self.build
    Exec.new(parse_["build"])
  end
  def self.parse_
    parse("project/simple.yml")
  end
  def self.parse(file)
    project = Psych.load_file(file)
  end


  class Pipeline
    def initialize(actions)
      @build   = Exec.new(actions["build"], "build")
      deploys  = actions.select {|a,b| a != "build"}
      @deploys = deploys.map {|key, value| Exec.new(value, key)}
    end

    def run
      @build.run
      @deploys.map {|deploy|  deploy.run  }
    end

    def show
      puts @build.show
      @deploys.map {|deploy| puts deploy.show }
    end
  end

  def self.test
    a = PredragsDummyPipelines.parse_
    e = PredragsDummyPipelines::Pipeline.new a
    e.run
    e.show
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
predrags_dummy_pipelines-0.4.1 lib/predrags_dummy_pipelines.rb