Sha256: 488d15b40290f16873aa232c3b6be09938a06e99e53f6ac87e1a52671b8e3c9a

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

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

module PredragsDummyPipelines
  # Your code goes here...

  def self.new(yaml)
      actions = parse(yaml)
      Pipeline.new(actions)
  end

  def self.build
    Exec.new(parse_["build"])
  end
  def self.parse_
    parse_file("project/simple.yml")
  end
  def self.parse_file(file)
    project = Psych.load_file(file)
  end
  def self.parse(actions)
    Psych.load(actions)
  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

    def build_results
      @build.results
    end
  end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
predrags_dummy_pipelines-0.6.1 lib/predrags_dummy_pipelines.rb
predrags_dummy_pipelines-0.5.3 lib/predrags_dummy_pipelines.rb
predrags_dummy_pipelines-0.5.2 lib/predrags_dummy_pipelines.rb