serveall 0.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e8960d2d790a23bafd59020070000e01ac150def
4
+ data.tar.gz: 63949f46d919b34d5d61f8cb5584bd181305a3cb
5
+ SHA512:
6
+ metadata.gz: 6dca7828bd012b7592dc7918715e3a659164fbc2d90f64be1f5b4c3acad1c4823e434b2aadcbc93b209642d751ecf5d7157d7cdd615f1b4de76aaa779bf734b7
7
+ data.tar.gz: 589828ab84ebd00d8fcc59106a3fe8c242e7402b30898800f52b9536b458c8e83a5dfcffc39d3cdf2967a0e0c6cb6addaa8310e131673a7ad7adcbdd5083af1d
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in serveall.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 lbuell
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/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Serveall
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'serveall'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install serveall
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ end
7
+
8
+ desc "Run tests"
9
+ task :default => :test
10
+
@@ -0,0 +1,129 @@
1
+ <!doctype html>
2
+ <!--[if IE 9]><html class="lt-ie10" lang="en" > <![endif]-->
3
+ <html class="no-js" lang="en" data-useragent="Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)">
4
+ <head>
5
+ <meta charset="utf-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Foundation Template | Orbit Home</title>
8
+
9
+
10
+ <meta name="description" content="Documentation and reference library for ZURB Foundation. JavaScript, CSS, components, grid and more." />
11
+
12
+ <meta name="author" content="ZURB, inc. ZURB network also includes zurb.com" />
13
+ <meta name="copyright" content="ZURB, inc. Copyright (c) 2013" />
14
+
15
+ <link rel="stylesheet" href="../assets/css/templates/foundation.css" />
16
+ <script src="../assets/js/modernizr.js"></script>
17
+ </head>
18
+ <body>
19
+
20
+
21
+ <div class="row">
22
+ <div class="large-3 columns">
23
+ <h1><img src="http://placehold.it/400x100&text=Logo" /></h1>
24
+ </div>
25
+ <div class="large-9 columns">
26
+ <ul class="right button-group">
27
+ <li><a href="#" class="button">Link 1</a></li>
28
+ <li><a href="#" class="button">Link 2</a></li>
29
+ <li><a href="#" class="button">Link 3</a></li>
30
+ <li><a href="#" class="button">Link 4</a></li>
31
+ </ul>
32
+ </div>
33
+ </div>
34
+
35
+ <!-- End Header and Nav -->
36
+
37
+ <!-- First Band (Slider) -->
38
+
39
+
40
+ <div class="row">
41
+ <div class="large-12 columns">
42
+ <ul class="example-orbit" data-orbit>
43
+ <li><img src=
44
+ "http://placehold.it/1000x400&amp;text=[%20img%201%20]"></li>
45
+ <li><img src=
46
+ "http://placehold.it/1000x400&amp;text=[%20img%202%20]"></li>
47
+ <li><img src=
48
+ "http://placehold.it/1000x400&amp;text=[%20img%203%20]"></li>
49
+ </ul>
50
+ </div>
51
+ </div>
52
+
53
+ <hr/>
54
+
55
+
56
+ <!-- Three-up Content Blocks -->
57
+
58
+ <div class="row">
59
+ <div class="large-4 columns">
60
+ <img src="http://placehold.it/400x300&text=[img]" />
61
+ <h4>This is a content section.</h4>
62
+ <p>Bacon ipsum dolor sit amet nulla ham qui sint exercitation eiusmod commodo, chuck duis velit. Aute in reprehenderit, dolore aliqua non est magna in labore pig pork biltong. Eiusmod swine spare ribs reprehenderit culpa. Boudin aliqua adipisicing rump corned beef.</p>
63
+ </div>
64
+
65
+ <div class="large-4 columns">
66
+ <img src="http://placehold.it/400x300&text=[img]" />
67
+ <h4>This is a content section.</h4>
68
+ <p>Bacon ipsum dolor sit amet nulla ham qui sint exercitation eiusmod commodo, chuck duis velit. Aute in reprehenderit, dolore aliqua non est magna in labore pig pork biltong. Eiusmod swine spare ribs reprehenderit culpa. Boudin aliqua adipisicing rump corned beef.</p>
69
+ </div>
70
+
71
+ <div class="large-4 columns">
72
+ <img src="http://placehold.it/400x300&text=[img]" />
73
+ <h4>This is a content section.</h4>
74
+ <p>Bacon ipsum dolor sit amet nulla ham qui sint exercitation eiusmod commodo, chuck duis velit. Aute in reprehenderit, dolore aliqua non est magna in labore pig pork biltong. Eiusmod swine spare ribs reprehenderit culpa. Boudin aliqua adipisicing rump corned beef.</p>
75
+ </div>
76
+
77
+ </div>
78
+
79
+ <!-- Call to Action Panel -->
80
+ <div class="row">
81
+ <div class="large-12 columns">
82
+
83
+ <div class="panel">
84
+ <h4>Get in touch!</h4>
85
+
86
+ <div class="row">
87
+ <div class="large-9 columns">
88
+ <p>We'd love to hear from you, you attractive person you.</p>
89
+ </div>
90
+ <div class="large-3 columns">
91
+ <a href="#" class="radius button right">Contact Us</a>
92
+ </div>
93
+ </div>
94
+ </div>
95
+
96
+ </div>
97
+ </div>
98
+
99
+ <!-- Footer -->
100
+
101
+ <footer class="row">
102
+ <div class="large-12 columns">
103
+ <hr />
104
+ <div class="row">
105
+ <div class="large-6 columns">
106
+ <p>&copy; Copyright no one at all. Go to town.</p>
107
+ </div>
108
+ <div class="large-6 columns">
109
+ <ul class="inline-list right">
110
+ <li><a href="#">Link 1</a></li>
111
+ <li><a href="#">Link 2</a></li>
112
+ <li><a href="#">Link 3</a></li>
113
+ <li><a href="#">Link 4</a></li>
114
+ </ul>
115
+ </div>
116
+ </div>
117
+ </div>
118
+ </footer>
119
+
120
+ <script src="../assets/js/jquery.js"></script>
121
+ <script src="../assets/js/templates/foundation.js"></script>
122
+ <script>
123
+ $(document).foundation();
124
+
125
+ var doc = document.documentElement;
126
+ doc.setAttribute('data-useragent', navigator.userAgent);
127
+ </script>
128
+ </body>
129
+ </html>
@@ -0,0 +1,3 @@
1
+ module Serveall
2
+ VERSION = "0.0.1"
3
+ end
data/lib/serveall.rb ADDED
@@ -0,0 +1,98 @@
1
+ require "serveall/version"
2
+ require 'socket'
3
+ require 'uri'
4
+
5
+ # Files will be served from this directory
6
+ WEB_ROOT = './public'
7
+
8
+ # Map extensions to their content type
9
+ CONTENT_TYPE_MAPPING = {
10
+ 'html' => 'text/html',
11
+ 'txt' => 'text/plain',
12
+ 'png' => 'image/png',
13
+ 'jpg' => 'image/jpeg'
14
+ }
15
+
16
+ # Treat as binary data if content type cannot be found
17
+ DEFAULT_CONTENT_TYPE = 'application/octet-stream'
18
+
19
+ # This helper function parses the extension of the
20
+ # requested file and then looks up its content type.
21
+
22
+ def content_type(path)
23
+ ext = File.extname(path).split(".").last
24
+ CONTENT_TYPE_MAPPING.fetch(ext, DEFAULT_CONTENT_TYPE)
25
+ end
26
+
27
+ # This helper function parses the Request-Line and
28
+ # generates a path to a file on the server.
29
+ def requested_file(request_line)
30
+ request_uri = request_line.split(" ")[1]
31
+ path = URI.unescape(URI(request_uri).path)
32
+
33
+ clean = []
34
+
35
+ # Split the path into components
36
+ parts = path.split("/")
37
+
38
+ parts.each do |part|
39
+ # skip any empty or current directory (".") path components
40
+ next if part.empty? || part == '.'
41
+ # If the path component goes up one directory level (".."),
42
+ # remove the last clean component.
43
+ # Otherwise, add the component to the Array of clean components
44
+ part == '..' ? clean.pop : clean << part
45
+ end
46
+
47
+ # return the web root joined to the clean path
48
+ File.join(WEB_ROOT, *clean)
49
+ end
50
+
51
+ # Except where noted below, the general approach of
52
+ # handling requests and generating responses is
53
+ # similar to that of the "Hello World" example
54
+ # shown earlier.
55
+
56
+ server = TCPServer.new('localhost', 2345)
57
+
58
+ loop do
59
+ socket = server.accept
60
+ request_line = socket.gets
61
+
62
+ STDERR.puts request_line
63
+
64
+ path = requested_file(request_line)
65
+
66
+ path = File.join(path, 'index.html') if File.directory?(path)
67
+
68
+ # Make sure the file exists and is not a directory
69
+ # before attempting to open it.
70
+ if File.exist?(path) && !File.directory?(path)
71
+ File.open(path, "rb") do |file|
72
+ socket.print "HTTP/1.1 200 OK\r\n" +
73
+ "Content-Type: #{content_type(file)}\r\n" +
74
+ "Content-Length: #{file.size}\r\n" +
75
+ "Connection: close\r\n"
76
+
77
+ socket.print "\r\n"
78
+
79
+ # write the contents of the file to the socket
80
+ IO.copy_stream(file, socket)
81
+ end
82
+ else
83
+ message = "File not found\n"
84
+
85
+ # respond with a 404 error code to indicate the file does not exist
86
+ socket.print "HTTP/1.1 404 Not Found\r\n" +
87
+ "Content-Type: text/plain\r\n" +
88
+ "Content-Length: #{message.size}\r\n" +
89
+ "Connection: close\r\n"
90
+
91
+ socket.print "\r\n"
92
+
93
+ socket.print message
94
+ end
95
+
96
+ socket.close
97
+
98
+ end
data/public/index.html ADDED
@@ -0,0 +1,129 @@
1
+ <!doctype html>
2
+ <!--[if IE 9]><html class="lt-ie10" lang="en" > <![endif]-->
3
+ <html class="no-js" lang="en" data-useragent="Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)">
4
+ <head>
5
+ <meta charset="utf-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Foundation Template | Orbit Home</title>
8
+
9
+
10
+ <meta name="description" content="Documentation and reference library for ZURB Foundation. JavaScript, CSS, components, grid and more." />
11
+
12
+ <meta name="author" content="ZURB, inc. ZURB network also includes zurb.com" />
13
+ <meta name="copyright" content="ZURB, inc. Copyright (c) 2013" />
14
+
15
+ <link rel="stylesheet" href="../assets/css/templates/foundation.css" />
16
+ <script src="../assets/js/modernizr.js"></script>
17
+ </head>
18
+ <body>
19
+
20
+
21
+ <div class="row">
22
+ <div class="large-3 columns">
23
+ <h1><img src="http://placehold.it/400x100&text=Logo" /></h1>
24
+ </div>
25
+ <div class="large-9 columns">
26
+ <ul class="right button-group">
27
+ <li><a href="#" class="button">Link 1</a></li>
28
+ <li><a href="#" class="button">Link 2</a></li>
29
+ <li><a href="#" class="button">Link 3</a></li>
30
+ <li><a href="#" class="button">Link 4</a></li>
31
+ </ul>
32
+ </div>
33
+ </div>
34
+
35
+ <!-- End Header and Nav -->
36
+
37
+ <!-- First Band (Slider) -->
38
+
39
+
40
+ <div class="row">
41
+ <div class="large-12 columns">
42
+ <ul class="example-orbit" data-orbit>
43
+ <li><img src=
44
+ "http://placehold.it/1000x400&amp;text=[%20img%201%20]"></li>
45
+ <li><img src=
46
+ "http://placehold.it/1000x400&amp;text=[%20img%202%20]"></li>
47
+ <li><img src=
48
+ "http://placehold.it/1000x400&amp;text=[%20img%203%20]"></li>
49
+ </ul>
50
+ </div>
51
+ </div>
52
+
53
+ <hr/>
54
+
55
+
56
+ <!-- Three-up Content Blocks -->
57
+
58
+ <div class="row">
59
+ <div class="large-4 columns">
60
+ <img src="http://placehold.it/400x300&text=[img]" />
61
+ <h4>This is a content section.</h4>
62
+ <p>Bacon ipsum dolor sit amet nulla ham qui sint exercitation eiusmod commodo, chuck duis velit. Aute in reprehenderit, dolore aliqua non est magna in labore pig pork biltong. Eiusmod swine spare ribs reprehenderit culpa. Boudin aliqua adipisicing rump corned beef.</p>
63
+ </div>
64
+
65
+ <div class="large-4 columns">
66
+ <img src="http://placehold.it/400x300&text=[img]" />
67
+ <h4>This is a content section.</h4>
68
+ <p>Bacon ipsum dolor sit amet nulla ham qui sint exercitation eiusmod commodo, chuck duis velit. Aute in reprehenderit, dolore aliqua non est magna in labore pig pork biltong. Eiusmod swine spare ribs reprehenderit culpa. Boudin aliqua adipisicing rump corned beef.</p>
69
+ </div>
70
+
71
+ <div class="large-4 columns">
72
+ <img src="http://placehold.it/400x300&text=[img]" />
73
+ <h4>This is a content section.</h4>
74
+ <p>Bacon ipsum dolor sit amet nulla ham qui sint exercitation eiusmod commodo, chuck duis velit. Aute in reprehenderit, dolore aliqua non est magna in labore pig pork biltong. Eiusmod swine spare ribs reprehenderit culpa. Boudin aliqua adipisicing rump corned beef.</p>
75
+ </div>
76
+
77
+ </div>
78
+
79
+ <!-- Call to Action Panel -->
80
+ <div class="row">
81
+ <div class="large-12 columns">
82
+
83
+ <div class="panel">
84
+ <h4>Get in touch!</h4>
85
+
86
+ <div class="row">
87
+ <div class="large-9 columns">
88
+ <p>We'd love to hear from you, you attractive person you.</p>
89
+ </div>
90
+ <div class="large-3 columns">
91
+ <a href="#" class="radius button right">Contact Us</a>
92
+ </div>
93
+ </div>
94
+ </div>
95
+
96
+ </div>
97
+ </div>
98
+
99
+ <!-- Footer -->
100
+
101
+ <footer class="row">
102
+ <div class="large-12 columns">
103
+ <hr />
104
+ <div class="row">
105
+ <div class="large-6 columns">
106
+ <p>&copy; Copyright no one at all. Go to town.</p>
107
+ </div>
108
+ <div class="large-6 columns">
109
+ <ul class="inline-list right">
110
+ <li><a href="#">Link 1</a></li>
111
+ <li><a href="#">Link 2</a></li>
112
+ <li><a href="#">Link 3</a></li>
113
+ <li><a href="#">Link 4</a></li>
114
+ </ul>
115
+ </div>
116
+ </div>
117
+ </div>
118
+ </footer>
119
+
120
+ <script src="../assets/js/jquery.js"></script>
121
+ <script src="../assets/js/templates/foundation.js"></script>
122
+ <script>
123
+ $(document).foundation();
124
+
125
+ var doc = document.documentElement;
126
+ doc.setAttribute('data-useragent', navigator.userAgent);
127
+ </script>
128
+ </body>
129
+ </html>
data/serveall.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'serveall/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "serveall"
8
+ spec.version = Serveall::VERSION
9
+ spec.authors = ["lbuell"]
10
+ spec.email = ["liamcbuell@gmail.com"]
11
+ spec.description = %q{A Simple ruby web server}
12
+ spec.summary = %q{Serve all the things!}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_runtime_dependency "rack"
24
+ end
@@ -0,0 +1,19 @@
1
+ require 'test/unit'
2
+ require 'serveall'
3
+
4
+ class Serveall < Test::Unit::TestCase
5
+ def test_english_hello
6
+ assert_equal "hello world",
7
+ Serveall.hi("english")
8
+ end
9
+
10
+ def test_any_hello
11
+ assert_equal "hello world",
12
+ Serveall.hi("ruby")
13
+ end
14
+
15
+ def test_spanish_hello
16
+ assert_equal "hola mundo",
17
+ Servall.hi("spanish")
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: serveall
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - lbuell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rack
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: A Simple ruby web server
56
+ email:
57
+ - liamcbuell@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/public/index.html
68
+ - lib/serveall.rb
69
+ - lib/serveall/version.rb
70
+ - public/index.html
71
+ - serveall.gemspec
72
+ - test/test_serveall.rb
73
+ homepage: ''
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.1.11
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Serve all the things!
97
+ test_files:
98
+ - test/test_serveall.rb