Class: CodePicnic::Console
- Inherits:
-
Object
- Object
- CodePicnic::Console
- Includes:
- APIRequest
- Defined in:
- lib/codepicnic/console.rb
Class Attribute Summary collapse
-
.api_url ⇒ Object
Returns the value of attribute api_url.
Instance Attribute Summary collapse
-
#container_name ⇒ Object
Returns the value of attribute container_name.
-
#container_type ⇒ Object
Returns the value of attribute container_type.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#custom_image ⇒ Object
Returns the value of attribute custom_image.
-
#embed_url ⇒ Object
Returns the value of attribute embed_url.
-
#id ⇒ Object
Returns the value of attribute id.
-
#is_headless ⇒ Object
Returns the value of attribute is_headless.
-
#name ⇒ Object
Returns the value of attribute name.
-
#permalink ⇒ Object
Returns the value of attribute permalink.
-
#terminal_url ⇒ Object
Returns the value of attribute terminal_url.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
- .all ⇒ Object
- .batch_exec(commands = [], container_names = []) ⇒ Object
- .find(container_name) ⇒ Object
Instance Method Summary collapse
- #exec(commands = []) ⇒ Object
- #file_content(path = "") ⇒ Object
- #files ⇒ Object
- #find ⇒ Object
- #forks ⇒ Object
-
#initialize(opts = {}) ⇒ Console
constructor
A new instance of Console.
- #restart ⇒ Object
- #save ⇒ Object
- #search(term, path) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #upload_file(file = nil, path = nil) ⇒ Object
Methods included from APIRequest
#get, included, #post, #post_form, #url_to
Constructor Details
#initialize(opts = {}) ⇒ Console
Returns a new instance of Console.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/codepicnic/console.rb', line 11 def initialize(opts={}) @id = opts.delete("id") || opts.delete(:id) @name = opts.delete("name") || opts.delete(:name) @container_name = opts.delete("container_name") || opts.delete(:container_name) @container_type = opts.delete("container_type") || opts.delete(:container_type) @custom_image = opts.delete("custom_image") || opts.delete(:custom_image) @created_at = opts.delete("created_at") || opts.delete(:created_at) @container_size = opts.delete("container_size") || opts.delete(:container_size) @title = @name || opts.delete("title") || opts.delete(:title) @hostname = opts.delete("hostname") || opts.delete(:hostname) @is_headless = opts.delete("is_headless") || opts.delete(:is_headless) @url = opts.delete("url") || opts.delete(:url) = opts.delete("embed_url") || opts.delete(:embed_url) @permalink = opts.delete("permalink") || opts.delete(:permalink) @terminal_url = opts.delete("terminal_url") || opts.delete(:terminal_url) end |
Class Attribute Details
.api_url ⇒ Object
Returns the value of attribute api_url.
88 89 90 |
# File 'lib/codepicnic/console.rb', line 88 def api_url @api_url end |
Instance Attribute Details
#container_name ⇒ Object
Returns the value of attribute container_name.
7 8 9 |
# File 'lib/codepicnic/console.rb', line 7 def container_name @container_name end |
#container_type ⇒ Object
Returns the value of attribute container_type.
7 8 9 |
# File 'lib/codepicnic/console.rb', line 7 def container_type @container_type end |
#created_at ⇒ Object
Returns the value of attribute created_at.
8 9 10 |
# File 'lib/codepicnic/console.rb', line 8 def created_at @created_at end |
#custom_image ⇒ Object
Returns the value of attribute custom_image.
7 8 9 |
# File 'lib/codepicnic/console.rb', line 7 def custom_image @custom_image end |
#embed_url ⇒ Object
Returns the value of attribute embed_url.
8 9 10 |
# File 'lib/codepicnic/console.rb', line 8 def end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/codepicnic/console.rb', line 7 def id @id end |
#is_headless ⇒ Object
Returns the value of attribute is_headless.
8 9 10 |
# File 'lib/codepicnic/console.rb', line 8 def is_headless @is_headless end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/codepicnic/console.rb', line 7 def name @name end |
#permalink ⇒ Object
Returns the value of attribute permalink.
8 9 10 |
# File 'lib/codepicnic/console.rb', line 8 def permalink @permalink end |
#terminal_url ⇒ Object
Returns the value of attribute terminal_url.
9 10 11 |
# File 'lib/codepicnic/console.rb', line 9 def terminal_url @terminal_url end |
#url ⇒ Object
Returns the value of attribute url.
8 9 10 |
# File 'lib/codepicnic/console.rb', line 8 def url @url end |
Class Method Details
.all ⇒ Object
90 91 92 |
# File 'lib/codepicnic/console.rb', line 90 def all get(url_to)["consoles"].map{|data| Console.new(data) } end |
.batch_exec(commands = [], container_names = []) ⇒ Object
98 99 100 |
# File 'lib/codepicnic/console.rb', line 98 def batch_exec(commands = [], container_names = []) post url_to(nil, "exec"), {commands: commands, container_names: container_names } end |
.find(container_name) ⇒ Object
94 95 96 |
# File 'lib/codepicnic/console.rb', line 94 def find(container_name) Console.new(get(url_to(container_name))) end |
Instance Method Details
#exec(commands = []) ⇒ Object
65 66 67 |
# File 'lib/codepicnic/console.rb', line 65 def exec(commands = []) post url_to(@container_name, "exec"), {commands: commands} end |
#file_content(path = "") ⇒ Object
61 62 63 |
# File 'lib/codepicnic/console.rb', line 61 def file_content(path = "") get url_to(@container_name, path) end |
#files ⇒ Object
57 58 59 |
# File 'lib/codepicnic/console.rb', line 57 def files get url_to(@container_name, "files") end |
#find ⇒ Object
28 29 30 |
# File 'lib/codepicnic/console.rb', line 28 def find get url_to(@container_name, "show") end |
#forks ⇒ Object
53 54 55 |
# File 'lib/codepicnic/console.rb', line 53 def forks get url_to(@container_name, "forks") end |
#restart ⇒ Object
49 50 51 |
# File 'lib/codepicnic/console.rb', line 49 def restart post url_to(@container_name, "restart") end |
#save ⇒ Object
32 33 34 35 36 37 |
# File 'lib/codepicnic/console.rb', line 32 def save response = post(url_to, {console: cleaned_params}) self.container_name = response["container_name"] self.url = response["url"] response end |
#search(term, path) ⇒ Object
74 75 76 |
# File 'lib/codepicnic/console.rb', line 74 def search(term, path) get url_to(@container_name, "search") end |
#start ⇒ Object
39 40 41 42 43 |
# File 'lib/codepicnic/console.rb', line 39 def start result = post(url_to(@container_name, "start")) @url = result["url"] result end |
#stop ⇒ Object
45 46 47 |
# File 'lib/codepicnic/console.rb', line 45 def stop post url_to(@container_name, "stop") end |
#upload_file(file = nil, path = nil) ⇒ Object
69 70 71 72 |
# File 'lib/codepicnic/console.rb', line 69 def upload_file(file = nil, path = nil) path = "/app/#{file.path}" unless path post_form url_to(@container_name, "upload_file"), {path: path, file: file} end |