erik_server 0.0.2 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +17 -0
- data/LICENSE.txt +22 -0
- data/Rakefile +2 -0
- data/bin/server +29 -0
- data/lib/server/version.rb +3 -0
- data/lib/server.rb +5 -0
- data/server.gemspec +23 -0
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ac49060e35e4b763a67b8aec6576428929fa7bf
|
4
|
+
data.tar.gz: 8f278ef41b1616cd2d332d91ecdf7f4cca09fe0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c080beeabdadff240b04c362afebf481ffda6a6f4d8226b0e9aafea219801b98e2fecc8a26b0c5875d2e251472e54b5041dd6e4ce959b19a9031f204a1a4f546
|
7
|
+
data.tar.gz: 22367289391eca4e036a818085bb5c403573043138111b8276063e2859bbeccc123d48ba975863f2e62ca60f80d3909a9ae7041bb4e9a512415d3ce3906b93d3
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Erik Nilsen
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/bin/server
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'socket'
|
4
|
+
|
5
|
+
server = TCPServer.new 1337
|
6
|
+
|
7
|
+
loop do
|
8
|
+
client = server.accept
|
9
|
+
request = clients.gets
|
10
|
+
verb, path,protocol = request.spilt(" ")
|
11
|
+
path ="." + path
|
12
|
+
|
13
|
+
if File.file?(path)
|
14
|
+
body = File.open(path, "r"){|file| file.read}
|
15
|
+
status = "200 OK"
|
16
|
+
else
|
17
|
+
body = "File not found\n"
|
18
|
+
status = "404 Not Found"
|
19
|
+
end
|
20
|
+
|
21
|
+
response = "#{protocol} #{status}\n"
|
22
|
+
response += "Content-Type: text/html\n"
|
23
|
+
response += "Content-Length: #{body.length}\n"
|
24
|
+
response += "Connection: close\n\n"
|
25
|
+
response += body
|
26
|
+
|
27
|
+
client.puts response
|
28
|
+
client.close
|
29
|
+
end
|
data/lib/server.rb
ADDED
data/server.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'server/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "erik_server"
|
8
|
+
spec.version = Server::VERSION
|
9
|
+
spec.authors = ["Erik Nilsen"]
|
10
|
+
spec.email = ["enilsen16@live.com"]
|
11
|
+
spec.summary = %q{A simple server}
|
12
|
+
spec.description = %q{A simple server made with ruby}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erik_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Nilsen
|
@@ -41,11 +41,21 @@ dependencies:
|
|
41
41
|
description: A simple server made with ruby
|
42
42
|
email:
|
43
43
|
- enilsen16@live.com
|
44
|
-
executables:
|
44
|
+
executables:
|
45
|
+
- server
|
45
46
|
extensions: []
|
46
47
|
extra_rdoc_files: []
|
47
48
|
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- Gemfile.lock
|
52
|
+
- LICENSE.txt
|
48
53
|
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- bin/server
|
56
|
+
- lib/server.rb
|
57
|
+
- lib/server/version.rb
|
58
|
+
- server.gemspec
|
49
59
|
homepage: ''
|
50
60
|
licenses:
|
51
61
|
- MIT
|