repla 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/lib/repla/dependencies/lib/controller.rb +22 -24
  3. data/lib/repla/dependencies/lib/model.rb +11 -8
  4. data/lib/repla/dependencies/lib/tester.rb +15 -15
  5. data/lib/repla/dependencies/lib/view.rb +19 -14
  6. data/lib/repla/dependencies.rb +25 -24
  7. data/lib/repla/lib/constants.rb +4 -4
  8. data/lib/repla/lib/controller.rb +1 -0
  9. data/lib/repla/lib/escape.rb +70 -0
  10. data/lib/repla/lib/module.rb +42 -59
  11. data/lib/repla/lib/view/javascript.rb +12 -31
  12. data/lib/repla/lib/view.rb +6 -7
  13. data/lib/repla/lib/window.rb +16 -12
  14. data/lib/repla/logger/test/lib/test_setup.rb +3 -2
  15. data/lib/repla/logger/test/lib/test_view_helper.rb +18 -19
  16. data/lib/repla/logger/test/tc_logger.rb +56 -56
  17. data/lib/repla/logger.rb +24 -23
  18. data/lib/repla/repl/lib/input_controller.rb +12 -13
  19. data/lib/repla/repl/lib/output_controller.rb +13 -14
  20. data/lib/repla/repl/lib/view.rb +23 -19
  21. data/lib/repla/repl.rb +37 -36
  22. data/lib/repla/resources/js/bullets/test/run_tests.rb +1 -1
  23. data/lib/repla/test/bundles/HelloWorld.wcplugin/Contents/Resources/hello_world.rb +1 -1
  24. data/lib/repla/test/bundles/Print.wcplugin/Contents/Resources/lib/controller.rb +16 -12
  25. data/lib/repla/test/bundles/Print.wcplugin/Contents/Resources/lib/view.rb +15 -9
  26. data/lib/repla/test/bundles/TestEnvironment.wcplugin/Contents/Resources/constants.rb +1 -1
  27. data/lib/repla/test/bundles/TestEnvironment.wcplugin/Contents/Resources/test_environment.rb +12 -17
  28. data/lib/repla/test/bundles/TestLog.wcplugin/Contents/Resources/test_log.rb +5 -5
  29. data/lib/repla/test/lib/helper.rb +5 -25
  30. data/lib/repla/test.rb +2 -2
  31. data/lib/repla.rb +1 -0
  32. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6c25d2a775a0a58b1b85c28fb7e659c031733ba
4
- data.tar.gz: 7bbd40e204cb30ccc62931c0669725dd6dd91cff
3
+ metadata.gz: b9d072ea3122cc808168f77e02aa527bee84b97f
4
+ data.tar.gz: 3425a55a09e166dd54b32d526d295ffff411a106
5
5
  SHA512:
6
- metadata.gz: 61e74ff0e82cc4e04b45495fbdd58ec26b828d0af6990efd856fabe575de63c9941b9e95a3edfc35357345746eab6dd2d3c8515503ed4dcfd57170fdb9fbb8c8
7
- data.tar.gz: 01ffaf898ce45b8964e7a0e63b8e4571a85f2aae7c51ba3c0d3d5c2ff779e9771d20c1fea7d19fb24c4f05172cb39dbe7d55703898b31fb05d7f0db3e5279735
6
+ metadata.gz: 2b410101c334239ea91222c48ec893a4ee9187266a57e46748a4c64b6418bcda4778c11a35b8b27a030bdf4df4e54ce720ed8e3d921b5f514a3c65488d104e01
7
+ data.tar.gz: df7a9f1397e818791db811fbba2efff84a38b5c36e2b6f68c82f66eba1ce6f2b25c5a3996ae4740f46ad5e922c83a5f651f4bd14026f954ab6feed8b1065f6e6
@@ -2,33 +2,31 @@ require_relative 'tester'
2
2
  require_relative 'model'
3
3
  require_relative 'view'
4
4
 
