repla 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/repla/dependencies/lib/controller.rb +22 -24
- data/lib/repla/dependencies/lib/model.rb +11 -8
- data/lib/repla/dependencies/lib/tester.rb +15 -15
- data/lib/repla/dependencies/lib/view.rb +19 -14
- data/lib/repla/dependencies.rb +25 -24
- data/lib/repla/lib/constants.rb +4 -4
- data/lib/repla/lib/controller.rb +1 -0
- data/lib/repla/lib/escape.rb +70 -0
- data/lib/repla/lib/module.rb +42 -59
- data/lib/repla/lib/view/javascript.rb +12 -31
- data/lib/repla/lib/view.rb +6 -7
- data/lib/repla/lib/window.rb +16 -12
- data/lib/repla/logger/test/lib/test_setup.rb +3 -2
- data/lib/repla/logger/test/lib/test_view_helper.rb +18 -19
- data/lib/repla/logger/test/tc_logger.rb +56 -56
- data/lib/repla/logger.rb +24 -23
- data/lib/repla/repl/lib/input_controller.rb +12 -13
- data/lib/repla/repl/lib/output_controller.rb +13 -14
- data/lib/repla/repl/lib/view.rb +23 -19
- data/lib/repla/repl.rb +37 -36
- data/lib/repla/resources/js/bullets/test/run_tests.rb +1 -1
- data/lib/repla/test/bundles/HelloWorld.wcplugin/Contents/Resources/hello_world.rb +1 -1
- data/lib/repla/test/bundles/Print.wcplugin/Contents/Resources/lib/controller.rb +16 -12
- data/lib/repla/test/bundles/Print.wcplugin/Contents/Resources/lib/view.rb +15 -9
- data/lib/repla/test/bundles/TestEnvironment.wcplugin/Contents/Resources/constants.rb +1 -1
- data/lib/repla/test/bundles/TestEnvironment.wcplugin/Contents/Resources/test_environment.rb +12 -17
- data/lib/repla/test/bundles/TestLog.wcplugin/Contents/Resources/test_log.rb +5 -5
- data/lib/repla/test/lib/helper.rb +5 -25
- data/lib/repla/test.rb +2 -2
- data/lib/repla.rb +1 -0
- metadata +2 -1
@@ -1,27 +1,26 @@
|
|
1
1
|
require_relative 'test_setup'
|
2
2
|
|
3
|
+
# Helper for testing view class
|
3
4
|
class TestViewHelper
|
5
|
+
def initialize(window_id, view_id)
|
6
|
+
@view = Repla::View.new(window_id, view_id)
|
7
|
+
javascript = File.read(TEST_JAVASCRIPT_FILE)
|
8
|
+
@view.do_javascript(javascript)
|
9
|
+
end
|
4
10
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@view.do_javascript(javascript)
|
9
|
-
end
|
11
|
+
def log_message_at_index(index)
|
12
|
+
@view.do_javascript_function('innerTextOfBodyChildAtIndex', [index])
|
13
|
+
end
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
|
15
|
+
def number_of_log_messages
|
16
|
+
@view.do_javascript(TEST_MESSAGE_COUNT_JAVASCRIPT)
|
17
|
+
end
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
def last_log_message
|
20
|
-
@view.do_javascript(TEST_MESSAGE_JAVASCRIPT)
|
21
|
-
end
|
22
|
-
|
23
|
-
def last_log_class
|
24
|
-
@view.do_javascript(TEST_CLASS_JAVASCRIPT)
|
25
|
-
end
|
19
|
+
def last_log_message
|
20
|
+
@view.do_javascript(TEST_MESSAGE_JAVASCRIPT)
|
21
|
+
end
|
26
22
|
|
23
|
+
def last_log_class
|
24
|
+
@view.do_javascript(TEST_CLASS_JAVASCRIPT)
|
25
|
+
end
|
27
26
|
end
|
@@ -1,36 +1,35 @@
|
|
1
1
|
#!/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'test/unit'
|
4
4
|
|
5
|
-
require_relative 'lib/test_setup
|
5
|
+
require_relative 'lib/test_setup'
|
6
6
|
|
7
|
-
require_relative
|
8
|
-
require_relative
|
7
|
+
require_relative 'lib/test_view_helper'
|
8
|
+
require_relative '../../logger'
|
9
9
|
|
10
|
+
# Test constants
|
10
11
|
class TestConstants < Test::Unit::TestCase
|
11
|
-
|
12
12
|
def test_constants
|
13
13
|
message_prefix = Repla::Logger::MESSAGE_PREFIX
|
14
|
-
assert_not_nil(message_prefix
|
14
|
+
assert_not_nil(message_prefix)
|
15
15
|
error_prefix = Repla::Logger::ERROR_PREFIX
|
16
|
-
assert_not_nil(
|
16
|
+
assert_not_nil(error_prefix)
|
17
17
|
end
|
18
|
-
|
19
18
|
end
|
20
19
|
|
21
|
-
|
20
|
+
# Test unitialized logger
|
22
21
|
class TestUnintializedLogger < Test::Unit::TestCase
|
23
|
-
|
24
22
|
def teardown
|
25
|
-
Repla::Test::Helper
|
26
|
-
assert(!Repla::Test::Helper
|
23
|
+
Repla::Test::Helper.quit
|
24
|
+
assert(!Repla::Test::Helper.app_running?,
|
25
|
+
'The application should not be running.')
|
27
26
|
end
|
28
27
|
|
29
28
|
def test_uninitialized_logger
|
30
29
|
logger = Repla::Logger.new
|
31
30
|
|
32
31
|
# Test Message
|
33
|
-
message =
|
32
|
+
message = 'Testing log message'
|
34
33
|
logger.info(message)
|
35
34
|
sleep Repla::Test::TEST_PAUSE_TIME # Pause for output to be processed
|
36
35
|
|
@@ -41,17 +40,14 @@ class TestUnintializedLogger < Test::Unit::TestCase
|
|
41
40
|
test_view_helper = TestViewHelper.new(logger.window_id, logger.view_id)
|
42
41
|
|
43
42
|
test_message = test_view_helper.last_log_message
|
44
|
-
assert_equal(message, test_message,
|
43
|
+
assert_equal(message, test_message, 'The messages should match')
|
45
44
|
test_class = test_view_helper.last_log_class
|
46
|
-
assert_equal(
|
47
|
-
|
45
|
+
assert_equal('message', test_class, 'The classes should match')
|
48
46
|
end
|
49
|
-
|
50
47
|
end
|
51
48
|
|
52
|
-
|
49
|
+
# Test logger
|
53
50
|
class TestLogger < Test::Unit::TestCase
|
54
|
-
|
55
51
|
def setup
|
56
52
|
@logger = Repla::Logger.new
|
57
53
|
@logger.show
|
@@ -59,82 +55,85 @@ class TestLogger < Test::Unit::TestCase
|
|
59
55
|
end
|
60
56
|
|
61
57
|
def teardown
|
62
|
-
Repla::Test::Helper
|
63
|
-
assert(!Repla::Test::Helper
|
58
|
+
Repla::Test::Helper.quit
|
59
|
+
assert(!Repla::Test::Helper.app_running?)
|
64
60
|
end
|
65
61
|
|
66
62
|
def test_logger
|
67
63
|
test_count = 0
|
68
64
|
|
69
65
|
# Test Error
|
70
|
-
message =
|
66
|
+
message = 'Testing log error'
|
71
67
|
@logger.error(message)
|
72
68
|
sleep Repla::Test::TEST_PAUSE_TIME # Pause for output to be processed
|
73
69
|
test_message = @test_view_helper.last_log_message
|
74
|
-
assert_equal(message, test_message
|
70
|
+
assert_equal(message, test_message)
|
75
71
|
test_class = @test_view_helper.last_log_class
|
76
|
-
assert_equal(
|
72
|
+
assert_equal('error', test_class)
|
77
73
|
result_count = @test_view_helper.number_of_log_messages
|
78
74
|
test_count += 1
|
79
|
-
assert_equal(test_count, result_count
|
75
|
+
assert_equal(test_count, result_count)
|
80
76
|
|
81
77
|
# Test Message
|
82
|
-
message =
|
78
|
+
message = 'Testing log message'
|
83
79
|
@logger.info(message)
|
84
80
|
sleep Repla::Test::TEST_PAUSE_TIME # Pause for output to be processed
|
85
81
|
test_message = @test_view_helper.last_log_message
|
86
|
-
assert_equal(message, test_message
|
82
|
+
assert_equal(message, test_message)
|
87
83
|
test_class = @test_view_helper.last_log_class
|
88
|
-
assert_equal(
|
84
|
+
assert_equal('message', test_class)
|
89
85
|
result_count = @test_view_helper.number_of_log_messages
|
90
86
|
test_count += 1
|
91
|
-
assert_equal(test_count, result_count
|
87
|
+
assert_equal(test_count, result_count)
|
92
88
|
|
93
89
|
# Test Only Error Prefix
|
94
|
-
|
90
|
+
# Note the trailing whitespace is trimmed
|
91
|
+
message = Repla::Logger::ERROR_PREFIX.rstrip
|
95
92
|
@logger.info(message)
|
96
93
|
sleep Repla::Test::TEST_PAUSE_TIME # Pause for output to be processed
|
97
94
|
test_message = @test_view_helper.last_log_message
|
98
|
-
assert_equal(message, test_message
|
95
|
+
assert_equal(message, test_message)
|
99
96
|
test_class = @test_view_helper.last_log_class
|
100
|
-
assert_equal(
|
97
|
+
assert_equal('message', test_class)
|
101
98
|
result_count = @test_view_helper.number_of_log_messages
|
102
99
|
test_count += 1
|
103
|
-
assert_equal(test_count, result_count
|
100
|
+
assert_equal(test_count, result_count)
|
104
101
|
|
105
102
|
# Test Only Message Prefix
|
106
|
-
|
103
|
+
# Note the trailing whitespace is trimmed
|
104
|
+
message = Repla::Logger::MESSAGE_PREFIX.rstrip
|
107
105
|
@logger.info(message)
|
108
106
|
sleep Repla::Test::TEST_PAUSE_TIME # Pause for output to be processed
|
109
107
|
test_message = @test_view_helper.last_log_message
|
110
|
-
assert_equal(message, test_message
|
108
|
+
assert_equal(message, test_message)
|
111
109
|
test_class = @test_view_helper.last_log_class
|
112
|
-
assert_equal(
|
110
|
+
assert_equal('message', test_class)
|
113
111
|
result_count = @test_view_helper.number_of_log_messages
|
114
112
|
test_count += 1
|
115
|
-
assert_equal(test_count, result_count
|
113
|
+
assert_equal(test_count, result_count)
|
116
114
|
|
117
115
|
# Test Blank Spaces
|
118
116
|
@logger.info(" \t")
|
119
117
|
sleep Repla::Test::TEST_PAUSE_TIME # Pause for output to be processed
|
120
|
-
test_message = @test_view_helper.last_log_message
|
121
|
-
assert_equal(message, test_message
|
122
|
-
test_class = @test_view_helper.last_log_class
|
123
|
-
assert_equal(
|
118
|
+
test_message = @test_view_helper.last_log_message
|
119
|
+
assert_equal(message, test_message)
|
120
|
+
test_class = @test_view_helper.last_log_class
|
121
|
+
assert_equal('message', test_class)
|
124
122
|
|
125
123
|
# Test Empty String
|
126
|
-
@logger.info(
|
124
|
+
@logger.info('')
|
127
125
|
sleep Repla::Test::TEST_PAUSE_TIME # Pause for output to be processed
|
128
|
-
test_message = @test_view_helper.last_log_message
|
129
|
-
assert_equal(message, test_message
|
130
|
-
test_class = @test_view_helper.last_log_class
|
131
|
-
assert_equal(
|
126
|
+
test_message = @test_view_helper.last_log_message
|
127
|
+
assert_equal(message, test_message)
|
128
|
+
test_class = @test_view_helper.last_log_class
|
129
|
+
assert_equal('message', test_class)
|
132
130
|
|
133
131
|
# TODO: Also add the following tests the `Log.wcplugin`
|
134
132
|
|
135
133
|
# Test Whitespace
|
136
|
-
# White space to the left should be preserved, whitespace to the right
|
137
|
-
# This test fails because retrieving the `innerText`
|
134
|
+
# White space to the left should be preserved, whitespace to the right
|
135
|
+
# should be removed This test fails because retrieving the `innerText`
|
136
|
+
# doesn't preserve whitepace.
|
138
137
|
|
139
138
|
# message = "\t Testing log message"
|
140
139
|
# @logger.info(message + "\t ")
|
@@ -145,26 +144,27 @@ class TestLogger < Test::Unit::TestCase
|
|
145
144
|
# assert_equal("message", test_class, "The classes should match")
|
146
145
|
# result_count = @test_view_helper.number_of_log_messages
|
147
146
|
# test_count += 1
|
148
|
-
# assert_equal(test_count, result_count
|
147
|
+
# assert_equal(test_count, result_count)
|
149
148
|
end
|
150
149
|
|
151
150
|
def test_long_input
|
152
|
-
message =
|
151
|
+
message = '
|
153
152
|
Line 1
|
154
153
|
|
155
154
|
Line 2
|
156
155
|
Line 3
|
157
|
-
|
156
|
+
'
|
158
157
|
@logger.info(message)
|
159
158
|
sleep Repla::Test::TEST_PAUSE_TIME * 2 # Pause for output to be processed
|
160
159
|
result_count = @test_view_helper.number_of_log_messages
|
161
|
-
assert_equal(result_count, 3,
|
160
|
+
assert_equal(result_count, 3, 'The number of log messages should match')
|
162
161
|
|
163
|
-
(1..3).each
|
162
|
+
(1..3).each do |i|
|
164
163
|
result = @test_view_helper.log_message_at_index(i - 1)
|
165
164
|
test_result = "Line #{i}"
|
166
|
-
assert_equal(result,
|
167
|
-
|
165
|
+
assert_equal(result,
|
166
|
+
test_result,
|
167
|
+
'The number of log messages should match')
|
168
|
+
end
|
168
169
|
end
|
169
|
-
|
170
170
|
end
|
data/lib/repla/logger.rb
CHANGED
@@ -1,34 +1,34 @@
|
|
1
1
|
require_relative '../repla'
|
2
2
|
|
3
3
|
module Repla
|
4
|
-
|
4
|
+
# Logger
|
5
5
|
class Logger
|
6
|
-
MESSAGE_PREFIX = 'MESSAGE '
|
7
|
-
ERROR_PREFIX = 'ERROR '
|
8
|
-
LOG_PLUGIN_NAME = 'Log'
|
6
|
+
MESSAGE_PREFIX = 'MESSAGE '.freeze
|
7
|
+
ERROR_PREFIX = 'ERROR '.freeze
|
8
|
+
LOG_PLUGIN_NAME = 'Log'.freeze
|
9
9
|
|
10
10
|
# Toggle
|
11
11
|
|
12
|
-
SHOW_LOG_SCRIPT = File.join(APPLESCRIPT_DIRECTORY,
|
12
|
+
SHOW_LOG_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, 'show_log.scpt')
|
13
13
|
def show
|
14
|
-
Repla
|
14
|
+
Repla.run_applescript(SHOW_LOG_SCRIPT, [window_id])
|
15
15
|
end
|
16
|
-
|
17
|
-
HIDE_LOG_SCRIPT = File.join(APPLESCRIPT_DIRECTORY,
|
16
|
+
|
17
|
+
HIDE_LOG_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, 'hide_log.scpt')
|
18
18
|
def hide
|
19
|
-
Repla
|
19
|
+
Repla.run_applescript(HIDE_LOG_SCRIPT, [window_id])
|
20
20
|
end
|
21
|
-
|
22
|
-
TOGGLE_LOG_SCRIPT = File.join(APPLESCRIPT_DIRECTORY,
|
21
|
+
|
22
|
+
TOGGLE_LOG_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, 'toggle_log.scpt')
|
23
23
|
def toggle
|
24
|
-
Repla
|
24
|
+
Repla.run_applescript(TOGGLE_LOG_SCRIPT, [window_id])
|
25
25
|
end
|
26
26
|
|
27
27
|
# Messages
|
28
28
|
|
29
29
|
def info(message)
|
30
30
|
message = message.dup
|
31
|
-
message.gsub!(
|
31
|
+
message.gsub!(/^/, MESSAGE_PREFIX) # Prefix all lines
|
32
32
|
# Strip trailing white space
|
33
33
|
# Add a line break
|
34
34
|
log_message(message)
|
@@ -36,33 +36,34 @@ module Repla
|
|
36
36
|
|
37
37
|
def error(message)
|
38
38
|
message = message.dup
|
39
|
-
message.gsub!(
|
39
|
+
message.gsub!(/^/, ERROR_PREFIX)
|
40
40
|
log_message(message)
|
41
41
|
end
|
42
42
|
|
43
43
|
# Properties
|
44
44
|
|
45
45
|
def window_id
|
46
|
-
|
46
|
+
key = WINDOW_ID_KEY
|
47
|
+
@window_id ||= ENV.key?(key) ? ENV[key] : Repla.create_window
|
47
48
|
end
|
48
|
-
|
49
|
+
|
49
50
|
def view_id
|
50
|
-
@view_id ||= Repla
|
51
|
+
@view_id ||= Repla.split_id_in_window(window_id, LOG_PLUGIN_NAME)
|
51
52
|
return @view_id unless @view_id.nil?
|
52
53
|
|
53
|
-
@view_id = Repla
|
54
|
-
Repla
|
55
|
-
@view_id
|
54
|
+
@view_id = Repla.split_id_in_window_last(window_id)
|
55
|
+
Repla.run_plugin_in_split(LOG_PLUGIN_NAME, window_id, @view_id)
|
56
|
+
@view_id
|
56
57
|
end
|
57
58
|
|
58
59
|
private
|
59
60
|
|
60
|
-
READ_FROM_STANDARD_INPUT_SCRIPT = File.join(APPLESCRIPT_DIRECTORY
|
61
|
+
READ_FROM_STANDARD_INPUT_SCRIPT = File.join(APPLESCRIPT_DIRECTORY)
|
61
62
|
def log_message(message)
|
62
63
|
message.rstrip!
|
63
64
|
message += "\n"
|
64
|
-
Repla
|
65
|
+
Repla.run_applescript(READ_FROM_STANDARD_INPUT_SCRIPT,
|
66
|
+
[message, window_id, view_id])
|
65
67
|
end
|
66
|
-
|
67
68
|
end
|
68
69
|
end
|
@@ -1,18 +1,17 @@
|
|
1
|
-
module Repla
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
module Repla
|
2
|
+
module REPL
|
3
|
+
# Input controller
|
4
|
+
class InputController < Repla::Controller
|
5
|
+
attr_accessor :view
|
6
|
+
def initialize(view)
|
7
|
+
@view = view
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
@view.add_input(input)
|
10
|
+
def parse_input(input)
|
11
|
+
input = input.dup
|
12
|
+
input.chomp!
|
13
|
+
@view.add_input(input) unless input.strip.empty? # Ignore empty lines
|
14
14
|
end
|
15
15
|
end
|
16
|
-
|
17
16
|
end
|
18
17
|
end
|
@@ -1,19 +1,18 @@
|
|
1
|
-
module Repla
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
module Repla
|
2
|
+
module REPL
|
3
|
+
# Output controller
|
4
|
+
class OutputController < Repla::Controller
|
5
|
+
attr_accessor :view
|
6
|
+
def initialize(view)
|
7
|
+
@view = view
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
@view.add_output(output)
|
10
|
+
def parse_output(output)
|
11
|
+
output = output.dup
|
12
|
+
output.gsub!(/\x1b[^m]*m/, '') # Remove escape sequences
|
13
|
+
output.chomp!
|
14
|
+
@view.add_output(output) unless output.strip.empty? # Ignore empty lines
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
18
17
|
end
|
19
18
|
end
|
data/lib/repla/repl/lib/view.rb
CHANGED
@@ -1,23 +1,27 @@
|
|
1
|
-
module Repla
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
module Repla
|
2
|
+
module REPL
|
3
|
+
# REPL 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')
|
8
|
+
def initialize
|
9
|
+
super
|
10
|
+
self.root_access_directory_path = File.expand_path(
|
11
|
+
ROOT_ACCESS_DIRECTORY
|
12
|
+
)
|
13
|
+
load_file(VIEW_TEMPLATE)
|
14
|
+
end
|
11
15
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
ADD_OUTPUT_JAVASCRIPT_FUNCTION = "WcREPL.addOutput"
|
18
|
-
def add_output(output)
|
19
|
-
do_javascript_function(ADD_OUTPUT_JAVASCRIPT_FUNCTION, [output])
|
20
|
-
end
|
16
|
+
ADD_INPUT_JAVASCRIPT_FUNCTION = 'WcREPL.addInput'.freeze
|
17
|
+
def add_input(input)
|
18
|
+
do_javascript_function(ADD_INPUT_JAVASCRIPT_FUNCTION, [input])
|
19
|
+
end
|
21
20
|
|
21
|
+
ADD_OUTPUT_JAVASCRIPT_FUNCTION = 'WcREPL.addOutput'.freeze
|
22
|
+
def add_output(output)
|
23
|
+
do_javascript_function(ADD_OUTPUT_JAVASCRIPT_FUNCTION, [output])
|
24
|
+
end
|
25
|
+
end
|
22
26
|
end
|
23
27
|
end
|
data/lib/repla/repl.rb
CHANGED
@@ -1,48 +1,49 @@
|
|
1
1
|
require_relative '../repla'
|
2
2
|
|
3
|
-
module Repla
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
3
|
+
module Repla
|
4
|
+
# REPL
|
5
|
+
module REPL
|
6
|
+
require_relative 'repl/lib/input_controller'
|
7
|
+
require_relative 'repl/lib/output_controller'
|
8
|
+
require_relative 'repl/lib/view'
|
9
|
+
|
10
|
+
# Wrapper
|
11
|
+
class Wrapper
|
12
|
+
require 'pty'
|
13
|
+
|
14
|
+
def initialize(command)
|
15
|
+
PTY.spawn(command) do |output, input, _pid|
|
16
|
+
Thread.new do
|
17
|
+
output.each do |line|
|
18
|
+
output_controller.parse_output(line)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
@input = input
|
18
22
|
end
|
19
|
-
@input = input
|
20
23
|
end
|
21
24
|
|
22
|
-
|
25
|
+
def parse_input(input)
|
26
|
+
input_controller.parse_input(input)
|
27
|
+
write_input(input)
|
28
|
+
end
|
23
29
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
30
|
+
def write_input(input)
|
31
|
+
@input.write(input)
|
32
|
+
end
|
28
33
|
|
29
|
-
|
30
|
-
@input.write(input)
|
31
|
-
end
|
34
|
+
private
|
32
35
|
|
33
|
-
|
36
|
+
def input_controller
|
37
|
+
@input_controller ||= InputController.new(view)
|
38
|
+
end
|
34
39
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
def output_controller
|
40
|
-
@output_controller ||= OutputController.new(view)
|
41
|
-
end
|
42
|
-
|
43
|
-
def view
|
44
|
-
@view ||= View.new
|
45
|
-
end
|
40
|
+
def output_controller
|
41
|
+
@output_controller ||= OutputController.new(view)
|
42
|
+
end
|
46
43
|
|
44
|
+
def view
|
45
|
+
@view ||= View.new
|
46
|
+
end
|
47
|
+
end
|
47
48
|
end
|
48
49
|
end
|
@@ -1,18 +1,22 @@
|
|
1
1
|
require_relative 'view'
|
2
|
+
require_relative '../../../../../../lib/escape'
|
2
3
|
|
3
|
-
module Repla
|
4
|
-
|
4
|
+
module Repla
|
5
|
+
# Print module
|
6
|
+
module Print
|
7
|
+
using Escape
|
8
|
+
# Print controller
|
9
|
+
class Controller < Repla::Controller
|
10
|
+
def initialize
|
11
|
+
@view = View.new
|
12
|
+
end
|
5
13
|
|
6
|
-
|
7
|
-
|
14
|
+
def parse_line(line)
|
15
|
+
line.chomp!
|
16
|
+
line.javascript_escape!
|
17
|
+
javascript = %[addOutput('#{line}');]
|
18
|
+
@view.do_javascript(javascript)
|
19
|
+
end
|
8
20
|
end
|
9
|
-
|
10
|
-
def parse_line(line)
|
11
|
-
line.chomp!
|
12
|
-
line.javascript_escape!
|
13
|
-
javascript = %Q[addOutput('#{line}');]
|
14
|
-
@view.do_javascript(javascript)
|
15
|
-
end
|
16
|
-
|
17
21
|
end
|
18
22
|
end
|
@@ -1,13 +1,19 @@
|
|
1
|
-
module Repla
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module Repla
|
2
|
+
module Print
|
3
|
+
# Print view
|
4
|
+
class View < Repla::View
|
5
|
+
ROOT_ACCESS_DIRECTORY = File.join(File.dirname(__FILE__),
|
6
|
+
'../../../../../../')
|
7
|
+
HTML_DIRECTORY = File.join(File.dirname(__FILE__), '../html/')
|
8
|
+
VIEW_TEMPLATE = File.join(HTML_DIRECTORY, 'index.html')
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
def initialize
|
11
|
+
super
|
12
|
+
self.root_access_directory_path = File.expand_path(
|
13
|
+
ROOT_ACCESS_DIRECTORY
|
14
|
+
)
|
15
|
+
load_file(VIEW_TEMPLATE)
|
16
|
+
end
|
11
17
|
end
|
12
18
|
end
|
13
19
|
end
|
@@ -1 +1 @@
|
|
1
|
-
TEST_PLUGIN_NAME =
|
1
|
+
TEST_PLUGIN_NAME = 'TestEnvironment'.freeze
|