Class: Regiment::API

Inherits:
Object
  • Object
show all
Defined in:
lib/regiment/api.rb

Constant Summary collapse

ORDER_PATH =
"/etc/regiment/orders/"

Instance Method Summary collapse

Constructor Details

#initializeAPI

Returns a new instance of API.



9
10
# File 'lib/regiment/api.rb', line 9

def initialize
end

Instance Method Details

#about(order, options = {}) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/regiment/api.rb', line 29

def about(order, options={})
  begin
    info = File.new(Pathname.new(ORDER_PATH).join(Pathname.new("#{order}/README")).to_s)
  rescue IOError => e
    return e
  end
  return info
end

#execute(order, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/regiment/api.rb', line 16

def execute(order, options={})
  path = Pathname.new(ORDER_PATH).join(Pathname.new("#{order}/#{order}.rb")).to_s
  
  # Classes have caps yo!
  order[0] = order[0].capitalize

  # Load our order, instantiate it and call do_execute
  Kernel.load(path)
  o = Object.const_get(order.to_sym).new

  return o.do_execute
end

#versionObject



12
13
14
# File 'lib/regiment/api.rb', line 12

def version
  return Regiment::Service::VERSION
end