RubyApp 0.2.1 → 0.2.2
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/Gemfile.lock +1 -1
- data/lib/ruby_app/log.rb +10 -0
- data/lib/ruby_app/mixins/delegate_mixin.rb +4 -0
- data/lib/ruby_app/rack/route.rb +4 -4
- data/lib/ruby_app/version.rb +1 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/lib/ruby_app/log.rb
CHANGED
@@ -6,12 +6,21 @@ require 'fileutils'
|
|
6
6
|
require 'logger'
|
7
7
|
|
8
8
|
module RubyApp
|
9
|
+
require 'ruby_app'
|
9
10
|
require 'ruby_app/mixins'
|
10
11
|
|
11
12
|
class Log < ::Logger
|
12
13
|
extend RubyApp::Mixins::ConfigurationMixin
|
13
14
|
extend RubyApp::Mixins::DelegateMixin
|
14
15
|
|
16
|
+
class Formatter < ::Logger::Formatter
|
17
|
+
|
18
|
+
def call(severity, time, application, message)
|
19
|
+
return "#{severity} | #{time.strftime('%Y-%m-%d %H:%M:%S %Z')} | #{RubyApp::Session.exists? ? RubyApp::Session.session_id : '-'} | #{RubyApp::Session.exists? && RubyApp::Session.identity ? RubyApp::Session.identity.url : '-'} | #{message}\n"
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
15
24
|
def duration(message)
|
16
25
|
start = Time.now
|
17
26
|
begin
|
@@ -69,6 +78,7 @@ module RubyApp
|
|
69
78
|
|
70
79
|
def initialize(path)
|
71
80
|
super(path)
|
81
|
+
self.formatter = RubyApp::Log::Formatter.new
|
72
82
|
end
|
73
83
|
|
74
84
|
end
|
data/lib/ruby_app/rack/route.rb
CHANGED
@@ -18,7 +18,7 @@ module RubyApp
|
|
18
18
|
end
|
19
19
|
|
20
20
|
route(RubyApp::Mixins::RouteMixin::GET, /\/quit/) do |method, path|
|
21
|
-
RubyApp::Log.debug("
|
21
|
+
RubyApp::Log.debug("GET /quit")
|
22
22
|
RubyApp::Session.quit!
|
23
23
|
RubyApp::Response['Content-Type'] = 'text/html'
|
24
24
|
RubyApp::Response.write(RubyApp::Elements::Pages::QuitPage.new.render(:html))
|
@@ -28,7 +28,7 @@ module RubyApp
|
|
28
28
|
RubyApp::Response['Content-Type'] = RubyApp::Element.get_content_type(format)
|
29
29
|
begin
|
30
30
|
element = RubyApp::Element.get_element(element_id)
|
31
|
-
RubyApp::Log.duration("
|
31
|
+
RubyApp::Log.duration("GET #{element.class} #{format}") do
|
32
32
|
RubyApp::Response.write(element.render(format.to_sym))
|
33
33
|
end
|
34
34
|
rescue Exception => exception
|
@@ -39,7 +39,7 @@ module RubyApp
|
|
39
39
|
route(RubyApp::Mixins::RouteMixin::GET, /\.([^\.\?]+)/) do |method, path, format|
|
40
40
|
RubyApp::Response['Content-Type'] = RubyApp::Element.get_content_type(format)
|
41
41
|
page = RubyApp::Session.pages.last
|
42
|
-
RubyApp::Log.duration("
|
42
|
+
RubyApp::Log.duration("GET #{page.class} #{format}") do
|
43
43
|
RubyApp::Response.write(page.render(format.to_sym))
|
44
44
|
end
|
45
45
|
end
|
@@ -52,7 +52,7 @@ module RubyApp
|
|
52
52
|
RubyApp::Response['Content-Type'] = 'application/json'
|
53
53
|
begin
|
54
54
|
event = RubyApp::Element::Event.from_hash(RubyApp::Request.POST)
|
55
|
-
RubyApp::Log.duration("
|
55
|
+
RubyApp::Log.duration("POST #{event.class}") do
|
56
56
|
event.process!
|
57
57
|
RubyApp::Response.write(Yajl::Encoder.new.encode(event.to_hash))
|
58
58
|
end
|
data/lib/ruby_app/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: RubyApp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Frank G. Ficnar
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-03-
|
18
|
+
date: 2012-03-22 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|