Class: Utopia::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/utopia/shell.rb

Overview

This is designed to be used with the corresponding bake task.

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Shell

Initialize a shell for a Bake context.



15
16
17
18
# File 'lib/utopia/shell.rb', line 15

def initialize(context)
	@context = context
	@app = nil
end

Instance Method Details

#appObject

Load the configured application on first access.



22
23
24
# File 'lib/utopia/shell.rb', line 22

def app
	@app ||= Application.load(File.expand_path(Application::PATH, @context.root))
end

#bindingObject

Expose this shell's binding to IRB.



51
52
53
# File 'lib/utopia/shell.rb', line 51

def binding
	super
end

#get(path, headers = nil) ⇒ Object

Perform a GET request.



30
31
32
# File 'lib/utopia/shell.rb', line 30

def get(path, headers = nil)
	app.call(Protocol::HTTP::Request["GET", path, headers])
end

#post(path, headers = nil, body = nil) ⇒ Object

Perform a POST request.



39
40
41
# File 'lib/utopia/shell.rb', line 39

def post(path, headers = nil, body = nil)
	app.call(Protocol::HTTP::Request["POST", path, headers, body])
end

#to_sObject

Convert this object to a string.



45
46
47
# File 'lib/utopia/shell.rb', line 45

def to_s
	self.class.name
end