5
- module Repla::Dependencies
6
-
7
- class Controller < Repla::Controller
8
-
9
- def initialize
10
- @view = View.new
11
- end
12
-
13
- def missing_dependency(dependency)
14
- name = dependency.name
15
- type = self.class.string_for_type(dependency.type)
16
- options = dependency.options
17
- if options.has_key?(:installation_instructions)
18
- installation_instructions = options[:installation_instructions]
19
- end
20
- @view.add_missing_dependency(name, type, installation_instructions)
21
- end
5
+ module Repla
6
+ module Dependencies
7
+ # Dependencies controller
8
+ class Controller < Repla::Controller
9
+ def initialize
10
+ @view = View.new
11
+ end
22
12
 
23
- private
13
+ def missing_dependency(dependency)
14
+ name = dependency.name
15
+ type = self.class.string_for_type(dependency.type)
16
+ options = dependency.options
17
+ if options.key?(:installation_instructions)
18
+ installation_instructions = options[:installation_instructions]
19
+ end
20
+ @view.add_missing_dependency(name, type, installation_instructions)
21
+ end
24
22
 
25
- def self.string_for_type(type)
26
- case type
27
- when :shell_command
28
- return "shell command"
23
+ private_class_method def self.string_for_type(type)
24
+ case type
25
+ when :shell_command
26
+ return 'shell command'
27
+ end
28
+ nil
29
29
  end
30
- nil
31
30
  end
32
-
33
31
  end
34
32
  end
@@ -1,10 +1,13 @@
1
- module Repla::Dependencies
2
- class Dependency
3
- attr_reader :name, :type, :options
4
- def initialize(name, type, options = {})
5
- @name = name
6
- @type = type
7
- @options = options
8
- end
1
+ module Repla
2
+ module Dependencies
3
+ # Dependency
4
+ class Dependency
5
+ attr_reader :name, :type, :options
6
+ def initialize(name, type, options = {})
7
+ @name = name
8
+ @type = type
9
+ @options = options
10
+ end
11
+ end
9
12
  end
10
13
  end
@@ -1,19 +1,19 @@
1
- module Repla::Dependencies
2
- module Tester
3
- def self.check(name, type)
4
- case type
5
- when :shell_command
6
- return check_shell_command(name)
1
+ module Repla
2
+ module Dependencies
3
+ # Tester
4
+ module Tester
5
+ def self.check(name, type)
6
+ case type
7
+ when :shell_command
8
+ check_shell_command(name)
9
+ end
7
10
  end
8
- end
9
-
10
- private
11
-
12
- require 'shellwords'
13
- def self.check_shell_command(name)
14
- command = "type -a #{Shellwords.escape(name)} > /dev/null 2>&1"
15
- system(command)
16
- end
17
11
 
12
+ require 'shellwords'
13
+ private_class_method def self.check_shell_command(name)
14
+ command = "type -a #{Shellwords.escape(name)} > /dev/null 2>&1"
15
+ system(command)
16
+ end
17
+ end
18
18
  end
19
19
  end
@@ -1,19 +1,24 @@
1
- module Repla::Dependencies
2
-
3
- class View < Repla::View
4
- ROOT_ACCESS_DIRECTORY = File.join(File.dirname(__FILE__), '../../')
5
- HTML_DIRECTORY = File.join(File.dirname(__FILE__), '../html/')
6
- VIEW_TEMPLATE = File.join(HTML_DIRECTORY, 'index.html')
1
+ module Repla
2
+ module Dependencies
3
+ # Dependency view
4
+ class View < Repla::View
5
+ ROOT_ACCESS_DIRECTORY = File.join(File.dirname(__FILE__), '../../')
6
+ HTML_DIRECTORY = File.join(File.dirname(__FILE__), '../html/')
7
+ VIEW_TEMPLATE = File.join(HTML_DIRECTORY, 'index.html')
7
8
 
