servo 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,9 +1,26 @@
1
1
  Servo
2
2
  =
3
3
 
4
- It's easy.
4
+ Servo serves your static filesystem via the web. Fun for testing simple static websites or generally being a weirdo.
5
+
6
+ It's easy:
5
7
 
6
8
  1. `gem install servo`
7
9
  2. `servo ~/Path/to/directory` or just `servo` for current directory
8
10
  3. Open [http://localhost:9292/](http://localhost:9292/)
9
11
  4. Profit
12
+
13
+ Usage
14
+ ==
15
+
16
+ Basics: `servo [options] [directory]`
17
+
18
+ Directory is optional and defaults to the current working directory.
19
+
20
+ Options are:
21
+
22
+ - `-p PORT, --port PORT` will serve on `PORT` supplied. So `servo -p 3001` will serve the current directory at `http://localhost:3001`
23
+
24
+ Oh look, it's just one option. Yeah, it's a simple little app.
25
+
26
+ Copyright © 2012 Flip Sasser, dont' sue me if it breaks something.
data/Version CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.1
data/bin/servo CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'rubygems'
3
- require 'rack'
4
3
  require 'optparse'
4
+ require File.expand_path('../lib/servo', File.dirname(__FILE__))
5
5
 
6
6
  options = {:port => 9292}
7
7
 
@@ -14,12 +14,5 @@ OptionParser.new do |opts|
14
14
  end.parse!
15
15
 
16
16
  dir = ARGV.first && File.expand_path(ARGV.first) || Dir.pwd
17
-
18
- servo_app = Rack::Builder.new {
19
- run Rack::Directory.new(dir)
20
- }
21
-
22
- server = Rack::Server.new(:Port => options[:port])
23
- server.options[:config] = nil
24
- server.instance_variable_set('@app', servo_app)
17
+ server = Rack::Server.new(:app => Servo.serve(dir), :Port => options[:port])
25
18
  server.start
data/lib/servo.rb ADDED
@@ -0,0 +1,16 @@
1
+ $LOAD_PATH.push File.dirname(__FILE__)
2
+
3
+ require 'rubygems'
4
+ require 'rack'
5
+ require 'servo/directory_index'
6
+
7
+ module Servo
8
+ class << self
9
+ def serve(dir)
10
+ Rack::Builder.new {
11
+ use Servo::DirectoryIndex, dir
12
+ run Rack::Directory.new(dir)
13
+ }
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ # Thanks to David Stamm (https://github.com/whylom) for this
2
+ # middleware that serves an index file if it's exists
3
+ module Servo
4
+ class DirectoryIndex
5
+ def initialize(app, dir)
6
+ @app = app
7
+ @dir = dir
8
+ end
9
+
10
+ def call(env)
11
+ index_path = ::File.join(@dir, Rack::Request.new(env).path.split('/'), 'index.html')
12
+ if ::File.exists?(index_path)
13
+ return [200, {"Content-Type" => "text/html"}, [::File.read(index_path)]]
14
+ else
15
+ @app.call(env)
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+
data/servo.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "servo"
8
- s.version = "0.0.3"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Flip Sasser"]
12
- s.date = "2012-04-26"
12
+ s.date = "2013-01-15"
13
13
  s.description = "\n Servo makes it dead simple to serve up a static filesystem using Rack::Directory.\n "
14
14
  s.email = "flip@x451.com"
15
15
  s.executables = ["servo"]
@@ -24,18 +24,30 @@ Gem::Specification.new do |s|
24
24
  ]
25
25
  s.homepage = "http://github.com/flipsasser/servo"
26
26
  s.require_paths = ["lib"]
27
- s.rubygems_version = "1.8.10"
27
+ s.rubygems_version = "1.8.24"
28
28
  s.summary = "A command-line static file server"
29
29
 
30
30
  if s.respond_to? :specification_version then
31
31
  s.specification_version = 3
32
32
 
33
33
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
34
+ s.add_runtime_dependency(%q<rack>, [">= 0"])
35
+ s.add_development_dependency(%q<capybara>, [">= 0"])
36
+ s.add_development_dependency(%q<rspec>, [">= 0"])
37
+ s.add_development_dependency(%q<rack-test>, [">= 0"])
34
38
  s.add_runtime_dependency(%q<rack>, [">= 1.2.1"])
35
39
  else
40
+ s.add_dependency(%q<rack>, [">= 0"])
41
+ s.add_dependency(%q<capybara>, [">= 0"])
42
+ s.add_dependency(%q<rspec>, [">= 0"])
43
+ s.add_dependency(%q<rack-test>, [">= 0"])
36
44
  s.add_dependency(%q<rack>, [">= 1.2.1"])
37
45
  end
38
46
  else
47
+ s.add_dependency(%q<rack>, [">= 0"])
48
+ s.add_dependency(%q<capybara>, [">= 0"])
49
+ s.add_dependency(%q<rspec>, [">= 0"])
50
+ s.add_dependency(%q<rack-test>, [">= 0"])
39
51
  s.add_dependency(%q<rack>, [">= 1.2.1"])
40
52
  end
41
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,75 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-27 00:00:00.000000000 Z
12
+ date: 2013-01-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
16
- requirement: &70355965219560 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: capybara
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rack-test
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rack
80
+ requirement: !ruby/object:Gem::Requirement
17
81
  none: false
18
82
  requirements:
19
83
  - - ! '>='
@@ -21,7 +85,12 @@ dependencies:
21
85
  version: 1.2.1
22
86
  type: :runtime
23
87
  prerelease: false
24
- version_requirements: *70355965219560
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: 1.2.1
25
94
  description: ! "\n Servo makes it dead simple to serve up a static filesystem using
26
95
  Rack::Directory.\n "
27
96
  email: flip@x451.com
@@ -34,6 +103,8 @@ files:
34
103
  - README.md
35
104
  - Version
36
105
  - bin/servo
106
+ - lib/servo.rb
107
+ - lib/servo/directory_index.rb
37
108
  - servo.gemspec
38
109
  homepage: http://github.com/flipsasser/servo
39
110
  licenses: []
@@ -55,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
126
  version: '0'
56
127
  requirements: []
57
128
  rubyforge_project:
58
- rubygems_version: 1.8.15
129
+ rubygems_version: 1.8.24
59
130
  signing_key:
60
131
  specification_version: 3
61
132
  summary: A command-line static file server