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.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#permalink ⇒ Object
Returns the value of attribute permalink.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #exec(commands = []) ⇒ Object
- #file_content(path = "") ⇒ Object
- #files ⇒ Object
- #forks ⇒ Object
-
#initialize(opts = {}) ⇒ Console
constructor
A new instance of Console.
- #restart ⇒ Object
- #save ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Methods included from APIRequest
#get, included, #post, #url_to
Constructor Details
#initialize(opts = {}) ⇒ Console
Returns a new instance of Console.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/codepicnic/console.rb', line 8 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) end |
Class Attribute Details
.api_url ⇒ Object
Returns the value of attribute api_url.
67 68 69 |
# File 'lib/codepicnic/console.rb', line 67 def api_url @api_url end |
Instance Attribute Details
#container_name ⇒ Object
Returns the value of attribute container_name.
6 7 8 |
# File 'lib/codepicnic/console.rb', line 6 def container_name @container_name end |
#container_type ⇒ Object
Returns the value of attribute container_type.
6 7 8 |
# File 'lib/codepicnic/console.rb', line 6 def container_type @container_type end |
#created_at ⇒ Object
Returns the value of attribute created_at.
6 7 8 |
# File 'lib/codepicnic/console.rb', line 6 def created_at @created_at end |
#custom_image ⇒ Object
Returns the value of attribute custom_image.
6 7 8 |
# File 'lib/codepicnic/console.rb', line 6 def custom_image @custom_image end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/codepicnic/console.rb', line 6 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/codepicnic/console.rb', line 6 def name @name end |
#permalink ⇒ Object
Returns the value of attribute permalink.
6 7 8 |
# File 'lib/codepicnic/console.rb', line 6 def permalink @permalink end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/codepicnic/console.rb', line 6 def url @url end |
Class Method Details
.all ⇒ Object
69 70 71 |
# File 'lib/codepicnic/console.rb', line 69 def all get(url_to)["consoles"].map{|data| Console.new(data) } end |
.batch_exec(commands = [], container_names = []) ⇒ Object
73 74 75 |
# File 'lib/codepicnic/console.rb', line 73 def batch_exec(commands = [], container_names = []) post url_to(nil, "exec"), {commands: commands, container_names: container_names } end |
Instance Method Details
#exec(commands = []) ⇒ Object
53 54 55 |
# File 'lib/codepicnic/console.rb', line 53 def exec(commands = []) post url_to(@container_name, "exec"), {commands: commands} end |
#file_content(path = "") ⇒ Object
49 50 51 |
# File 'lib/codepicnic/console.rb', line 49 def file_content(path = "") get url_to(@container_name, path) end |
#files ⇒ Object
45 46 47 |
# File 'lib/codepicnic/console.rb', line 45 def files get url_to(@container_name, "files") end |
#forks ⇒ Object
41 42 43 |
# File 'lib/codepicnic/console.rb', line 41 def forks get url_to(@container_name, "forks") end |
#restart ⇒ Object
37 38 39 |
# File 'lib/codepicnic/console.rb', line 37 def restart post url_to(@container_name, "restart") end |
#save ⇒ Object
20 21 22 23 24 25 |
# File 'lib/codepicnic/console.rb', line 20 def save response = post(url_to, {console: cleaned_params}) self.container_name = response["container_name"] self.url = response["url"] response end |
#start ⇒ Object
27 28 29 30 31 |
# File 'lib/codepicnic/console.rb', line 27 def start result = post(url_to(@container_name, "start")) @url = result["url"] result end |
#stop ⇒ Object
33 34 35 |
# File 'lib/codepicnic/console.rb', line 33 def stop post url_to(@container_name, "stop") end |