lib/staticme.rb in staticme-0.1.0 vs lib/staticme.rb in staticme-0.2.0
- old
+ new
@@ -1,18 +1,32 @@
require 'rubygems'
-require 'rack'
-require 'thin'
+require 'staticme/app'
+require 'staticme/arguments'
+require 'staticme/runner'
+require 'staticme/thin_runner'
+
module Staticme
+
extend self
- def run!(argv)
- pwd = argv['-f'] || argv['--path'] || Dir.pwd
- port = (argv['-p'] || argv['--port'] || 8080).to_i
- host = argv['-h'] || argv['--host'] || '0.0.0.0'
- staticme = Rack::Builder.new do
- run Rack::Directory.new(pwd)
- end
+ extend Staticme::Arguments
- Rack::Handler::Thin.run(staticme, :Port => port, :Host => host)
+ attr_accessor :runner
+
+ def run!(argv, &blk)
+
+ params = parse_input(argv)
+
+ app = Staticme::App.new(params).bind
+
+ runner = Staticme::ThinRunner.new
+
+ runner.start(app, params, &blk)
+
end
+
+ def stop!
+ runner.stop
+ end
+
end