city-watch 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,14 @@
1
+ require 'erubis'
2
+
3
+ TemplateCache = {}
4
+ ViewPath = File.expand_path(File.dirname(__FILE__) + "/../../../views")
5
+ Layout = Proc.new {
6
+ file_path = "#{ViewPath}/layouts/default.html.erb"
7
+ Erubis::FastEruby.new(File.read(file_path), bufvar: '@output_buffer', filename: file_path)
8
+ }.call
9
+
1
10
  module Renderer
2
11
 
3
- require 'erubis'
4
-
5
12
  def render(*tpl)
6
13
  layout do
7
14
  render_bare(*tpl)
@@ -15,11 +22,7 @@ module Renderer
15
22
  private
16
23
 
17
24
  def layout(&block)
18
- @layout ||= Proc.new {
19
- file_path = "#{view_path}/layouts/default.html.erb"
20
- Erubis::FastEruby.new(File.read(file_path), bufvar: '@output_buffer', filename: file_path)
21
- }.call
22
- @layout.result(binding)
25
+ Layout.result(binding)
23
26
  end
24
27
 
25
28
  def template_content(file_path)
@@ -27,24 +30,19 @@ module Renderer
27
30
  File.read(file_path)
28
31
  end
29
32
 
30
- def template_key(*keys)
31
- keys.inject("") {|a,k| a += k.to_s}
32
- end
33
-
34
33
  def template_path(*tpl)
35
34
  tpl.map {|t| "#{view_path}/#{t}.html.erb" }.detect{|p| File.exists?(p) }
36
35
  end
37
36
 
38
37
  def template(*tpl)
39
- return @templates[tpl.join] if @templates && @templates[tpl.join]
38
+ return TemplateCache[tpl.join] if TemplateCache[tpl.join]
40
39
  file_path = template_path(*tpl)
41
40
  return template_content(file_path) if CityWatch.debug?
42
- @templates ||= {}
43
- @templates[tpl.join] ||= template_content(file_path)
41
+ TemplateCache[tpl.join] ||= template_content(file_path)
44
42
  end
45
43
 
46
44
  def view_path
47
- File.expand_path(File.dirname(__FILE__) + "/../../../views")
45
+ ViewPath
48
46
  end
49
47
 
50
48
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CityWatch
2
- VERSION = "0.6.3"
2
+ VERSION = "0.6.4"
3
3
  end
@@ -3,7 +3,7 @@ sum = summary
3
3
  update_time = sum.delete("received_at")
4
4
  %>
5
5
  <div class="server">
6
- <a href="/<%=@host%>"><%=@host%></a>
6
+ <a href="/<%=@host%>"><%=@host%></a> (Last update: <%=update_time%>)
7
7
  <% sum.each do |watchman,dat| %>
8
8
  <%= Reader::Watchman.new(@host,watchman).render_from_summary(dat) %>
9
9
  <% end %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: city-watch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: