webify 0.1.0
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/README.md +7 -0
- data/bin/webify +3 -0
- data/lib/webify.rb +49 -0
- metadata +51 -0
data/README.md
ADDED
data/bin/webify
ADDED
data/lib/webify.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'webrick'
|
2
|
+
require 'optparse'
|
3
|
+
|
4
|
+
require 'ruby-debug'
|
5
|
+
|
6
|
+
class Webify
|
7
|
+
include WEBrick
|
8
|
+
|
9
|
+
DEFAULT_PORT = 3000
|
10
|
+
|
11
|
+
def self.start(options={})
|
12
|
+
dir = File.expand_path(options[:dir] || Dir::pwd)
|
13
|
+
port = options[:port] || DEFAULT_PORT
|
14
|
+
|
15
|
+
msg = "Serving: #{dir}\nURL: http://#{Socket.gethostname}:#{port}"
|
16
|
+
|
17
|
+
puts "="*80
|
18
|
+
puts "#{msg}\n"
|
19
|
+
puts ("="*80)+"\n\n"
|
20
|
+
|
21
|
+
server = HTTPServer.new(
|
22
|
+
:Port => port,
|
23
|
+
:DocumentRoot => dir
|
24
|
+
)
|
25
|
+
|
26
|
+
trap('INT') { server.shutdown }
|
27
|
+
server.start
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
options = {
|
32
|
+
:port => Webify::DEFAULT_PORT,
|
33
|
+
:dir => Dir.pwd
|
34
|
+
}
|
35
|
+
|
36
|
+
options_parser = OptionParser.new do |opts|
|
37
|
+
opts.banner = "Webify -- serve any directory to your browser\n"+
|
38
|
+
"Usage: webify [options]"
|
39
|
+
|
40
|
+
opts.separator ""
|
41
|
+
opts.separator "Server options:"
|
42
|
+
|
43
|
+
opts.on('-p', '--port PORT', "Use PORT (default: #{options[:port]})") {|val| options[:port] = val }
|
44
|
+
opts.on('-d', '--dir DIRECTORY', "Document root DIRECTORY (default: #{options[:dir]})") {|val| options[:dir] = val }
|
45
|
+
opts.on('-h', '--help', 'Display this help message') { puts opts; exit! }
|
46
|
+
end
|
47
|
+
options_parser.parse!(ARGV)
|
48
|
+
|
49
|
+
Webify.start(options)
|
metadata
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: webify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Rida Al Barazi
|
9
|
+
- Peter Kieltyka
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2011-09-28 00:00:00.000000000Z
|
14
|
+
dependencies: []
|
15
|
+
description: Serve any directory to your browser
|
16
|
+
email:
|
17
|
+
- rida@nulayer.com
|
18
|
+
- peter@nulayer.com
|
19
|
+
executables:
|
20
|
+
- webify
|
21
|
+
extensions: []
|
22
|
+
extra_rdoc_files: []
|
23
|
+
files:
|
24
|
+
- README.md
|
25
|
+
- lib/webify.rb
|
26
|
+
- bin/webify
|
27
|
+
homepage: http://github.com/nulayer/webify
|
28
|
+
licenses: []
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 1.3.6
|
45
|
+
requirements: []
|
46
|
+
rubyforge_project:
|
47
|
+
rubygems_version: 1.8.9
|
48
|
+
signing_key:
|
49
|
+
specification_version: 3
|
50
|
+
summary: Serve any directory to your browser
|
51
|
+
test_files: []
|