8
- def initialize
9
- super
10
- self.root_access_directory_path = File.expand_path(ROOT_ACCESS_DIRECTORY)
11
- load_file(VIEW_TEMPLATE)
12
- end
9
+ def initialize
10
+ super
11
+ self.root_access_directory_path = File.expand_path(
12
+ ROOT_ACCESS_DIRECTORY
13
+ )
14
+ load_file(VIEW_TEMPLATE)
15
+ end
13
16
 
14
- ADD_MISSING_DEPENDENCY_FUNCTION = "addMissingDependency"
15
- def add_missing_dependency(name, type, installation_instructions = nil)
16
- do_javascript_function(ADD_MISSING_DEPENDENCY_FUNCTION, [name, type, installation_instructions])
17
+ ADD_MISSING_DEPENDENCY_FUNCTION = 'addMissingDependency'.freeze
18
+ def add_missing_dependency(name, type, installation_instructions = nil)
19
+ do_javascript_function(ADD_MISSING_DEPENDENCY_FUNCTION,
20
+ [name, type, installation_instructions])
21
+ end
17
22
  end
18
23
  end
19
24
  end
@@ -1,33 +1,34 @@
1
1
  require_relative '../repla'
2
2
 
3
- module Repla::Dependencies
4
- class Checker
5
- require_relative 'dependencies/lib/model'
6
- require_relative 'dependencies/lib/controller'
3
+ module Repla
4
+ module Dependencies
5
+ # Checks whether bundle dependencies are installed
6
+ class Checker
7
+ require_relative 'dependencies/lib/model'
8
+ require_relative 'dependencies/lib/controller'
7
9
 
8
- def check_dependencies(dependencies)
9
- passed = true
10
- dependencies.each { |dependency|
11
- dependency_passed = check(dependency)
12
- passed = false unless dependency_passed
13
- }
14
- passed
15
- end
10
+ def check_dependencies(dependencies)
11
+ passed = true
12
+ dependencies.each do |dependency|
13
+ dependency_passed = check(dependency)
14
+ passed = false unless dependency_passed
15
+ end
16
+ passed
17
+ end
16
18
 
17
- def check(dependency)
18
- name = dependency.name
19
- type = dependency.type
20
- passed = Tester::check(name, type)
21
- controller.missing_dependency(dependency) unless passed
22
- passed
23
- end
19
+ def check(dependency)
20
+ name = dependency.name
21
+ type = dependency.type
22
+ passed = Tester.check(name, type)
23
+ controller.missing_dependency(dependency) unless passed
24
+ passed
25
+ end
24
26
 
25
- private
27
+ private
26
28
 
27
- def controller
28
- @controller ||= Controller.new
29
+ def controller
30
+ @controller ||= Controller.new
31
+ end
29
32
  end
30
-
31
33
  end
32
-
33
34
  end
@@ -1,9 +1,9 @@
1
1
  module Repla
2
2
  # Keys
3
- PLUGIN_NAME_KEY = 'WC_PLUGIN_NAME'
4
- SPLIT_ID_KEY = 'WC_SPLIT_ID'
5
- WINDOW_ID_KEY = 'WC_WINDOW_ID'
3
+ PLUGIN_NAME_KEY = 'WC_PLUGIN_NAME'.freeze
4
+ SPLIT_ID_KEY = 'WC_SPLIT_ID'.freeze
5
+ WINDOW_ID_KEY = 'WC_WINDOW_ID'.freeze
6
6
 
7
7
  # Directories
8
- APPLESCRIPT_DIRECTORY = File.join(File.dirname(__FILE__), "..", "..", "applescript")
8
+ APPLESCRIPT_DIRECTORY = File.join(File.dirname(__FILE__), '../../applescript')
9
9
  end
@@ -1,4 +1,5 @@
1
1
  module Repla
2
+ # Controller
2
3
  class Controller
3
4
  attr_reader :view
4
5
  end
