Module: Repla
- Defined in:
- lib/repla.rb,
lib/repla/repl.rb,
lib/repla/test.rb,
lib/repla/logger.rb,
lib/repla/lib/view.rb,
lib/repla/lib/module.rb,
lib/repla/lib/window.rb,
lib/repla/dependencies.rb,
lib/repla/lib/constants.rb,
lib/repla/repl/lib/view.rb,
lib/repla/lib/controller.rb,
lib/repla/test/lib/helper.rb,
lib/repla/lib/view/resources.rb,
lib/repla/lib/view/javascript.rb,
lib/repla/test/lib/view_helper.rb,
lib/repla/dependencies/lib/view.rb,
lib/repla/dependencies/lib/model.rb,
lib/repla/dependencies/lib/tester.rb,
lib/repla/repl/lib/input_controller.rb,
lib/repla/logger/test/lib/log_helper.rb,
lib/repla/logger/test/lib/log_tester.rb,
lib/repla/repl/lib/output_controller.rb,
lib/repla/dependencies/lib/controller.rb,
lib/repla/test/packages/Print.replaplugin/Contents/Resources/lib/view.rb,
lib/repla/test/packages/Print.replaplugin/Contents/Resources/lib/controller.rb
Overview
Defined Under Namespace
Modules: Dependencies, Print, REPL, Test
Classes: Controller, Logger, View, Window
Constant Summary
collapse
- LOAD_PLUGIN_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY, 'load_plugin.scpt')
- EXISTS_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY, 'exists.scpt')
- RUN_PLUGIN_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY, 'run_plugin.scpt')
- RUN_PLUGIN_WITH_ENVIRONMENT_SCRIPT =
File.join(
APPLESCRIPT_DIRECTORY, 'run_plugin_with_environment.scpt'
)
- RUN_PLUGIN_IN_SPLIT_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY,
'run_plugin_in_split.scpt')
- WINDOW_ID_FOR_PLUGIN_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY,
'window_id_for_plugin.scpt')
- SPLIT_ID_IN_WINDOW_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY,
'split_id_in_window.scpt')
- SPLIT_ID_IN_WINDOW_LAST_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY,
'split_id_in_window_last.scpt')
- CREATE_WINDOW_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY, 'create_window.scpt')
- RESOURCE_PATH_FOR_PLUGIN_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY,
'resource_path_for_plugin.scpt')
- RESOURCE_URL_FOR_PLUGIN_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY,
'resource_url_for_plugin.scpt')
- PLUGIN_NAME_KEY =
'WC_PLUGIN_NAME'.freeze
- SPLIT_ID_KEY =
'WC_SPLIT_ID'.freeze
- WINDOW_ID_KEY =
'WC_WINDOW_ID'.freeze
- DARK_MODE_KEY =
'WC_DARK_MODE'.freeze
- APPLESCRIPT_DIRECTORY =
File.join(__dir__, '../../applescript')
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.debug ⇒ Object
Returns the value of attribute debug.
10
11
12
|
# File 'lib/repla/lib/module.rb', line 10
def debug
@debug
end
|
Class Method Details
.application_exists ⇒ Object
19
20
21
22
|
# File 'lib/repla/lib/module.rb', line 19
def self.application_exists
result = run_applescript(EXISTS_SCRIPT)
result == 'true'
end
|
.create_window ⇒ Object
69
70
71
|
# File 'lib/repla/lib/module.rb', line 69
def self.create_window
run_applescript(CREATE_WINDOW_SCRIPT)
end
|
.load_plugin(path) ⇒ Object
14
15
16
|
# File 'lib/repla/lib/module.rb', line 14
def self.load_plugin(path)
run_applescript(LOAD_PLUGIN_SCRIPT, [path])
end
|
.resource_path_for_plugin(name) ⇒ Object
.resource_url_for_plugin(name) ⇒ Object
.run_applescript(script, arguments = nil) ⇒ Object
TODO: ‘self.run_applescript` should be private but now all of a sudden instances method can’t call private class methods?
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/repla/lib/module.rb', line 89
def self.run_applescript(script, arguments = nil)
command = "/usr/bin/osascript #{script}"
if arguments
command += ' ' + arguments.compact.map(&:to_s).map do |x|
x.shell_escape
end.join(' ')
end
puts command if @debug
result = `#{command}`
result.chomp!
return nil if result.empty?
return result.to_i if result.integer?
return result.to_f if result.float?
result
end
|
.run_plugin(name, directory = nil, arguments = nil) ⇒ Object
25
26
27
28
29
30
|
# File 'lib/repla/lib/module.rb', line 25
def self.run_plugin(name, directory = nil, arguments = nil)
parameters = [name]
parameters.push(directory) unless directory.nil?
parameters += arguments unless arguments.nil?
run_applescript(RUN_PLUGIN_SCRIPT, parameters)
end
|
.run_plugin_in_split(name, window_id, split_id) ⇒ Object
42
43
44
45
|
# File 'lib/repla/lib/module.rb', line 42
def self.run_plugin_in_split(name, window_id, split_id)
parameters = [name, window_id, split_id]
run_applescript(RUN_PLUGIN_IN_SPLIT_SCRIPT, parameters)
end
|
.run_plugin_with_environment(name, environment) ⇒ Object
35
36
37
38
|
# File 'lib/repla/lib/module.rb', line 35
def self.run_plugin_with_environment(name, environment)
parameters = [name, environment]
run_applescript(RUN_PLUGIN_WITH_ENVIRONMENT_SCRIPT, parameters)
end
|
.split_id_in_window(window_id, plugin_name = nil) ⇒ Object
55
56
57
58
59
|
# File 'lib/repla/lib/module.rb', line 55
def self.split_id_in_window(window_id, plugin_name = nil)
arguments = [window_id]
arguments.push(plugin_name) unless plugin_name.nil?
run_applescript(SPLIT_ID_IN_WINDOW_SCRIPT, arguments)
end
|
.split_id_in_window_last(window_id) ⇒ Object
63
64
65
66
|
# File 'lib/repla/lib/module.rb', line 63
def self.split_id_in_window_last(window_id)
arguments = [window_id]
run_applescript(SPLIT_ID_IN_WINDOW_LAST_SCRIPT, arguments)
end
|
.window_id_for_plugin(name) ⇒ Object
49
50
51
|
# File 'lib/repla/lib/module.rb', line 49
def self.window_id_for_plugin(name)
run_applescript(WINDOW_ID_FOR_PLUGIN_SCRIPT, [name])
end
|