http-double 0.1.2 → 0.1.3

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: 49dbfe366330961123afa18c4dfd54b4577bb01a
4
- data.tar.gz: ecc7902329f4ed52d782e6b313476d0b4dbd5d7b
3
+ metadata.gz: cb89445f8247604e9ecec1820a8745079d0a566c
4
+ data.tar.gz: 79f37dd1e89778680590e15234f18e8c0e87707e
5
5
  SHA512:
6
- metadata.gz: ea3b5f77d465743946754159bfc6409239daee58869e87ab2dd31a387cf51dec1a4d22114321e78c32f8616a9143168ed9f601a31fa20ad4f54e4905ad530ba3
7
- data.tar.gz: 016a6b3629465f0b33908115e4cae40c175871436295eb8845fdbfc7eed04740969b6a9ed2b86b7c46fcb836469aa406458d1d193d66af22bf374c873409138d
6
+ metadata.gz: 0ed4d5c31b4cd7befba7fedda9914208b6018528d8d8e4e3264db6602656b5c324946a1a3eb6bf8f4246eb571b5532435ee80686c2592bc2ff679a5052c799a0
7
+ data.tar.gz: 5c6d2b77584c6a93f4f35c1710dc33068e03ede57b097b11069293f1e0d9598efefe4dead04dad3900e86dbae4191fb41841c4a6a55f84f0e3eace93e9f01742
data/lib/http-double.rb CHANGED
@@ -5,7 +5,7 @@ require 'forwardable'
5
5
  module HttpDouble
6
6
  class << self
7
7
  extend Forwardable
8
- delegate [:background, :log] => :Base
8
+ delegate %i[background foreground log] => :Base
9
9
  end
10
10
  end
11
11
 
@@ -1,25 +1,29 @@
1
1
  require 'sinatra/base'
2
+ require 'sinatra/namespace'
2
3
 
3
4
  module HttpDouble
4
5
  class Base < Sinatra::Base
6
+ register Sinatra::Namespace
5
7
 
6
8
  class << self
7
9
 
8
- def background(addr, port, log_path: '/dev/null', logger: nil)
10
+ def foreground(addr, port, log_path: '/dev/null', logger: nil)
9
11
  server_class = self
10
- thread = Thread.new do
11
12
 
12
- # Even if we use /dev/null, we need a logger to suppress warnings
13
- # generated by Thin::Logging#trace_logger being undefined
14
- log_stream = File.open(log_path, 'a')
15
- Thin::Logging.trace_logger = logger || Logger.new(log_stream)
16
-
17
- Thin::Server.start(addr, port) do
18
- use RequestLogger, server_class.log
19
- run server_class
20
- end
13
+ # Even if we use /dev/null, we need a logger to suppress warnings
14
+ # generated by Thin::Logging#trace_logger being undefined
15
+ log_stream = File.open(log_path, 'a')
16
+ Thin::Logging.trace_logger = logger || Logger.new(log_stream)
21
17
 
18
+ Thin::Server.start(addr, port) do
19
+ use RequestLogger, server_class.log
20
+ run server_class
22
21
  end
22
+
23
+ end
24
+
25
+ def background(*args)
26
+ thread = Thread.new{ foreground *args }
23
27
  thread.abort_on_exception = true
24
28
  thread
25
29
  end
@@ -1,3 +1,3 @@
1
1
  module HttpDouble
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http-double
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil E. Pearson
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sinatra-contrib
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.4'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rack
29
43
  requirement: !ruby/object:Gem::Requirement