@@ -0,0 +1,70 @@
1
+ require 'Shellwords'
2
+
3
+ # Escaping parameters
4
+ module Escape
5
+ # Escaping floats
6
+ module FloatEscape
7
+ def javascript_argument
8
+ to_s
9
+ end
10
+ end
11
+ # Escaping integers
12
+ module IntegerEscape
13
+ def javascript_argument
14
+ to_s
15
+ end
16
+ end
17
+
18
+ # Escaping strings
19
+ module StringEscape
20
+ def javascript_argument
21
+ "'#{StringEscape.javascript_escape(self)}'"
22
+ end
23
+
24
+ def javascript_escape
25
+ StringEscape.javascript_escape(self)
26
+ end
27
+
28
+ def javascript_escape!
29
+ replace(StringEscape.javascript_escape(self))
30
+ end
31
+
32
+ def float?
33
+ true if Float(self)
34
+ rescue StandardError
35
+ false
36
+ end
37
+
38
+ def integer?
39
+ to_i.to_s == self
40
+ end
41
+
42
+ def shell_escape
43
+ StringEscape.shell_escape(self)
44
+ end
45
+
46
+ def shell_escape!
47
+ replace(StringEscape.shell_escape(self))
48
+ end
49
+
50
+ private_class_method def self.javascript_escape(string)
51
+ string.gsub('\\', '\\\\\\\\').gsub("\n", '\\\\n').gsub("'", "\\\\'")
52
+ end
53
+
54
+ private_class_method def self.shell_escape(string)
55
+ Shellwords.escape(string)
56
+ end
57
+ end
58
+
59
+ refine String do
60
+ include StringEscape
61
+ end
62
+
63
+ refine Integer do
64
+ include IntegerEscape
65
+ end
66
+
67
+ refine Float do
68
+ include FloatEscape
69
+ end
70
+ end
@@ -1,72 +1,83 @@
1
1
  require 'Shellwords'
2
+ require_relative 'escape'
3
+
4
+ # Repla
2
5
  module Repla
3
- LOAD_PLUGIN_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "load_plugin.scpt")
6
+ using Escape
7
+
8
+ LOAD_PLUGIN_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, 'load_plugin.scpt')
4
9
  def self.load_plugin(path)
5
- self.run_applescript(LOAD_PLUGIN_SCRIPT, [path])
10
+ run_applescript(LOAD_PLUGIN_SCRIPT, [path])
6
11
  end
7
12
 
8
- EXISTS_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "exists.scpt")
13
+ EXISTS_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, 'exists.scpt')
9
14
  def self.application_exists
10
- result = self.run_applescript(EXISTS_SCRIPT)
11
- result == "true" ? true : false
15
+ result = run_applescript(EXISTS_SCRIPT)
16
+ result == 'true'
12
17
  end
13
18
 
14
- RUN_PLUGIN_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "run_plugin.scpt")
19
+ RUN_PLUGIN_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, 'run_plugin.scpt')
15
20
  def self.run_plugin(name, directory = nil, arguments = nil)
16
21
  parameters = [name]
17
22
  parameters.push(directory) unless directory.nil?
18
23
  parameters += arguments unless arguments.nil?
19
- self.run_applescript(RUN_PLUGIN_SCRIPT, parameters)
24
+ run_applescript(RUN_PLUGIN_SCRIPT, parameters)
20
25
  end
21
-
22
- RUN_PLUGIN_IN_SPLIT_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "run_plugin_in_split.scpt")
26
+
27
+ RUN_PLUGIN_IN_SPLIT_SCRIPT = File.join(APPLESCRIPT_DIRECTORY,
28
+ 'run_plugin_in_split.scpt')
23
29
  def self.run_plugin_in_split(name, window_id, split_id)
24
30
  parameters = [name, window_id, split_id]
25
- self.run_applescript(RUN_PLUGIN_IN_SPLIT_SCRIPT, parameters)
31
+ run_applescript(RUN_PLUGIN_IN_SPLIT_SCRIPT, parameters)
26
32
  end
27
33
 
28
- WINDOW_ID_FOR_PLUGIN_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "window_id_for_plugin.scpt")
34
+ WINDOW_ID_FOR_PLUGIN_SCRIPT = File.join(APPLESCRIPT_DIRECTORY,
35
+ 'window_id_for_plugin.scpt')
29
36
  def self.window_id_for_plugin(name)
