street_lights 0.0.2 → 0.0.3

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/lib/street_lights.rb CHANGED
@@ -9,15 +9,25 @@ class StreetLights
9
9
  unless File.exists?(@street_lights_dir)
10
10
  FileUtils.mkdir_p(@street_lights_dir)
11
11
  end
12
- at_exit { File.rm "#{@street_lights_dir}/#{Process.pid}" }
12
+ shutdown_behaviour = proc do
13
+ FileUtils.rm(street_light) if File.exists?(street_light)
14
+ end
15
+ trap('QUIT', &shutdown_behaviour)
16
+ trap('TERM', &shutdown_behaviour)
17
+ trap('EXIT', &shutdown_behaviour)
18
+ trap('KILL', &shutdown_behaviour)
19
+ end
20
+
21
+ def street_light
22
+ @street_light ||= "#{@street_lights_dir}/#{Process.pid}"
13
23
  end
14
24
 
15
25
  def call(env)
16
- File.open("#{@street_lights_dir}/#{Process.pid}", 'w+') do |file|
26
+ File.open(street_light, 'w+') do |file|
17
27
  file.puts "#{Process.pid.to_s.to_ansi.red.to_s} #{env['HTTP_HOST']} #{env['REQUEST_PATH']}"
18
28
  end
19
29
  status, headers, response = @app.call(env)
20
- File.open("#{@street_lights_dir}/#{Process.pid}", 'w+') do |file|
30
+ File.open(street_light, 'w+') do |file|
21
31
  file.puts "#{Process.pid.to_s.to_ansi.green.to_s}"
22
32
  end
23
33
  [status, headers, response]
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{street_lights}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["kazuyoshi tlacaelel"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: street_lights
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - kazuyoshi tlacaelel