RubyApp 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- RubyApp (0.2.1)
4
+ RubyApp (0.2.2)
5
5
  BlueCloth
6
6
  chronic
7
7
  chronic_duration
@@ -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
@@ -4,6 +4,10 @@ module RubyApp
4
4
 
5
5
  module DelegateMixin
6
6
 
7
+ def exists?
8
+ return self.get != nil
9
+ end
10
+
7
11
  def method_missing(name, *arguments, &block)
8
12
  return self.get.send(name, *arguments, &block)
9
13
  end
@@ -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("#{RubyApp::Session.session_id} GET /quit")
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("#{RubyApp::Session.session_id} GET #{element.class} #{format}") do
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("#{RubyApp::Session.session_id} GET #{page.class} #{format}") do
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("#{RubyApp::Session.session_id} POST #{event.class}") do
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
@@ -1,4 +1,4 @@
1
1
  module RubyApp
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  ROOT = File.expand_path(File.dirname(__FILE__))
4
4
  end
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: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
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-21 00:00:00 Z
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