Use a status object

This commit is contained in:
cn 2013-05-03 18:30:34 +02:00
parent cd6e41fcfa
commit 438931f8a6
4 changed files with 18 additions and 6 deletions

View File

@ -7,9 +7,9 @@ require 'yaml'
require 'rack'
require 'metriks'
require 'openvpn-status-web/status'
require 'openvpn-status-web/parser/v1'
require 'openvpn-status-web/int_patch'
require 'openvpn-status-web/status'
require 'openvpn-status-web/version'
module OpenVPNStatusWeb
@ -37,7 +37,7 @@ module OpenVPNStatusWeb
main_tmpl = read_template(File.join(File.dirname(__FILE__), 'openvpn-status-web/main.html.erb'))
# variables for template
name = @name
client_list, routing_table, global_stats = read_status_log(@file)
status = read_status_log(@file)
html = main_tmpl.result(binding)
[200, {"Content-Type" => "text/html"}, [html]]

View File

@ -55,7 +55,7 @@ thead {
<td class="last">Connected Since</td>
</thead>
<tbody>
<% client_list.each do |client| %>
<% status.client_list.each do |client| %>
<tr>
<td class="first"><%= client[0] %></td>
<td class="middle"><%= client[1] %></td>
@ -78,7 +78,7 @@ thead {
<td class="last">Last Ref</td>
</thead>
<tbody>
<% routing_table.each do |e| %>
<% status.routing_table.each do |e| %>
<tr>
<td class="first"><%= e[0] %></td>
<td class="middle"><%= e[1] %></td>
@ -94,7 +94,7 @@ thead {
<div>
<table>
<tbody>
<% global_stats.each do |e| %>
<% status.global_stats.each do |e| %>
<tr>
<td><%= e[0] %>:</td>
<td><%= e[1] %></td>

View File

@ -21,7 +21,11 @@ module OpenVPNStatusWeb
end
end
[client_list[2..-1], routing_table[1..-1], global_stats]
status = Status.new
status.client_list = client_list[2..-1]
status.routing_table = routing_table[1..-1]
status.global_stats = global_stats
status
end
end
end

View File

@ -0,0 +1,8 @@
module OpenVPNStatusWeb
class Status
attr_accessor :client_list
attr_accessor :routing_table
attr_accessor :global_stats
end
end