nonnative 1.3.0 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f258779774baf11f2ae65c66b397f4f4fa0e1afd10972db59149080a3534616
4
- data.tar.gz: ecd62fbcf9051813acda6b21dff301b4985d3ecb6ad3ef89cb3b810e917b297d
3
+ metadata.gz: 515bd5110a2fb8db379637fc056a89daf97eaf02129c373fd69a44ff15f84a99
4
+ data.tar.gz: 652310aff1902f23ef506320d9fe82238653244ef81d68a01ae3c313fd5bdb84
5
5
  SHA512:
6
- metadata.gz: 328717fae77a845b8009bdf265b072504b4ad0ec644fb29f5f6884460d8aff892f1f46b73b869010ceae536d3a590a778977a3e65cd86c5f2cc4a0f15fb5e670
7
- data.tar.gz: 0dd2f19cf8773c08fe93cf911298e8441ae1465e4289eb2449a44887f8f1a594e50b31ffadb343fd0ebf6e67b0d9f16e29f0faa75406fa7c09e8c82d37fcc643
6
+ metadata.gz: f66e4a4ac3d018fc69b093807136bccc2d430b97da0165fad8ccbe9439f2cbb81cef26885130a11e46c4128190ba845fd7f39f9945999f32e40d98ce8d65d7fe
7
+ data.tar.gz: a2bd28a16bd590bac8f33a75543619505f8dccf8c4ee87c7147167b89bb095a5d0647513fbfabbe1118d35e8b0cf8a4ad014026aa9df512cd8c6b5970b9f2de6
@@ -5,6 +5,9 @@ AllCops:
5
5
  Layout/LineLength:
6
6
  Max: 120
7
7
 
8
+ Metrics/MethodLength:
9
+ Max: 15
10
+
8
11
  Style/Documentation:
9
12
  Enabled: false
10
13
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nonnative (1.3.0)
4
+ nonnative (1.4.0)
5
5
  cucumber
6
6
  rspec-expectations
7
7
  semantic_logger
@@ -12,7 +12,7 @@ require 'nonnative/port'
12
12
  require 'nonnative/configuration'
13
13
  require 'nonnative/configuration_process'
14
14
  require 'nonnative/configuration_server'
15
- require 'nonnative/system'
15
+ require 'nonnative/command'
16
16
  require 'nonnative/pool'
17
17
  require 'nonnative/server'
18
18
  require 'nonnative/logger'
@@ -40,16 +40,16 @@ module Nonnative
40
40
  def start
41
41
  @pool ||= Nonnative::Pool.new(configuration)
42
42
 
43
- @pool.start do |id, result|
44
- logger.error('Process has started though did respond in time', id: id) unless result
43
+ @pool.start do |name, id, result|
44
+ logger.error('Started though did respond in time', id: id, name: name) unless result
45
45
  end
46
46
  end
47
47
 
48
48
  def stop
49
49
  return if @pool.nil?
50
50
 
51
- @pool.stop do |id, result|
52
- logger.error('Process has stopped though did respond in time', id: id) unless result
51
+ @pool.stop do |name, id, result|
52
+ logger.error('Stopped though did respond in time', id: id, name: name) unless result
53
53
  end
54
54
  end
55
55
 
@@ -1,12 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nonnative
4
- class System
4
+ class Command
5
5
  def initialize(process)
6
6
  @process = process
7
7
  @started = false
8
8
  end
9
9
 
10
+ def name
11
+ process.command
12
+ end
13
+
10
14
  def start
11
15
  unless started
12
16
  @pid = spawn(process.command, %i[out err] => [process.file, 'a'])
@@ -22,7 +22,7 @@ module Nonnative
22
22
 
23
23
  def processes
24
24
  @processes ||= configuration.processes.map do |d|
25
- [Nonnative::System.new(d), Nonnative::Port.new(d)]
25
+ [Nonnative::Command.new(d), Nonnative::Port.new(d)]
26
26
  end
27
27
  end
28
28
 
@@ -32,25 +32,27 @@ module Nonnative
32
32
  end
33
33
  end
34
34
 
35
- def process_all(all, pr_method, po_method, &block)
36
- prs = []
37
- ths = []
35
+ def process_all(all, type_method, port_method, &block)
36
+ types = []
37
+ pids = []
38
+ threads = []
38
39
 
39
- all.each do |pr, po|
40
- prs << pr.send(pr_method)
41
- ths << Thread.new { po.send(po_method) }
40
+ all.each do |type, port|
41
+ types << type
42
+ pids << type.send(type_method)
43
+ threads << Thread.new { port.send(port_method) }
42
44
  end
43
45
 
44
- ThreadsWait.all_waits(*ths)
46
+ ThreadsWait.all_waits(*threads)
45
47
 
46
- pos = ths.map(&:value)
48
+ ports = threads.map(&:value)
47
49
 
48
- yield_results(prs, pos, &block)
50
+ yield_results(types, pids, ports, &block)
49
51
  end
50
52
 
51
- def yield_results(prs, pos)
52
- prs.zip(pos).each do |id, result|
53
- yield id, result
53
+ def yield_results(all, pids, ports)
54
+ all.zip(pids, ports).each do |type, id, result|
55
+ yield type.name, id, result
54
56
  end
55
57
  end
56
58
  end
@@ -11,6 +11,10 @@ module Nonnative
11
11
  end
12
12
  end
13
13
 
14
+ def name
15
+ self.class.to_s
16
+ end
17
+
14
18
  def start
15
19
  object_id
16
20
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nonnative
4
- VERSION = '1.3.0'
4
+ VERSION = '1.4.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nonnative
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Falkowski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-02 00:00:00.000000000 Z
11
+ date: 2020-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -158,6 +158,7 @@ files:
158
158
  - bin/setup
159
159
  - lib/nonnative.rb
160
160
  - lib/nonnative/before.rb
161
+ - lib/nonnative/command.rb
161
162
  - lib/nonnative/configuration.rb
162
163
  - lib/nonnative/configuration_process.rb
163
164
  - lib/nonnative/configuration_server.rb
@@ -168,7 +169,6 @@ files:
168
169
  - lib/nonnative/port.rb
169
170
  - lib/nonnative/server.rb
170
171
  - lib/nonnative/startup.rb
171
- - lib/nonnative/system.rb
172
172
  - lib/nonnative/timeout.rb
173
173
  - lib/nonnative/version.rb
174
174
  - nonnative.gemspec