30
- self.run_applescript(WINDOW_ID_FOR_PLUGIN_SCRIPT, [name])
37
+ run_applescript(WINDOW_ID_FOR_PLUGIN_SCRIPT, [name])
31
38
  end
32
39
 
33
- SPLIT_ID_IN_WINDOW_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "split_id_in_window.scpt")
34
- def self.split_id_in_window(window_id, pluginName = nil)
40
+ SPLIT_ID_IN_WINDOW_SCRIPT = File.join(APPLESCRIPT_DIRECTORY,
41
+ 'split_id_in_window.scpt')
42
+ def self.split_id_in_window(window_id, plugin_name = nil)
35
43
  arguments = [window_id]
36
- arguments.push(pluginName) unless pluginName.nil?
37
- self.run_applescript(SPLIT_ID_IN_WINDOW_SCRIPT, arguments)
44
+ arguments.push(plugin_name) unless plugin_name.nil?
45
+ run_applescript(SPLIT_ID_IN_WINDOW_SCRIPT, arguments)
38
46
  end
39
47
 
40
- SPLIT_ID_IN_WINDOW_LAST_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "split_id_in_window_last.scpt")
48
+ SPLIT_ID_IN_WINDOW_LAST_SCRIPT = File.join(APPLESCRIPT_DIRECTORY,
49
+ 'split_id_in_window_last.scpt')
41
50
  def self.split_id_in_window_last(window_id)
42
51
  arguments = [window_id]
43
- self.run_applescript(SPLIT_ID_IN_WINDOW_LAST_SCRIPT, arguments)
52
+ run_applescript(SPLIT_ID_IN_WINDOW_LAST_SCRIPT, arguments)
44
53
  end
45
54
 
46
- CREATE_WINDOW_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "create_window.scpt")
55
+ CREATE_WINDOW_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, 'create_window.scpt')
47
56
  def self.create_window
48
- self.run_applescript(CREATE_WINDOW_SCRIPT)
57
+ run_applescript(CREATE_WINDOW_SCRIPT)
49
58
  end
50
59
 
51
60
  # Resources
52
61
 
53
- RESOURCE_PATH_FOR_PLUGIN_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "resource_path_for_plugin.scpt")
62
+ RESOURCE_PATH_FOR_PLUGIN_SCRIPT = File.join(APPLESCRIPT_DIRECTORY,
63
+ 'resource_path_for_plugin.scpt')
54
64
  def self.resource_path_for_plugin(name)
55
- self.run_applescript(RESOURCE_PATH_FOR_PLUGIN_SCRIPT, [name])
65
+ run_applescript(RESOURCE_PATH_FOR_PLUGIN_SCRIPT, [name])
56
66
  end
57
67
 
58
- RESOURCE_URL_FOR_PLUGIN_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "resource_url_for_plugin.scpt")
68
+ RESOURCE_URL_FOR_PLUGIN_SCRIPT = File.join(APPLESCRIPT_DIRECTORY,
69
+ 'resource_url_for_plugin.scpt')
59
70
  def self.resource_url_for_plugin(name)
60
- self.run_applescript(RESOURCE_URL_FOR_PLUGIN_SCRIPT, [name])
71
+ run_applescript(RESOURCE_URL_FOR_PLUGIN_SCRIPT, [name])
61
72
  end
62
73
 
63
- private
64
-
65
- def self.run_applescript(script, arguments = nil)
74
+ private_class_method def self.run_applescript(script, arguments = nil)
66
75
  command = "osascript #{script.shell_escape}"
67
76
 
68
77
  if arguments
69
- command += " " + arguments.compact.map(&:to_s).map(&:shell_escape).join(' ')
78
+ command += ' ' + arguments.compact.map(&:to_s).map do |x|
79
+ x.shell_escape
80
+ end.join(' ')
70
81
  end
