smallvictories 0.0.16 → 0.0.17

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: 12382dc9fd1f3d1688534c4a2df59eaaa1eab52b
4
- data.tar.gz: 0da0a7dc2013e224a60376cd9f54303e315b1372
3
+ metadata.gz: a012abc5e4e26ee5e48bf0577689ace065e6de1e
4
+ data.tar.gz: 0f68a60487282ac4c6c9a11be0c017ef3549149b
5
5
  SHA512:
6
- metadata.gz: 4e8ef9f37f4da27baff4b8f5fb3ffa625a6256d557dc9c96b196729ebfb59437af11e5c5f9cb39ef074ddcc65e9362afffb2941a8726be0508cfbe7bc36ab7ea
7
- data.tar.gz: a6ad93cdae7983dfd6eb9b066c335dfa13b6325e8faae02b453d2854c72f0b5a36a4a1697299424d9f0dade517dcce78d9b998ec6c66ce376c5adf073bef669b
6
+ metadata.gz: 5590c7692d2bc9ac0975fa412eabf7283faf01cf990d05e52ae28ecacb2e5e8635151a64bc35ef93ed8e03c40c3b491988dd58a3b397b557693dd841cb22c320
7
+ data.tar.gz: 1f546b231f4a53fe1804490d34087e7d564d51474508ab217c8dfc36f840f47ab7c5a12da3987a8c3a6409b2eec247d9aac2d85542a3e56fd66e79f17de9811b
@@ -115,37 +115,40 @@ module SmallVictories
115
115
  loop do
116
116
  @socket = @server.accept
117
117
  request_line = socket.gets
118
- socket.close if request_line == nil
119
118
 
120
119
  STDERR.puts request_line
121
120
 
122
- path = requested_file(request_line)
123
- path = File.join(path, 'index.html') if File.directory?(path)
124
-
125
- if path == File.join(WEB_ROOT, '_sv_custom.css')
126
- render_stylesheet
127
- elsif File.exist?(path) && !File.directory?(path)
128
- File.open(path, "rb") do |file|
129
- if File.extname(path) == '.html'
130
- # parse liquid
131
- template = Liquid::Template.parse(file.read, error_mode: :warn)
132
- render_string(template.render(SiteFile.files_hash))
133
- else
134
- render_file(file)
121
+ begin
122
+ path = requested_file(request_line)
123
+ path = File.join(path, 'index.html') if File.directory?(path)
124
+
125
+ if path == File.join(WEB_ROOT, '_sv_custom.css')
126
+ render_stylesheet
127
+ elsif File.exist?(path) && !File.directory?(path)
128
+ File.open(path, "rb") do |file|
129
+ if File.extname(path) == '.html'
130
+ # parse liquid
131
+ template = Liquid::Template.parse(file.read, error_mode: :warn)
132
+ render_string(template.render(SiteFile.files_hash))
133
+ else
134
+ render_file(file)
135
+ end
135
136
  end
136
- end
137
- else
138
- message = "File not found\n"
137
+ else
138
+ message = "File not found\n"
139
139
 
140
- # respond with a 404 error code to indicate the file does not exist
141
- socket.print "HTTP/1.1 404 Not Found\r\n" +
142
- "Content-Type: text/plain\r\n" +
143
- "Content-Length: #{message.size}\r\n" +
144
- "Connection: close\r\n"
140
+ # respond with a 404 error code to indicate the file does not exist
141
+ socket.print "HTTP/1.1 404 Not Found\r\n" +
142
+ "Content-Type: text/plain\r\n" +
143
+ "Content-Length: #{message.size}\r\n" +
144
+ "Connection: close\r\n"
145
145
 
146
- socket.print "\r\n"
146
+ socket.print "\r\n"
147
147
 
148
- socket.print message
148
+ socket.print message
149
+ end
150
+ rescue => e
151
+ socket.print "\r\n"
149
152
  end
150
153
 
151
154
  socket.close
@@ -1,3 +1,3 @@
1
1
  module SmallVictories
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.17"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smallvictories
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Dijkstra