busker 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/busker/version.rb +1 -1
- data/lib/busker.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 479d0314b2b96aa30c911d939ad80b2bc8b1df76
|
4
|
+
data.tar.gz: 7d9aba7ffc423e2c566a7dfab46abcebad2c8925
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78b54d4eff9e762c78a661791b9539348ec0f4cd44dee41800531881ed78ddd9d9546f7eb4d8f12fd48c41d8b7a2d57fe6f9ff7bcc779c316252b78460378f10
|
7
|
+
data.tar.gz: 86396ccdde4f1dc4f304842c439a70b2b08292aab40275eb9bbd71005cf7aede2e0bbd52ae87cf88e721db38190176f8bda082a8245b1e76f2a58c06b97a8dd5
|
data/README.md
CHANGED
@@ -62,7 +62,7 @@ Or install it yourself as:
|
|
62
62
|
|
63
63
|
## Design principles
|
64
64
|
|
65
|
-
* Small code base that is
|
65
|
+
* Small code base that is easily to understandable and hackable
|
66
66
|
* Such a tiny code base that you can just copy it into your one-file-project without the need to require a Gem
|
67
67
|
* No dependencies except what is in the Ruby Standard Lib
|
68
68
|
* Backward compatibility to older Ruby versions
|
@@ -74,6 +74,7 @@ Or install it yourself as:
|
|
74
74
|
|
75
75
|
* Improve render method, allow yield etc
|
76
76
|
* Improve error handling, honor production/development environment?
|
77
|
+
* Tests? ;)
|
77
78
|
* Auto reload?
|
78
79
|
* Anything cool that doesn't break the design principles ...
|
79
80
|
|
data/lib/busker/version.rb
CHANGED
data/lib/busker.rb
CHANGED
@@ -7,7 +7,7 @@ module Busker
|
|
7
7
|
class Busker
|
8
8
|
def initialize(opts={}, &block)
|
9
9
|
@_ = {:routes => {}}
|
10
|
-
|
10
|
+
instance_eval(&block) if block_given?
|
11
11
|
opts[:Port] ||= opts.delete(:port) || 8080
|
12
12
|
opts[:DocumentRoot] ||= opts.delete(:document_root) || File.expand_path('./')
|
13
13
|
@_[:server] = WEBrick::HTTPServer.new(opts)
|
@@ -16,6 +16,7 @@ module Busker
|
|
16
16
|
rs.status, rs.content_type, method = nil, 'text/html', rq.request_method.tr('-', '_').upcase
|
17
17
|
route, handler = @_[:routes].find{|k,v| k.first.include?(method) && k.last.match(rq.path_info)}
|
18
18
|
params = Hash[ CGI::parse(rq.query_string||'').map{|k,v| [k.to_sym,v[0]]} + #url params
|
19
|
+
rq.query.map{|k,v| [k.to_sym, v]} + #query params
|
19
20
|
($~ ? $~.names.map(&:to_sym).zip($~.captures) : []) ] #dynamic route params
|
20
21
|
rs.status, rs.body = route ? [rs.status || 200, handler[:block].call(params, rq, rs)] : [404, 'not found']
|
21
22
|
rescue => e
|