Class: Utopia::Shell
- Inherits:
-
Object
- Object
- Utopia::Shell
- Defined in:
- lib/utopia/shell.rb
Overview
This is designed to be used with the corresponding bake task.
Instance Method Summary collapse
-
#app ⇒ Object
Load the configured application on first access.
-
#binding ⇒ Object
Expose this shell's binding to IRB.
-
#get(path, headers = nil) ⇒ Object
Perform a GET request.
-
#initialize(context) ⇒ Shell
constructor
Initialize a shell for a Bake context.
-
#post(path, headers = nil, body = nil) ⇒ Object
Perform a POST request.
-
#to_s ⇒ Object
Convert this object to a string.
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
#app ⇒ Object
Load the configured application on first access.
22 23 24 |
# File 'lib/utopia/shell.rb', line 22 def app @app ||= Application.load(File.(Application::PATH, @context.root)) end |
#binding ⇒ Object
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_s ⇒ Object
Convert this object to a string.
45 46 47 |
# File 'lib/utopia/shell.rb', line 45 def to_s self.class.name end |