Sha256: b15e11a0d6e823f1f0fc82a17728b265668412e2eb223a3b4f3ffee457dba949

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

module Minke
  class Helpers

    class << self
      attr_accessor :config
    end

    @config = nil

    def self.wait_until_server_running server, count
      begin
        response = RestClient.send("get", server)
      rescue

      end

      if response == nil || !response.code.to_i == 200
        puts "Waiting for server #{server} to start"
        sleep 1
        if count < 20
          self.wait_until_server_running server, count + 1
        else
          raise 'Server failed to start'
        end
      end
    end

    def self.load_config config_file
      @config = YAML.parse(ERB.new(File.read(config_file)).result).transform

      @config[:build_config] = Minke::Commands::Go.new.commands(@config) unless @config['language'] != 'go'
      @config[:build_config] = Minke::Commands::Swift.new.commands(@config) unless @config['language'] != 'swift'
    end

    def self.copy_files assets
      assets.each do |a|
        directory = a['to']
        if File.directory?(a['to'])
          directory = File.dirname(a['to'])
        end

        Dir.mkdir directory unless Dir.exist? a['to']
        FileUtils.cp a['from'], a['to']
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
minke-0.14.0 lib/minke/helpers.rb