http_server_manager 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,6 @@
1
1
  require 'rake/tasklib' unless defined? (::Rake::TaskLib)
2
2
 
3
3
  module HttpServerManager
4
-
5
4
  module Rake
6
5
 
7
6
  class ServerTasks < ::Rake::TaskLib
@@ -31,5 +30,4 @@ module HttpServerManager
31
30
  end
32
31
 
33
32
  end
34
-
35
33
  end
@@ -2,23 +2,24 @@ module HttpServerManager
2
2
 
3
3
  class Server
4
4
 
5
- attr_reader :name, :port
5
+ attr_reader :name, :host, :port
6
6
 
7
7
  def initialize(options)
8
8
  @name = options[:name]
9
+ @host = options[:host]
9
10
  @port = options[:port]
10
11
  @deletable_artifacts = [pid_file_path]
11
12
  end
12
13
 
13
14
  def start!
14
15
  if running?
15
- logger.info "#{@name} already running on port #{@port}"
16
+ logger.info "#{@name} already running on #{@host}:#{@port}"
16
17
  else
17
18
  ensure_directories_exist
18
19
  pid = Process.spawn(start_command, { [:out, :err] => [log_file_path, "w"] })
19
20
  create_pid_file(pid)
20
21
  Wait.until_true!("#{@name} is running") { running? }
21
- logger.info "#{@name} started on port #{@port}"
22
+ logger.info "#{@name} started on #{@host}:#{@port}"
22
23
  end
23
24
  end
24
25
 
@@ -42,7 +43,7 @@ module HttpServerManager
42
43
  end
43
44
 
44
45
  def to_s
45
- "#{@name} on port #{@port}"
46
+ "#{@name} on #{@host}:#{@port}"
46
47
  end
47
48
 
48
49
  def logger
@@ -52,7 +53,7 @@ module HttpServerManager
52
53
  private
53
54
 
54
55
  def running?
55
- !!Net::HTTP.get_response("localhost", "/", @port) rescue false
56
+ !!Net::HTTP.get_response(@host, "/", @port) rescue false
56
57
  end
57
58
 
58
59
  def current_pid
@@ -1,3 +1,3 @@
1
1
  module HttpServerManager
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  describe HttpServerManager::Server, "managing a real server" do
2
2
  include_context "managed http server integration utilities"
3
3
 
4
- let(:server) { RackServer.new(port: 4001) }
4
+ let(:server) { RackServer.new(host: "localhost", port: 4001) }
5
5
 
6
6
  describe "#start!" do
7
7
 
@@ -32,7 +32,7 @@ describe HttpServerManager::Server, "managing a real server" do
32
32
  end
33
33
 
34
34
  it "should log that the server started on the configured port" do
35
- logger.should_receive(:info).with(/started on port 4001/)
35
+ logger.should_receive(:info).with(/started on localhost:4001/)
36
36
 
37
37
  server.start!
38
38
  end
@@ -47,7 +47,7 @@ describe HttpServerManager::Server, "managing a real server" do
47
47
  end
48
48
 
49
49
  it "should log that the server is already running on the configured port" do
50
- logger.should_receive(:info).with(/already running on port 4001/)
50
+ logger.should_receive(:info).with(/already running on localhost:4001/)
51
51
 
52
52
  server.start!
53
53
  end
@@ -160,6 +160,10 @@ describe HttpServerManager::Server, "managing a real server" do
160
160
  server.to_s.should match(/rack_server/)
161
161
  end
162
162
 
163
+ it "should return a string containing the servers host" do
164
+ server.to_s.should match(/localhost/)
165
+ end
166
+
163
167
  it "should return a string containing the servers port" do
164
168
  server.to_s.should match(/4001/)
165
169
  end
@@ -8,7 +8,7 @@ describe HttpServerManager::Server do
8
8
 
9
9
  end
10
10
 
11
- let(:server) { HttpServerManager::TestableServer.new(name: "Test Server", port: 8888) }
11
+ let(:server) { HttpServerManager::TestableServer.new(name: "Test Server", host: "localhost", port: 8888) }
12
12
 
13
13
  before(:each) do
14
14
  server.stub(:start!)
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'simplecov'
2
2
  SimpleCov.start do
