lino 3.2.0.pre.8 → 3.2.0.pre.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da0833b0822fedee12bfa81350d5e87a69ef51bb9b4abc7f9f4537d5b851d3fe
4
- data.tar.gz: f3bc82e3a0f6af9b1ae512a8db77b01626b39b089616371a35bb523a625a3551
3
+ metadata.gz: 7cb69956b6fc3389deb0f7747c7ab5023225e95bee92ec99d1f7492d1a9020c4
4
+ data.tar.gz: 4fb9eeea0d1be41bae1d8864cbf0893c0dcfa9f654e5730b69ffd0d396c2106c
5
5
  SHA512:
6
- metadata.gz: e901b165f5fa1da7678057e04217b90558f7ef19f788b575e1dd3e1a5af825615e46040c33c24135899af5fa1ca1d8b150b83f225aeff568facc3498a2092f95
7
- data.tar.gz: 9bd2103be29ad1026863b39df46a33d2a9618343d06ce517a01558087d6f18a85501c9a3a12fb04ab526ac6a22b56a9d8f29f0ee4269cf5b4ba013da3c5a1b58
6
+ metadata.gz: aa736d59d32a7358972e4940035f4767c077e2d1af7edf6630c144cb07b9235788f086c22589d64bfd4f00f0e7ddf02dc01d5bf1976bac496b4c696a90a4a8ed
7
+ data.tar.gz: aff892172f4752f99f0b4d7d68075aa60ba20a6e5069ee8adb59a32c0d0cc7b6c7784420d7a7910ba97f8022614523642d9d6ef75bf00bb9392abf2fb86c4b01
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lino (3.2.0.pre.8)
4
+ lino (3.2.0.pre.10)
5
5
  childprocess (~> 5.0.0)
6
6
  hamster (~> 3.0)
7
7
  open4 (~> 1.3)
@@ -11,7 +11,7 @@ module Lino
11
11
  end
12
12
 
13
13
  def execute(command_line, opts = {})
14
- execution = { command_line:, opts:, exit_code: @exit_code }
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.merge(stdout_contents:)
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.merge(stderr_contents:)
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.merge(stdin_contents: stdin.read) if stdin
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
@@ -10,12 +10,12 @@ module Lino
10
10
  end
11
11
 
12
12
  def string
13
- argument
13
+ argument.to_s
14
14
  end
15
15
  alias to_s string
16
16
 
17
17
  def array
18
- [argument]
18
+ [argument.to_s]
19
19
  end
20
20
  alias to_a string
21
21
 
@@ -100,7 +100,7 @@ module Lino
100
100
  def formatted_components(format)
101
101
  {
102
102
  environment_variables: @environment_variables.map(&format),
103
- command: @command,
103
+ command: @command.to_s,
104
104
  options: @options
105
105
  .group_by(&:placement)
106
106
  .map { |p, o| [p, o.map(&format)] },
@@ -26,7 +26,7 @@ module Lino
26
26
  alias to_s string
27
27
 
28
28
  def array
29
- [name, value]
29
+ [name.to_s, value.to_s]
30
30
  end
31
31
  alias to_a array
32
32
 
@@ -13,12 +13,12 @@ module Lino
13
13
  end
14
14
 
15
15
  def string
16
- flag
16
+ flag.to_s
17
17
  end
18
18
  alias to_s string
19
19
 
20
20
  def array
21
- [flag]
21
+ [flag.to_s]
22
22
  end
23
23
  alias to_a string
24
24
 
@@ -29,7 +29,7 @@ module Lino
29
29
 
30
30
  def array
31
31
  if separator == ' '
32
- [option, value]
32
+ [option.to_s, value.to_s]
33
33
  else
34
34
  ["#{option}#{separator}#{value}"]
35
35
  end
@@ -12,12 +12,12 @@ module Lino
12
12
  end
13
13
 
14
14
  def string
15
- [@subcommand, @options.map(&:string)].reject(&:empty?).join(' ')
15
+ [@subcommand.to_s, @options.map(&:string)].reject(&:empty?).join(' ')
16
16
  end
17
17
  alias to_s string
18
18
 
19
19
  def array
20
- [@subcommand, @options.map(&:array)].flatten
20
+ [@subcommand.to_s, @options.map(&:array)].flatten
21
21
  end
22
22
  alias to_a array
23
23
 
data/lib/lino/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lino
4
- VERSION = '3.2.0.pre.8'
4
+ VERSION = '3.2.0.pre.10'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lino
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0.pre.8
4
+ version: 3.2.0.pre.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - InfraBlocks Maintainers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-08 00:00:00.000000000 Z
11
+ date: 2024-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: childprocess