Sha256: 13d35aaac44004c6e912f1b53096532021912ffb0ce5f044e1b1617222eaaae0

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 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 unless @config['language'] != 'go'
      @config[:build_config] = Minke::Commands::Swift.new.commands 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.13.0 lib/minke/helpers.rb