Class: CodePicnic::Console
- Inherits:
-
Object
- Object
- CodePicnic::Console
show all
- Includes:
- APIRequest
- Defined in:
- lib/codepicnic/console.rb
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from APIRequest
#get, included, #post, #post_form, #url_to
Constructor Details
#initialize(opts = {}) ⇒ Console
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/codepicnic/console.rb', line 9
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)
end
|
Class Attribute Details
.api_url ⇒ Object
Returns the value of attribute api_url.
82
83
84
|
# File 'lib/codepicnic/console.rb', line 82
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.
7
8
9
|
# File 'lib/codepicnic/console.rb', line 7
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
|
#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.
7
8
9
|
# File 'lib/codepicnic/console.rb', line 7
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.
7
8
9
|
# File 'lib/codepicnic/console.rb', line 7
def permalink
@permalink
end
|
#url ⇒ Object
Returns the value of attribute url.
7
8
9
|
# File 'lib/codepicnic/console.rb', line 7
def url
@url
end
|
Class Method Details
.all ⇒ Object
84
85
86
|
# File 'lib/codepicnic/console.rb', line 84
def all
get(url_to)["consoles"].map{|data| Console.new(data) }
end
|
.batch_exec(commands = [], container_names = []) ⇒ Object
92
93
94
|
# File 'lib/codepicnic/console.rb', line 92
def batch_exec(commands = [], container_names = [])
post url_to(nil, "exec"), {commands: commands, container_names: container_names }
end
|
.find(container_name) ⇒ Object
88
89
90
|
# File 'lib/codepicnic/console.rb', line 88
def find(container_name)
Console.new(get(url_to(container_name)))
end
|
Instance Method Details
#exec(commands = []) ⇒ Object
59
60
61
|
# File 'lib/codepicnic/console.rb', line 59
def exec(commands = [])
post url_to(@container_name, "exec"), {commands: commands}
end
|
#file_content(path = "") ⇒ Object
55
56
57
|
# File 'lib/codepicnic/console.rb', line 55
def file_content(path = "")
get url_to(@container_name, path)
end
|
#files ⇒ Object
51
52
53
|
# File 'lib/codepicnic/console.rb', line 51
def files
get url_to(@container_name, "files")
end
|
#find ⇒ Object
22
23
24
|
# File 'lib/codepicnic/console.rb', line 22
def find
get url_to(@container_name, "show")
end
|
#forks ⇒ Object
47
48
49
|
# File 'lib/codepicnic/console.rb', line 47
def forks
get url_to(@container_name, "forks")
end
|
#restart ⇒ Object
43
44
45
|
# File 'lib/codepicnic/console.rb', line 43
def restart
post url_to(@container_name, "restart")
end
|
#save ⇒ Object
26
27
28
29
30
31
|
# File 'lib/codepicnic/console.rb', line 26
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
68
69
70
|
# File 'lib/codepicnic/console.rb', line 68
def search(term, path)
get url_to(@container_name, "search")
end
|
#start ⇒ Object
33
34
35
36
37
|
# File 'lib/codepicnic/console.rb', line 33
def start
result = post(url_to(@container_name, "start"))
@url = result["url"]
result
end
|
#stop ⇒ Object
39
40
41
|
# File 'lib/codepicnic/console.rb', line 39
def stop
post url_to(@container_name, "stop")
end
|
#upload_file(file = nil, path = nil) ⇒ Object
63
64
65
66
|
# File 'lib/codepicnic/console.rb', line 63
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
|