adsf 1.0.1 → 1.1.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.
- data/NEWS.md +22 -0
- data/README.md +52 -0
- data/Rakefile +1 -1
- data/bin/adsf +17 -4
- data/lib/adsf.rb +1 -1
- data/lib/adsf/rack/index_file_finder.rb +12 -4
- metadata +33 -52
- data/NEWS.rdoc +0 -9
- data/README.rdoc +0 -27
data/NEWS.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
adsf News
|
2
|
+
=========
|
3
|
+
|
4
|
+
1.1.1
|
5
|
+
-----
|
6
|
+
|
7
|
+
* Made SIGINT/SIGTERM cause proper exit
|
8
|
+
|
9
|
+
1.1.0
|
10
|
+
-----
|
11
|
+
|
12
|
+
* Added support for custom index filenames [Mark Meves]
|
13
|
+
|
14
|
+
1.0.1
|
15
|
+
-----
|
16
|
+
|
17
|
+
* Added runtime dependency on Rack
|
18
|
+
|
19
|
+
1.0
|
20
|
+
---
|
21
|
+
|
22
|
+
* Initial release
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
adsf
|
2
|
+
====
|
3
|
+
|
4
|
+
adsf (A Dead Simple Fileserver) is a tiny static file server that you can launch instantly in any directory, like this:
|
5
|
+
|
6
|
+
▸ ls -l
|
7
|
+
total 0
|
8
|
+
drwxr-xr-x 2 ddfreyne staff 68 May 29 10:04 about
|
9
|
+
drwxr-xr-x 2 ddfreyne staff 68 May 29 10:04 contact
|
10
|
+
-rw-r--r-- 1 ddfreyne staff 0 May 29 10:04 index.html
|
11
|
+
drwxr-xr-x 2 ddfreyne staff 68 May 29 10:04 projects
|
12
|
+
|
13
|
+
▸ adsf
|
14
|
+
2009-05-29 10:04:44] INFO WEBrick 1.3.1
|
15
|
+
[2009-05-29 10:04:44] INFO ruby 1.8.7 (2008-08-11) [i686-darwin9.6.1]
|
16
|
+
[2009-05-29 10:04:44] INFO WEBrick::HTTPServer#start: pid=2757 port=3000
|
17
|
+
|
18
|
+
… and now you can go to http://localhost:3000/ and start browsing.
|
19
|
+
|
20
|
+
You can specify a custom web root with `-r` or `--root`; the server will be started in that directory (e.g. `adsf -r public/`). If you want to specificy custom index filenames (other than the default `index.html`), you can use the `-i` or `--index-filename` option, which is a comma-separated list of filenames (e.g. `adsf -i index.html,index.xml`).
|
21
|
+
|
22
|
+
adsf has one dependency, namely on Rack. It is licenced under the MIT license. Patches are always welcome; check my contact e-mail address at the bottom of this document.
|
23
|
+
|
24
|
+
Using adsf programmatically
|
25
|
+
---------------------------
|
26
|
+
|
27
|
+
You can use adsf programmatically in your Rack applications. [nanoc](http://nanoc.stoneship.org/) uses adsf for its “view” command, for example. adsf consists of one middleware class that finds index filenames, and rewrites these requests so that Rack::File can be used to serve these files.
|
28
|
+
|
29
|
+
Here’s an example middleware/application stack that runs a web server with the "public/" directory as its web root:
|
30
|
+
|
31
|
+
use Adsf::Rack::IndexFileFinder, :root => "public/"
|
32
|
+
run Rack::File.new("public/")
|
33
|
+
|
34
|
+
The `:root` option is required; it should contain the path to the web root.
|
35
|
+
|
36
|
+
You can also specify an `:index_filenames` option, containing the names of the index filenames that will be served when a directory containing an index file is requested. Usually, this will simply be `[ 'index.html' ]`, but under different circumstances (when using IIS, for exmaple), the array may have to be modified to include index filenames such as `default.html` or `index.xml`. Here’s an example middleware/application stack that uses custom index filenames:
|
37
|
+
|
38
|
+
use Adsf::Rack::IndexFileFinder,
|
39
|
+
:root => "public/",
|
40
|
+
:index_filenames => %w( index.html index.xhtml index.xml )
|
41
|
+
run Rack::File.new("public/")
|
42
|
+
|
43
|
+
Authors
|
44
|
+
-------
|
45
|
+
|
46
|
+
* Denis Defreyne
|
47
|
+
* Mark Meves
|
48
|
+
|
49
|
+
Contact
|
50
|
+
-------
|
51
|
+
|
52
|
+
You can reach me at <denis.defreyne@stoneship.org>.
|
data/Rakefile
CHANGED
data/bin/adsf
CHANGED
@@ -8,9 +8,10 @@ require 'adsf'
|
|
8
8
|
|
9
9
|
# Parse options
|
10
10
|
options = {
|
11
|
-
:handler
|
12
|
-
:port
|
13
|
-
:
|
11
|
+
:handler => nil,
|
12
|
+
:port => 3000,
|
13
|
+
:index_filenames => %w( index.html ),
|
14
|
+
:root => '.'
|
14
15
|
}
|
15
16
|
OptionParser.new do |opts|
|
16
17
|
opts.banner = "Usage: adsf [options]"
|
@@ -29,6 +30,11 @@ OptionParser.new do |opts|
|
|
29
30
|
exit
|
30
31
|
end
|
31
32
|
|
33
|
+
# index filenames
|
34
|
+
opts.on('-i', '--index-filenames [index-filenames]', 'Specify index filenames (comma-separated)') do |o|
|
35
|
+
options[:index_filenames] = o.split(',')
|
36
|
+
end
|
37
|
+
|
32
38
|
# port
|
33
39
|
opts.on('-p', '--port [port]', Integer, 'Specify the port number to use') do |o|
|
34
40
|
options[:port] = o
|
@@ -55,9 +61,16 @@ app = Rack::Builder.new do
|
|
55
61
|
use Rack::CommonLogger
|
56
62
|
use Rack::ShowExceptions
|
57
63
|
use Rack::Lint
|
58
|
-
use Adsf::Rack::IndexFileFinder,
|
64
|
+
use Adsf::Rack::IndexFileFinder,
|
65
|
+
:root => options[:root],
|
66
|
+
:index_filenames => options[:index_filenames]
|
59
67
|
run Rack::File.new(options[:root])
|
60
68
|
end.to_app
|
61
69
|
|
70
|
+
# Be quittable
|
71
|
+
%w( INT TERM ).each do |s|
|
72
|
+
Signal.trap(s) { handler.shutdown }
|
73
|
+
end
|
74
|
+
|
62
75
|
# Run
|
63
76
|
handler.run(app, :Port => options[:port])
|
data/lib/adsf.rb
CHANGED
@@ -3,8 +3,9 @@ module Adsf::Rack
|
|
3
3
|
class IndexFileFinder
|
4
4
|
|
5
5
|
def initialize(app, options)
|
6
|
-
@app
|
6
|
+
@app = app
|
7
7
|
@root = options[:root] or raise ArgumentError, ':root option is required but was not given'
|
8
|
+
@index_filenames = options[:index_filenames] || [ 'index.html' ]
|
8
9
|
end
|
9
10
|
|
10
11
|
def call(env)
|
@@ -25,9 +26,8 @@ module Adsf::Rack
|
|
25
26
|
# Add index file if necessary
|
26
27
|
new_env = env.dup
|
27
28
|
if ::File.directory?(path)
|
28
|
-
|
29
|
-
|
30
|
-
new_env['PATH_INFO'] = ::File.join(path_info, 'index.html')
|
29
|
+
if index_filename = index_file_in(path)
|
30
|
+
new_env['PATH_INFO'] = ::File.join(path_info, index_filename)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -35,6 +35,14 @@ module Adsf::Rack
|
|
35
35
|
@app.call(new_env)
|
36
36
|
end
|
37
37
|
|
38
|
+
private
|
39
|
+
|
40
|
+
def index_file_in(dir)
|
41
|
+
@index_filenames.find do |index_filename|
|
42
|
+
::File.file?(::File.join(dir, index_filename))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
38
46
|
end
|
39
47
|
|
40
48
|
end
|
metadata
CHANGED
@@ -1,85 +1,66 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: adsf
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
version: 1.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.1
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Denis Defreyne
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-03-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rack
|
22
|
-
|
23
|
-
|
24
|
-
requirements:
|
25
|
-
- -
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 1
|
29
|
-
- 0
|
30
|
-
- 0
|
16
|
+
requirement: &70157238354860 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
31
21
|
version: 1.0.0
|
32
22
|
type: :runtime
|
33
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70157238354860
|
34
25
|
description: a tiny static file server
|
35
26
|
email: denis.defreyne@stoneship.org
|
36
|
-
executables:
|
27
|
+
executables:
|
37
28
|
- adsf
|
38
29
|
extensions: []
|
39
|
-
|
40
30
|
extra_rdoc_files: []
|
41
|
-
|
42
|
-
files:
|
31
|
+
files:
|
43
32
|
- ChangeLog
|
44
33
|
- LICENSE
|
45
|
-
- NEWS.
|
34
|
+
- NEWS.md
|
46
35
|
- Rakefile
|
47
|
-
- README.
|
36
|
+
- README.md
|
48
37
|
- bin/adsf
|
49
38
|
- lib/adsf/rack/index_file_finder.rb
|
50
39
|
- lib/adsf/rack.rb
|
51
40
|
- lib/adsf.rb
|
52
|
-
has_rdoc: false
|
53
41
|
homepage: http://stoneship.org/software/adsf/
|
54
42
|
licenses: []
|
55
|
-
|
56
43
|
post_install_message:
|
57
44
|
rdoc_options: []
|
58
|
-
|
59
|
-
require_paths:
|
45
|
+
require_paths:
|
60
46
|
- lib
|
61
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
- 1
|
67
|
-
- 8
|
68
|
-
- 5
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
69
52
|
version: 1.8.5
|
70
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
version: "0"
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
77
59
|
requirements: []
|
78
|
-
|
79
60
|
rubyforge_project: adsf
|
80
|
-
rubygems_version: 1.
|
61
|
+
rubygems_version: 1.8.17
|
81
62
|
signing_key:
|
82
63
|
specification_version: 3
|
83
64
|
summary: a tiny static file server
|
84
65
|
test_files: []
|
85
|
-
|
66
|
+
has_rdoc: false
|
data/NEWS.rdoc
DELETED
data/README.rdoc
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
= adsf
|
2
|
-
|
3
|
-
adsf (A Dead Simple Fileserver) is a tiny static file server that you can launch instantly in any directory, like this:
|
4
|
-
|
5
|
-
attignawantan ✓ ~/my_site ▸ ls -l
|
6
|
-
total 0
|
7
|
-
drwxr-xr-x 2 ddfreyne staff 68 May 29 10:04 about
|
8
|
-
drwxr-xr-x 2 ddfreyne staff 68 May 29 10:04 contact
|
9
|
-
-rw-r--r-- 1 ddfreyne staff 0 May 29 10:04 index.html
|
10
|
-
drwxr-xr-x 2 ddfreyne staff 68 May 29 10:04 projects
|
11
|
-
attignawantan ✓ ~/my_site ▸ adsf
|
12
|
-
2009-05-29 10:04:44] INFO WEBrick 1.3.1
|
13
|
-
[2009-05-29 10:04:44] INFO ruby 1.8.7 (2008-08-11) [i686-darwin9.6.1]
|
14
|
-
[2009-05-29 10:04:44] INFO WEBrick::HTTPServer#start: pid=2757 port=3000
|
15
|
-
|
16
|
-
… and now you can go to http://localhost:3000/ and start browsing.
|
17
|
-
|
18
|
-
Some more details about adsf:
|
19
|
-
|
20
|
-
* adsf has only one feature and that is serving static files.
|
21
|
-
* The only documentation you'll get is from the --help commandline option. :)
|
22
|
-
* Rack is the only dependency.
|
23
|
-
* It is licenced under the MIT licence.
|
24
|
-
|
25
|
-
== Contact
|
26
|
-
|
27
|
-
You can reach me at <denis.defreyne@stoneship.org>.
|