ws 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +5 -0
  2. data/bin/ws +5 -0
  3. data/lib/ws.rb +1 -1
  4. metadata +1 -1
data/README.md CHANGED
@@ -30,6 +30,11 @@ To install, make sure you have the latest version of Ruby and RubyGems installed
30
30
  :::text
31
31
  ws -d ~ -p 1337 -v
32
32
 
33
+ ### Launch a server and use `default.htm` as the default file to serve.
34
+
35
+ :::text
36
+ ws -i default.htm
37
+
33
38
  ### Show help
34
39
 
35
40
  :::text
data/bin/ws CHANGED
@@ -18,6 +18,11 @@ optparse = OptionParser.new do |opts|
18
18
  options[:directory] = directory
19
19
  end
20
20
 
21
+ options[:index] = "index.html"
22
+ opts.on "-i", "--index-file FILENAME", "Specify the file name to use for index files." do |file|
23
+ options[:index] = file
24
+ end
25
+
21
26
  options[:port] = 5000 + options[:directory].hash % 1000
22
27
  opts.on "-p", "--port PORT", Integer, "Specify port to use" do |port|
23
28
  options[:port] = port
data/lib/ws.rb CHANGED
@@ -6,7 +6,7 @@ module WS
6
6
  while (conn = server.accept)
7
7
  file = conn.gets.scan(/(?<=\/).*(?=\sHTTP)/)[0].split("/")
8
8
  file_path = File.join(options[:directory], file)
9
- file_path = File.join(file_path, "index.html") if File.directory? file_path
9
+ file_path = File.join(file_path, options[:index]) if File.directory? file_path
10
10
  mime_type = get_mime_type file_path
11
11
  begin
12
12
  file_handle = File.open(file_path, "r")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: