Top Level Namespace

Constant Summary collapse

RUMAKE_VERSION =

Rumake version constant

'v0.1.3'
RUMAKE_LIBRARY =

Used to determine whether Rumake should be used as an executable or library

true

Instance Method Summary collapse

Instance Method Details

#cd(dir) ⇒ Object

Change the current working directory



79
80
81
# File 'lib/rumake.rb', line 79

def cd(dir)
  Dir.chdir(dir)
end

#fail(error = nil) ⇒ Object

Display an error message and stop execution of the script. This should be used as the standard way to show error messages and end execution of the target.



65
66
67
68
69
# File 'lib/rumake.rb', line 65

def fail(error = nil)
  puts "Error: #{error}" unless error.nil?
  puts 'Target failed to execute properly.'
  exit 1
end

#getwdObject

Get the current working directory



84
85
86
# File 'lib/rumake.rb', line 84

def getwd
  Dir.getwd
end

#loadObject

A basic startup method



34
35
36
37
38
39
40
41
42
43
# File 'lib/rumake.rb', line 34

def load
  # Load any file called "rumakefile.rb"
  begin
    file = File::read('rumakefile.rb')
  rescue
    fail('Unable to open "rumakefile.rb"')
  end

  file
end

#run(tar = :all) ⇒ Object

Run a target



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/rumake.rb', line 46

def run(tar = :all)
  if $targets[tar].nil?
    puts "Target \"#{tar}\" does not exist."
    exit 1
  else
    $targets[tar].call

    # The target should have executed successfully by now
    puts 'Target executed successfully.'
  end
end

#sh(command) ⇒ Object

Run a shell command



72
73
74
75
76
# File 'lib/rumake.rb', line 72

def sh(command)
  if system(command) == false
    fail("Shell command \"#{command}\" exited with error.")
  end
end

#target(tar, &block) ⇒ Object

A simple target generator



59
60
61
# File 'lib/rumake.rb', line 59

def target(tar, &block)
  $targets[tar] = block
end