lino 3.2.0.pre.6 → 3.2.0.pre.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1dd66849dd6c056a887e3db11f3b7e4ce81fe79977803e756295b432782990d
4
- data.tar.gz: dd084ea5d3d3e2399e17e3bf560fd5452094623218c0b3124e4ed2749e9abfc7
3
+ metadata.gz: 316b2b5ecae6178261c4b76fedfe0c5797ae50355a94a939f02c115507ba2a37
4
+ data.tar.gz: 7ee4b662f7c3b1b5fa7ca3b6aca9d1e2597c5804d12732822bf766cfad2d228f
5
5
  SHA512:
6
- metadata.gz: efbe7f4fea738bceb5ae5e148de4591e0a635a0c67923e30eb69f9503723d2bb70eb28911fd1addde172218d217de1cb27a9d3237293759b323a341c964ba3af
7
- data.tar.gz: 38833fa7c9b6c9c91e1056099fa4f3d0fe35117c624cb20bc7e265ad234a27613fa5f8f13176a148b0690bf60368d4919a0263d455e1faebdb1922801548995c
6
+ metadata.gz: 152d8164ab1b7b00deaae2538d18559d872a5fb8800231728d238a34fa0393658134fc41244134288e7b2a6cff8b8962bb48bb5c151104a24aadb798da9149cd
7
+ data.tar.gz: b2549104ac5496bb688b3cb61c8b4229bc99af00be5071871dbabd018007603734940f610658f20a8c62a9bd0638d1923e0f3b8631dc873819c812de54084deb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lino (3.2.0.pre.6)
4
+ lino (3.2.0.pre.7)
5
5
  childprocess (~> 5.0.0)
6
6
  hamster (~> 3.0)
7
7
  open4 (~> 1.3)
@@ -5,8 +5,8 @@ module Lino
5
5
  module Mixins
6
6
  module Executor
7
7
  def initialize(state)
8
- @executor = state[:executor] || Executors::Childprocess.new
9
8
  super
9
+ @executor = state[:executor] || Lino.configuration.executor
10
10
  end
11
11
 
12
12
  def with_executor(executor)
@@ -17,7 +17,7 @@ module Lino
17
17
 
18
18
  exit_code = process.wait
19
19
 
20
- return unless exit_code != 0
20
+ return if exit_code.zero?
21
21
 
22
22
  raise Lino::Errors::ExecutionError.new(
23
23
  command_line.string, exit_code
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lino
4
+ module Executors
5
+ class Mock
6
+ attr_reader :calls
7
+ attr_accessor :exit_code
8
+
9
+ def initialize
10
+ reset
11
+ end
12
+
13
+ def execute(command_line, opts = {})
14
+ @calls << { command_line:, opts:, exit_code: @exit_code }
15
+
16
+ return if @exit_code.zero?
17
+
18
+ raise Lino::Errors::ExecutionError.new(
19
+ command_line.string, @exit_code
20
+ )
21
+ end
22
+
23
+ def reset
24
+ @calls = []
25
+ @exit_code = 0
26
+ end
27
+ end
28
+ end
29
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative 'executors/open4'
4
4
  require_relative 'executors/childprocess'
5
+ require_relative 'executors/mock'
5
6
 
6
7
  module Lino
7
8
  module Executors
@@ -85,7 +85,7 @@ module Lino
85
85
  options: opts.fetch(:options, []),
86
86
  arguments: opts.fetch(:arguments, []),
87
87
  environment_variables: opts.fetch(:environment_variables, []),
88
- executor: opts.fetch(:executor, Executors::Childprocess.new),
88
+ executor: opts.fetch(:executor, Lino.configuration.executor),
89
89
  working_directory: opts.fetch(:working_directory, nil)
90
90
  }
91
91
  end
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.6'
4
+ VERSION = '3.2.0.pre.7'
5
5
  end
data/lib/lino.rb CHANGED
@@ -7,6 +7,30 @@ require 'lino/executors'
7
7
  require 'lino/errors'
8
8
 
9
9
  module Lino
10
+ class << self
11
+ attr_writer :configuration
12
+
13
+ def configuration
14
+ @configuration ||= Configuration.new
15
+ end
16
+
17
+ def configure
18
+ yield(configuration)
19
+ end
20
+
21
+ def reset!
22
+ @configuration = nil
23
+ end
24
+ end
25
+
26
+ class Configuration
27
+ attr_accessor :executor
28
+
29
+ def initialize
30
+ @executor = Executors::Childprocess.new
31
+ end
32
+ end
33
+
10
34
  class CommandLineBuilder
11
35
  class << self
12
36
  def for_command(command)
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.6
4
+ version: 3.2.0.pre.7
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-07 00:00:00.000000000 Z
11
+ date: 2024-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: childprocess
@@ -310,6 +310,7 @@ files:
310
310
  - lib/lino/errors/execution_error.rb
311
311
  - lib/lino/executors.rb
312
312
  - lib/lino/executors/childprocess.rb
313
+ - lib/lino/executors/mock.rb
313
314
  - lib/lino/executors/open4.rb
314
315
  - lib/lino/model.rb
315
316
  - lib/lino/model/argument.rb