3
3
  add_filter "/spec/"
4
+ add_filter "/vendor/"
4
5
  minimum_coverage 100
5
6
  refuse_coverage_drop
6
7
  end if ENV["coverage"]
@@ -1,5 +1,4 @@
1
1
  module HttpServerManager
2
-
3
2
  module Test
4
3
 
5
4
  module ServerIntegrationUtilities
@@ -35,7 +34,7 @@ module HttpServerManager
35
34
 
36
35
  def wait_until_started!
37
36
  ::Wait.until_true!("#{server.name} starts") do
38
- !!Net::HTTP.get_response("localhost", "/", server.port) && pid_file_exists?
37
+ !!Net::HTTP.get_response(server.host, "/", server.port) && pid_file_exists?
39
38
  end
40
39
  FileUtils.cp(pid_file_path, pid_file_backup_path)
41
40
  end
@@ -43,7 +42,7 @@ module HttpServerManager
43
42
  def wait_until_stopped!
44
43
  ::Wait.until_true!("#{server.name} stops") do
45
44
  begin
46
- Net::HTTP.get_response("localhost", "/", server.port)
45
+ Net::HTTP.get_response(server.host, "/", server.port)
47
46
  false
48
47
  rescue
49
48
  !pid_file_exists?
@@ -95,5 +94,4 @@ module HttpServerManager
95
94
  end
96
95
 
97
96
  end
98
-
99
97
  end
@@ -1,5 +1,4 @@
1
1
  module HttpServerManager
2
-
3
2
  module Test
4
3
 
5
4
  class SilentLogger
@@ -11,5 +10,4 @@ module HttpServerManager
11
10
  end
12
11
 
13
12
  end
14
-
15
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_server_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-15 00:00:00.000000000 Z
12
+ date: 2013-10-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 10.1.0
21
+ version: '10.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 10.1.0
29
+ version: '10.1'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: sys-proctree
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -60,13 +60,13 @@ dependencies:
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.0.1
62
62
  - !ruby/object:Gem::Dependency
63
- name: rspec
63
+ name: metric_fu
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: '2.14'
69
+ version: '4.4'
70
70
  type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,15 +74,15 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: '2.14'
77
+ version: '4.4'
78
78
  - !ruby/object:Gem::Dependency
79
- name: simplecov
79
+ name: rspec
80
80
  requirement: !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
83
83
  - - ~>
84
84
  - !ruby/object:Gem::Version
85
- version: 0.7.1
85
+ version: '2.14'
86
86
  type: :development
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,15 +90,15 @@ dependencies:
90
90
  requirements:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
- version: 0.7.1
93
+ version: '2.14'
94
94
  - !ruby/object:Gem::Dependency
95
- name: flog
95
+ name: simplecov
96
96
  requirement: !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
99
99
  - - ~>
100
100
  - !ruby/object:Gem::Version
101
- version: 4.1.1
101
+ version: '0.7'
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
@@ -106,7 +106,7 @@ dependencies:
106
106
  requirements:
107
107
  - - ~>
108
108
  - !ruby/object:Gem::Version
109
- version: 4.1.1
109
+ version: '0.7'
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: travis-lint
112
112
  requirement: !ruby/object:Gem::Requirement
@@ -114,7 +114,7 @@ dependencies:
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: 1.7.0
117
+ version: '1.7'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -122,7 +122,7 @@ dependencies:
122
122
  requirements:
123
123
  - - ~>
124
124
  - !ruby/object:Gem::Version
125
- version: 1.7.0
125
+ version: '1.7'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: rack
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +130,7 @@ dependencies:
130
130
  requirements:
131
131
  - - ~>
132
132
  - !ruby/object:Gem::Version
133
- version: 1.5.2
133
+ version: '1.5'
134
134
  type: :development
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
@@ -138,7 +138,7 @@ dependencies:
138
138
  requirements:
139
139
  - - ~>
140
140
  - !ruby/object:Gem::Version
141
- version: 1.5.2
141
+ version: '1.5'
142
142
  description: Manages the lifecycle of HTTP server processes
143
143
  email: matthew.ueckerman@myob.com
144
144
  executables: []