sansom 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ea8ea9f12513294f151757423264d44870d210f
4
- data.tar.gz: 405f6c890367eaa2c961cc4520f58b1bdc7ddc6d
3
+ metadata.gz: c0ed3a40529913f75db37f78542ad2a6a1dde6a0
4
+ data.tar.gz: c9b93cde34acbcc3a3144170c75caa112192d72e
5
5
  SHA512:
6
- metadata.gz: f773bca14fef8bdfb91ba0147d97d952fc72189bd4c8d368e76c5920cf7d9c57c4073fdbd216e97c560f58c1e86481ca9737898d6090fb1246096a01e3e87532
7
- data.tar.gz: da9038bc8791abbbf2aed558613d3b922e6dd95eb8feea4cc7e2d09e668536c565e0bd6b5d8fecfcc00907adfd0c0bb1c7b2bc7302152fdccd837831d0c33097
6
+ metadata.gz: 38f436abd2d865c291f9c5edb4cded8eb6928374c80aa4a51b867c2e4f9dfe2e9e0e7b95363ef6e53d17088864482f4ff43e62215215c8760bb3ca710edd1063
7
+ data.tar.gz: d9b5f887a2620ee55d1c9584c068c61c86a48c63a8d3babbb7106e36899798f1904f33ff03280ee3c91a6b694b68d7bff2ab375ce2e195f5a3607dee4b306749
data/README.md CHANGED
@@ -164,6 +164,20 @@ Notes
164
164
  * Rack conformity & the DSL (`sansom.rb`)
165
165
  * Custom tree-based routing (`pine.rb`)
166
166
 
167
+ Speed
168
+ -
169
+
170
+ Well, that's great and all, but how fast is "hello world" example in comparision to Rack or Sinatra?
171
+
172
+ Rack: **15ms**<br />
173
+ Sansom: **15ms**<br />
174
+ Sinatra: **28ms**<br />
175
+ Rails: **34ms**
176
+
177
+ (results are rounded down)
178
+
179
+ Hey [Konstantine](https://github.com/rkh), *put that in your pipe and smoke it*.
180
+
167
181
  Contributing
168
182
  -
169
183
 
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "rack"
4
+
5
+ module Rack
6
+ class Fastlint
7
+ def self.response res
8
+ # Check response format
9
+ return false unless res.kind_of?(Array) && res.count == 3
10
+
11
+ status, headers, body = res
12
+
13
+ return false unless status.to_i >= 100
14
+
15
+ return false unless headers.respond_to? :each
16
+ headers.each { |k,v|
17
+ next if key =~ /^rack\..+$/
18
+ return false unless k.kind_of? String
19
+ return false unless v.kind_of? String
20
+ return false if k.downcase == "status"
21
+ return false unless k !~ /[:\n]/
22
+ return false unless k !~ /[-_]\z/
23
+ return false unless k =~ /\A[a-zA-Z][a-zA-Z0-9_-]*\z/
24
+ }
25
+
26
+ return false unless body.respond_to? :each
27
+ body.each { |part| return false unless part.kind_of? String }
28
+
29
+ if body.respond_to? :to_path
30
+ return false unless File.exist? body.to_path
31
+ end
32
+
33
+ true
34
+ end
35
+ end
36
+ end
data/lib/sansom.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "rack"
4
4
  require_relative "./sansom/pine"
5
+ require_relative "./rack/fastlint.rb"
5
6
 
6
7
  module Sansomable
7
8
  InvalidRouteError = Class.new StandardError
@@ -24,7 +25,7 @@ module Sansomable
24
25
 
25
26
  if @before_block
26
27
  res = @before_block.call r
27
- return res if [Fixnum, Hash, Array]-res.map(&:class) == 0
28
+ return res if Rack::Fastlint.response res
28
29
  end
29
30
 
30
31
  m = tree.match r.path_info, r.request_method
data/sansom.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "sansom"
7
- s.version = "0.0.5"
7
+ s.version = "0.0.6"
8
8
  s.authors = ["Nathaniel Symer"]
9
9
  s.email = ["nate@natesymer.com"]
10
10
  s.summary = "Scientific, philosophical, abstract web 'picowork' named after Sansom street in Philly, near where it was made."
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sansom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathaniel Symer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-31 00:00:00.000000000 Z
11
+ date: 2014-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,7 @@ files:
52
52
  - LICENSE.txt
53
53
  - README.md
54
54
  - changelog.md
55
+ - lib/rack/fastlint.rb
55
56
  - lib/sansom.rb
56
57
  - lib/sansom/pine.rb
57
58
  - sansom.gemspec