13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/watch_tower/editor/base_appscript.rb', line 13
def self.included(base)
base.class_eval " # Include AppScript\n include ::Appscript\n\n # Is the editor running ?\n #\n # @return [Boolean]\n def is_running?\n editor.is_running? if editor\n end\n\n # Returns the name of the editor\n #\n # Child class should implement this method\n def name\n @name ||= editor.try(:name).try(:get)\n end\n\n # Returns the version of the editor\n #\n # Child class should implement this method\n def version\n @version ||= editor.try(:version).try(:get)\n end\n\n # Return the path of the document being edited\n # Child classes can override this method if the behaviour is different\n #\n # @return [String] path to the document currently being edited\n def current_path\n current_paths.try(:first)\n end\n\n # Return the pathes of the documents being edited\n # Child classes can override this method if the behaviour is different\n #\n # @return [Array] pathes to the documents currently being edited\n def current_paths\n if is_running? && editor.respond_to?(:document)\n editor.document.get.collect(&:path).collect(&:get)\n end\n end\n\n # The editor's name for the log\n # Child classes can overwrite this method\n #\n # @return [String]\n def to_s\n \"\\\#{self.class.to_s.split('::').last} Editor Version \\\#{version}\"\n end\n END\nend\n", __FILE__, __LINE__ + 1
|