lino 3.2.0.pre.8 → 3.2.0.pre.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/lino/executors/mock.rb +69 -4
- data/lib/lino/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: beea9421552cd298e9e5cd1147018e9f441d4d1125a4f0a62b92153d73977420
|
4
|
+
data.tar.gz: 041531edbe469e0e33bd2c4f2c88bc725dd9562dbbc3718dba9ee645f7afdd45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a30f3228f4a66df89fb8e9d0f55e7dbfa02aaf81cd5f241103130ca27d2c26463618b95dda82cb13c53c6c7b71312afff7ef0940c6a98a31d4f330aee34a7f3e
|
7
|
+
data.tar.gz: 6bcf014ce80d9a2e302978be707f33b1f493d37bef77e360fd30928681dbacce8cb1c19948d759265a920440a6c5bb240fd3f30d2ba3c556ecf37d44bbae22ff
|
data/Gemfile.lock
CHANGED
data/lib/lino/executors/mock.rb
CHANGED
@@ -11,7 +11,7 @@ module Lino
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def execute(command_line, opts = {})
|
14
|
-
execution =
|
14
|
+
execution = Execution.new(command_line:, opts:, exit_code: @exit_code)
|
15
15
|
execution = process_streams(execution, opts)
|
16
16
|
|
17
17
|
@executions << execution
|
@@ -53,7 +53,7 @@ module Lino
|
|
53
53
|
def process_stdout(execution, stdout)
|
54
54
|
if stdout && stdout_contents
|
55
55
|
stdout.write(stdout_contents)
|
56
|
-
return execution.
|
56
|
+
return execution.with_stdout_contents(stdout_contents)
|
57
57
|
end
|
58
58
|
|
59
59
|
execution
|
@@ -62,17 +62,82 @@ module Lino
|
|
62
62
|
def process_stderr(execution, stderr)
|
63
63
|
if stderr && stderr_contents
|
64
64
|
stderr.write(stderr_contents)
|
65
|
-
return execution.
|
65
|
+
return execution.with_stderr_contents(stderr_contents)
|
66
66
|
end
|
67
67
|
|
68
68
|
execution
|
69
69
|
end
|
70
70
|
|
71
71
|
def process_stdin(execution, stdin)
|
72
|
-
return execution.
|
72
|
+
return execution.with_stdin_contents(stdin.read) if stdin
|
73
73
|
|
74
74
|
execution
|
75
75
|
end
|
76
|
+
|
77
|
+
class Execution
|
78
|
+
attr_reader :command_line,
|
79
|
+
:opts,
|
80
|
+
:exit_code,
|
81
|
+
:stdin_contents,
|
82
|
+
:stdout_contents,
|
83
|
+
:stderr_contents
|
84
|
+
|
85
|
+
def initialize(state)
|
86
|
+
@command_line = state[:command_line]
|
87
|
+
@opts = state[:opts]
|
88
|
+
@exit_code = state[:exit_code]
|
89
|
+
@stdin_contents = state[:stdin_contents]
|
90
|
+
@stdout_contents = state[:stdout_contents]
|
91
|
+
@stderr_contents = state[:stderr_contents]
|
92
|
+
end
|
93
|
+
|
94
|
+
def with_stdin_contents(contents)
|
95
|
+
Execution.new(state_hash.merge(stdin_contents: contents))
|
96
|
+
end
|
97
|
+
|
98
|
+
def with_stdout_contents(contents)
|
99
|
+
Execution.new(state_hash.merge(stdout_contents: contents))
|
100
|
+
end
|
101
|
+
|
102
|
+
def with_stderr_contents(contents)
|
103
|
+
Execution.new(state_hash.merge(stderr_contents: contents))
|
104
|
+
end
|
105
|
+
|
106
|
+
def ==(other)
|
107
|
+
self.class == other.class &&
|
108
|
+
state_array == other.state_array
|
109
|
+
end
|
110
|
+
|
111
|
+
alias eql? ==
|
112
|
+
|
113
|
+
def hash
|
114
|
+
[self.class, state_array].hash
|
115
|
+
end
|
116
|
+
|
117
|
+
protected
|
118
|
+
|
119
|
+
def state_array
|
120
|
+
[
|
121
|
+
@command_line,
|
122
|
+
@opts,
|
123
|
+
@exit_code,
|
124
|
+
@stdin_contents,
|
125
|
+
@stdout_contents,
|
126
|
+
@stderr_contents
|
127
|
+
]
|
128
|
+
end
|
129
|
+
|
130
|
+
def state_hash
|
131
|
+
{
|
132
|
+
command_line: @command_line,
|
133
|
+
opts: @opts,
|
134
|
+
exit_code: @exit_code,
|
135
|
+
stdin_contents: @stdin_contents,
|
136
|
+
stdout_contents: @stdout_contents,
|
137
|
+
stderr_contents: @stderr_contents
|
138
|
+
}
|
139
|
+
end
|
140
|
+
end
|
76
141
|
end
|
77
142
|
end
|
78
143
|
end
|
data/lib/lino/version.rb
CHANGED