Class: Minke::Helpers

Inherits:
Object
  • Object
show all
Defined in:
lib/minke/helpers.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject

Returns the value of attribute config.



5
6
7
# File 'lib/minke/helpers.rb', line 5

def config
  @config
end

Class Method Details

.copy_files(assets) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/minke/helpers.rb', line 32

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

.load_config(config_file) ⇒ Object



28
29
30
# File 'lib/minke/helpers.rb', line 28

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

.wait_until_server_running(server, count) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/minke/helpers.rb', line 10

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