71
82
 
72
83
  result = `#{command}`
@@ -74,37 +85,9 @@ module Repla
74
85
  result.chomp!
75
86
 
76
87
  return nil if result.empty?
77
- return result.to_i if result.is_integer?
78
- return result.to_f if result.is_float?
79
-
80
- result
81
- end
82
-
83
- class ::String
84
- def is_float?
85
- true if Float(self) rescue false
86
- end
87
-
88
- def is_integer?
89
- self.to_i.to_s == self
90
- end
88
+ return result.to_i if result.integer?
89
+ return result.to_f if result.float?
91
90
 
92
- def shell_escape
93
- Shellwords.escape(self)
94
- end
95
-
96
- def shell_escape!
97
- replace(shell_escape)
98
- end
99
-
100
- end
101
-
102
- class ::Float
103
- alias_method :javascript_argument, :to_s
104
- end
105
-
106
- class ::Integer
107
- alias_method :javascript_argument, :to_s
91
+ result
108
92
  end
109
-
110
93
  end
@@ -1,6 +1,10 @@
1
+ require_relative '../escape'
2
+
3
+ # Repla
1
4
  module Repla
5
+ using Escape
6
+ # View
2
7
  class View < Window
3
-
4
8
  def do_javascript_function(function, arguments = nil)
5
9
  javascript = self.class.javascript_function(function, arguments)
6
10
  do_javascript(javascript)
@@ -11,41 +15,18 @@ module Repla
11
15
  function << '('
12
16
 
13
17
  if arguments
14
- arguments.each { |argument|
15
- if argument
16
- function << argument.javascript_argument
17
- else
18
- function << "null"
19
- end
18
+ arguments.each do |argument|
19
+ function << if argument
20
+ argument.javascript_argument
21
+ else
22
+ 'null'
23
+ end
20
24
  function << ', '
21
- }
25
+ end
22
26
  function = function[0...-2]
23
27
  end
24
28
 
25
29
  function << ');'
26
30
  end
27
-
28
- private
29
-
30
- class ::Fixnum
31
- def javascript_argument
32
- "#{self}"
33
- end
34
- end
35
-
36
- class ::String
37
- def javascript_argument
38
- "'#{self.javascript_escape}'"
39
- end
40
-
41
- def javascript_escape
42
- self.gsub('\\', "\\\\\\\\").gsub("\n", "\\\\n").gsub("'", "\\\\'")
43
- end
44
-
45
- def javascript_escape!
46
- replace(self.javascript_escape)
47
- end
48
- end
49
-
50
31
  end
51
32
  end
@@ -1,10 +1,10 @@
1
- require_relative "window"
2
- require_relative "view/javascript"
3
- require_relative "view/resources"
1
+ require_relative 'window'
2
+ require_relative 'view/javascript'
3
+ require_relative 'view/resources'
4
4
 
5
5
  module Repla
6
+ # View
6
7
  class View < Window
7
-
8
8
  # Properties
9
9
  def initialize(window_id = nil, view_id = nil)
10
10
  super(window_id)
@@ -12,16 +12,15 @@ module Repla
12
12
  end
13
13
 
14
14
  def view_id
15
- @view_id ||= ENV.has_key?(SPLIT_ID_KEY) ? ENV[SPLIT_ID_KEY] : split_id
15
+ @view_id ||= ENV.key?(SPLIT_ID_KEY) ? ENV[SPLIT_ID_KEY] : split_id
16
16
  end
17
17
 
18
18
  private
19
-
19
+
20
20
  # Web
21
21
 
22
22
  def arguments_with_target(arguments)
23
23
  super(arguments).push(view_id)
24
24
  end
25
-
26
25
  end
27
26
  end
@@ -1,6 +1,7 @@
1
1
  module Repla
2
+ # Window
2
3
  class Window
3
- require_relative "constants"
4
+ require_relative 'constants'
4
5
 
5
6
  attr_accessor :root_access_directory_path
6
7
  def initialize(window_id = nil)
