Module: WebConsole
- Defined in:
- lib/webconsole.rb,
lib/webconsole/module.rb,
lib/webconsole/constants.rb,
lib/webconsole/controller.rb,
lib/webconsole/window_manager.rb
Defined Under Namespace
Classes: Controller, WindowManager
Constant Summary
collapse
- WEBCONSOLE_CONSTANTS =
File.join(File.dirname(__FILE__), "webconsole", "constants")
- LOAD_PLUGIN_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY, "load_plugin.scpt")
- RUN_PLUGIN_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY, "run_plugin.scpt")
- PLUGIN_HAS_WINDOWS_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY, "plugin_has_windows.scpt")
- WINDOW_ID_FOR_PLUGIN_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY, "window_id_for_plugin.scpt")
- RESOURCE_PATH_FOR_PLUGIN_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY, "resource_path_for_plugin.scpt")
- SHARED_RESOURCES_PLUGIN_NAME =
"Shared Resources"
- SHARED_TEST_RESOURCES_PLUGIN_NAME =
"Shared Test Resources"
- RESOURCE_URL_FOR_PLUGIN_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY, "resource_url_for_plugin.scpt")
- PLUGIN_READ_FROM_STANDARD_INPUT_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY, "plugin_read_from_standard_input.scpt")
- PLUGIN_NAME_KEY =
'WC_PLUGIN_NAME'
- WINDOW_ID_KEY =
'WC_WINDOW_ID'
- SHARED_RESOURCES_PATH_KEY =
'WC_SHARED_RESOURCES_PATH'
- SHARED_RESOURCES_URL_KEY =
'WC_SHARED_RESOURCES_URL'
- WINDOW_MANAGER_FILE =
File.join(File.dirname(__FILE__), "window_manager")
- CONTROLLER_FILE =
File.join(File.dirname(__FILE__), "controller")
- MODULE_FILE =
File.join(File.dirname(__FILE__), "module")
- APPLESCRIPT_DIRECTORY =
File.join(File.dirname(__FILE__), "..", "applescript")
Class Method Summary
collapse
Class Method Details
.load_plugin(path) ⇒ Object
4
5
6
|
# File 'lib/webconsole/module.rb', line 4
def self.load_plugin(path)
self.run_applescript(LOAD_PLUGIN_SCRIPT, [path])
end
|
.plugin_has_windows(name) ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/webconsole/module.rb', line 21
def self.plugin_has_windows(name)
result = self.run_applescript(PLUGIN_HAS_WINDOWS_SCRIPT, [name])
result.chomp!
if result == "true"
return true
else
return false
end
end
|
79
80
81
|
# File 'lib/webconsole/module.rb', line 79
def self.plugin_read_from_standard_input(name, text)
self.run_applescript(PLUGIN_READ_FROM_STANDARD_INPUT_SCRIPT, [name, text])
end
|
.resource_path_for_plugin(name) ⇒ Object
41
42
43
44
45
|
# File 'lib/webconsole/module.rb', line 41
def self.resource_path_for_plugin(name)
result = self.run_applescript(RESOURCE_PATH_FOR_PLUGIN_SCRIPT, [name])
result.chomp!
return result
end
|
.resource_url_for_plugin(name) ⇒ Object
68
69
70
71
72
|
# File 'lib/webconsole/module.rb', line 68
def self.resource_url_for_plugin(name)
result = self.run_applescript(RESOURCE_URL_FOR_PLUGIN_SCRIPT, [name])
result.chomp!
return result
end
|
.run_applescript(script, arguments = nil) ⇒ Object
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/webconsole/module.rb', line 85
def self.run_applescript(script, arguments = nil)
command = "osascript #{Shellwords.escape(script)}"
if arguments
arguments.each { |argument|
if argument
argument = argument.to_s
command = command + " " + Shellwords.escape(argument)
end
}
end
return `#{command}`
end
|
.run_plugin(name, directory = nil, arguments = nil) ⇒ Object
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/webconsole/module.rb', line 9
def self.run_plugin(name, directory = nil, arguments = nil)
parameters = [name]
if directory
parameters.push(directory)
end
if arguments
parameters = parameters + arguments
end
self.run_applescript(RUN_PLUGIN_SCRIPT, parameters)
end
|
.shared_resource(resource) ⇒ Object
58
59
60
|
# File 'lib/webconsole/module.rb', line 58
def self.shared_resource(resource)
return File.join(self.shared_resources_path, resource)
end
|
.shared_resources_path ⇒ Object
51
52
53
|
# File 'lib/webconsole/module.rb', line 51
def self.shared_resources_path
return WebConsole::resource_path_for_plugin(SHARED_RESOURCES_PLUGIN_NAME)
end
|
.shared_resources_url ⇒ Object
73
74
75
|
# File 'lib/webconsole/module.rb', line 73
def self.shared_resources_url
return WebConsole::resource_url_for_plugin(SHARED_RESOURCES_PLUGIN_NAME)
end
|
.shared_test_resource(resource) ⇒ Object
61
62
63
|
# File 'lib/webconsole/module.rb', line 61
def self.shared_test_resource(resource)
return File.join(self.shared_test_resources_path, resource)
end
|
.shared_test_resources_path ⇒ Object
54
55
56
|
# File 'lib/webconsole/module.rb', line 54
def self.shared_test_resources_path
return WebConsole::resource_path_for_plugin(SHARED_TEST_RESOURCES_PLUGIN_NAME)
end
|
.window_id_for_plugin(name) ⇒ Object
32
33
34
35
36
|
# File 'lib/webconsole/module.rb', line 32
def self.window_id_for_plugin(name)
result = self.run_applescript(WINDOW_ID_FOR_PLUGIN_SCRIPT, [name])
result.chomp!
return result
end
|