bbq-spawn 0.0.3 → 0.0.4

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
  SHA1:
3
- metadata.gz: 1a8f9fac05331610bc6102d7fa7d217da2eb4678
4
- data.tar.gz: 5a064347a18bfff381c1bf3f54ee028b35ececc4
3
+ metadata.gz: e4f5ae7e33b564356d09ab25299a44229cc0683a
4
+ data.tar.gz: b989fe07377ea98cbe2186f24359fd29a375aca7
5
5
  SHA512:
6
- metadata.gz: 4a5f758fe1dc8493ab42eef3cda068e329d2dcda26001b8b5873539c049d5ccbc8885626157617976c2800da371cd9372a7f647a39a10f671192ba467a9eecd7
7
- data.tar.gz: be65348d806a6323a606005bf87c4f23fa11d37bb3be72b7134826b693febe57ac6641641edf424b356316c5eee213262ab7102d074536da600a614d71bcbe13
6
+ metadata.gz: 8a08a057d2a2aa186aa7605f2c0d1fd388ecb9003726c1924c1d64e1a564ea50fd0e674ae424b0db0e496de74400b79c031c92e95f0254ef420dad78d3c7baba
7
+ data.tar.gz: c0300a7274ec23f7414a77f58ad19173ab389b73ceacb7d70486fe903cde3875bbae91378551abace14b38985ea049c4255de40273ff6a8ee77a94f67869096f
@@ -0,0 +1,25 @@
1
+ module Bbq
2
+ module Spawn
3
+ module IOStrategy
4
+ class Squelch
5
+ def initialize(writer)
6
+ @writer = writer
7
+ end
8
+
9
+ def run(io)
10
+ io.stdout = io.stderr = @writer
11
+ end
12
+
13
+ def after_spawn
14
+ @writer.close
15
+ end
16
+ end
17
+
18
+ class Inherit
19
+ def run(io)
20
+ io.inherit!
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,8 +1,10 @@
1
1
  require "bbq/spawn/version"
2
+ require 'bbq/builtin_strategies'
2
3
  require "childprocess"
3
4
  require "forwardable"
4
5
  require "socket"
5
6
  require "timeout"
7
+ require "uri"
6
8
  require "net/http"
7
9
 
8
10
  module Bbq
@@ -10,9 +12,12 @@ module Bbq
10
12
  class Executor
11
13
  extend Forwardable
12
14
 
15
+ attr_accessor :io_strategy
16
+
13
17
  def_delegators :@process, :start, :stop, :io
14
18
 
15
19
  def initialize(*args)
20
+ @strategy = :mute
16
21
  @process = ChildProcess.build(*args)
17
22
  yield @process if block_given?
18
23
  @process
@@ -33,12 +38,14 @@ module Bbq
33
38
  @url = options[:url]
34
39
 
35
40
  @reader, @writer = IO.pipe
41
+
42
+ @strategy = options[:strategy] || IOStrategy::Squelch.new(@writer)
36
43
  end
37
44
 
38
45
  def start
39
- @executor.io.stdout = @executor.io.stderr = @writer
46
+ @strategy.run(@executor.io)
40
47
  @executor.start
41
- @writer.close
48
+ @strategy.after_run if @strategy.respond_to? :after_run
42
49
  end
43
50
 
44
51
  def join
@@ -47,15 +54,13 @@ module Bbq
47
54
  wait_for_socket if @port and @host
48
55
  wait_for_response if @url
49
56
  end
50
- rescue Timeout::Error
51
57
  end
52
58
 
53
59
  private
54
60
  def wait_for_io
55
61
  loop do
56
- case @reader.readpartial(8192)
57
- when @banner then break
58
- end
62
+ output = @reader.readpartial(8192)
63
+ break if output.include?(@banner)
59
64
  end
60
65
  rescue EOFError
61
66
  end
@@ -72,13 +77,14 @@ module Bbq
72
77
  end
73
78
 
74
79
  def wait_for_response
80
+ uri = URI.parse(@url)
75
81
  begin
76
- Net::HTTP.start(@url) do |http|
82
+ Net::HTTP.start(uri.host, uri.port) do |http|
77
83
  http.open_timeout = 5
78
84
  http.read_timeout = 5
79
- http.head('/')
85
+ http.head(uri.path)
80
86
  end
81
- rescue SocketError
87
+ rescue SocketError, IOError, Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError
82
88
  retry
83
89
  end
84
90
  end
@@ -1,5 +1,5 @@
1
1
  module Bbq
2
2
  module Spawn
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bbq-spawn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paweł Pacana
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-12 00:00:00.000000000 Z
11
+ date: 2017-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: childprocess
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: Spawn and coordinate background processes for black box testing.
@@ -59,12 +59,13 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - .gitignore
62
+ - ".gitignore"
63
63
  - Gemfile
64
64
  - LICENSE.txt
65
65
  - README.md
66
66
  - Rakefile
67
67
  - bbq-spawn.gemspec
68
+ - lib/bbq/builtin_strategies.rb
68
69
  - lib/bbq/spawn.rb
69
70
  - lib/bbq/spawn/version.rb
70
71
  homepage: ''
@@ -77,17 +78,17 @@ require_paths:
77
78
  - lib
78
79
  required_ruby_version: !ruby/object:Gem::Requirement
79
80
  requirements:
80
- - - '>='
81
+ - - ">="
81
82
  - !ruby/object:Gem::Version
82
83
  version: '0'
83
84
  required_rubygems_version: !ruby/object:Gem::Requirement
84
85
  requirements:
85
- - - '>='
86
+ - - ">="
86
87
  - !ruby/object:Gem::Version
87
88
  version: '0'
88
89
  requirements: []
89
90
  rubyforge_project:
90
- rubygems_version: 2.0.3
91
+ rubygems_version: 2.6.12
91
92
  signing_key:
92
93
  specification_version: 4
93
94
  summary: Spawn and coordinate background processes for black box testing.