@@ -10,13 +11,16 @@ module Repla
10
11
  # Properties
11
12
 
12
13
  def window_id
13
- @window_id ||= ENV.has_key?(WINDOW_ID_KEY) ? ENV[WINDOW_ID_KEY] : Repla::create_window
14
+ key = WINDOW_ID_KEY
15
+ @window_id ||= ENV.key?(key) ? ENV[key] : Repla.create_window
14
16
  end
15
17
 
16
18
  # Web
17
19
 
18
- LOAD_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "load.scpt")
19
- LOADWITHROOTACCESSDIRECTORY_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "load_with_root_access_directory.scpt")
20
+ LOAD_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, 'load.scpt')
21
+ LOADWITHROOTACCESSDIRECTORY_SCRIPT = File.join(
22
+ APPLESCRIPT_DIRECTORY, 'load_with_root_access_directory.scpt'
23
+ )
20
24
  def load_file(file)
21
25
  arguments = [file]
22
26
 
@@ -30,41 +34,41 @@ module Repla
30
34
  run_script(script, arguments)
31
35
  end
32
36
 
33
- DOJAVASCRIPT_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "do_javascript.scpt")
37
+ DOJAVASCRIPT_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, 'do_javascript.scpt')
34
38
  def do_javascript(javascript)
35
39
  run_script(DOJAVASCRIPT_SCRIPT, [javascript])
36
40
  end
37
41
 
38
- READ_FROM_STANDARD_INPUT_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "read_from_standard_input.scpt")
42
+ READ_FROM_STANDARD_INPUT_SCRIPT = File.join(APPLESCRIPT_DIRECTORY,
43
+ 'read_from_standard_input.scpt')
39
44
  def read_from_standard_input(text)
40
45
  run_script(READ_FROM_STANDARD_INPUT_SCRIPT, [text])
41
46
  end
42
47
 
43
48
  # Window
44
49
 
45
- CLOSEWINDOW_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "close_window.scpt")
50
+ CLOSEWINDOW_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, 'close_window.scpt')
46
51
  def close
47
- Repla::run_applescript(CLOSEWINDOW_SCRIPT, [window_id])
52
+ Repla.run_applescript(CLOSEWINDOW_SCRIPT, [window_id])
48
53
  end
49
54
 
50
55
  def split_id
51
- Repla::split_id_in_window(window_id)
56
+ Repla.split_id_in_window(window_id)
52
57
  end
53
58
 
54
59
  def split_id_last
55
- Repla::split_id_in_window_last(window_id)
60
+ Repla.split_id_in_window_last(window_id)
56
61
  end
57
62
 
58
63
  private
59
64
 
60
65
  def run_script(script, arguments = [])
61
66
  arguments = arguments_with_target(arguments)
62
- Repla::run_applescript(script, arguments)
67
+ Repla.run_applescript(script, arguments)
63
68
  end
64
69
 
65
70
  def arguments_with_target(arguments)
66
71
  arguments.push(window_id)
67
72
  end
68
-
69
73
  end
70
74
  end
@@ -1,4 +1,4 @@
1
- require_relative "../../../test"
1
+ require_relative '../../../test'
2
2
  require Repla::Test::HELPER_FILE
3
3
  require Repla::Test::REPLA_FILE
4
4
 
@@ -7,4 +7,5 @@ TEST_MESSAGE_JAVASCRIPT = 'document.body.lastChild.innerText'.freeze
7
7
  TEST_MESSAGE_COUNT_JAVASCRIPT = 'document.body.children.length'.freeze
8
8
 
9
9
  TEST_JAVASCRIPT_DIRECTORY = File.join(File.dirname(__FILE__), '..', 'js')
10
- TEST_JAVASCRIPT_FILE = File.join(TEST_JAVASCRIPT_DIRECTORY, 'test_view_helper.js')
10
+ TEST_JAVASCRIPT_FILE = File.join(TEST_JAVASCRIPT_DIRECTORY,
11
+ 'test_view_helper.js')