tansu 0.3.0 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3255da4f480f3428f7a2c65590f171229879256d
4
- data.tar.gz: 53d76f95e8831b43946cafb6ad64a32224757e07
3
+ metadata.gz: 5a90e5ef734a65ec4dd70e4bab7c5fea4a1dc0b4
4
+ data.tar.gz: 6591f7215a43f5108d8c16c3716a684defd4aa42
5
5
  SHA512:
6
- metadata.gz: 09c18f040d39a93ba9e7ae35c5bbc14c6a5ea41464616e19b199528598e800a4da35fa2762e691a4211335f4884153800e2b352916de3c19b40325dbedfbd643
7
- data.tar.gz: 14b626ceb849b3f8600e5f58fee281d08f52668bd86e84e6c9f21cc01794922c663f97adb22ef3b666e4162d64d4ff78fff2949fb6e0bf281a41f6e69592330c
6
+ metadata.gz: 3d7584ae81ab7c3b6abc26e6b506b4428dd42743711dec8bb41a0f4ec0dea8a1111a2eb8d95e4c84e4a23e842dbd30f2ae18301d3b017f8b4b03c8a447a497da
7
+ data.tar.gz: 60fc1a43004b0abb8081bad6b98959a448a24ee4e43229ea615896e5540c700db2694604144183373bfdbe2fd36eafa6b9c62efe7d1699cb1bc459b59d3d5dbf
data/lib/tansu.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'uri'
2
+ require 'logger'
2
3
  require 'rack'
3
4
  require 'minicontext'
4
5
  require 'tilt'
@@ -12,6 +13,7 @@ require 'tansu/environment'
12
13
  require 'tansu/configuration'
13
14
  require 'tansu/application'
14
15
  require 'tansu/static'
16
+ require 'tansu/formatter'
15
17
 
16
18
  module Tansu
17
19
  class << self
@@ -35,6 +35,10 @@ module Tansu
35
35
  super res
36
36
  end
37
37
 
38
+ def short_circuit?
39
+ super || redirect?
40
+ end
41
+
38
42
  def headers(hash = nil)
39
43
  response.headers.merge!(hash) if hash
40
44
 
@@ -45,6 +49,10 @@ module Tansu
45
49
  request.session
46
50
  end
47
51
 
52
+ def logger
53
+ Application[:logger]
54
+ end
55
+
48
56
  def redirect(uri, status = 302)
49
57
  response.redirect(uri, status)
50
58
  end
@@ -54,5 +62,9 @@ module Tansu
54
62
  def parse(path)
55
63
  (path[1..-1] || '').split('/').map(&:to_sym)
56
64
  end
65
+
66
+ def redirect?
67
+ Response === @response && @response.status == 302
68
+ end
57
69
  end
58
70
  end
@@ -0,0 +1,13 @@
1
+ module Tansu
2
+ class Formatter < Logger::Formatter
3
+ FORMAT = %{%s [%s] %s : %s\n}
4
+
5
+ def call(severity, time, progname, msg)
6
+ level = severity[0]
7
+ timef = time.strftime("%Y-%m-%d %H:%M:%S %z")
8
+ name = progname || '-'
9
+
10
+ FORMAT % [level, timef, name, msg]
11
+ end
12
+ end
13
+ end
data/lib/tansu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tansu
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tansu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - daisuko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-11 00:00:00.000000000 Z
11
+ date: 2015-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -143,6 +143,7 @@ files:
143
143
  - lib/tansu/configuration.rb
144
144
  - lib/tansu/context.rb
145
145
  - lib/tansu/environment.rb
146
+ - lib/tansu/formatter.rb
146
147
  - lib/tansu/render.rb
147
148
  - lib/tansu/response.rb
148
149
  - lib/tansu/static.rb