centralised configuration to config.rb

This commit is contained in:
Christoffer Müller Madsen 2017-05-09 13:40:42 +02:00
parent e1b5259ba6
commit beb2e8a428
4 changed files with 29 additions and 15 deletions

6
config.rb Normal file
View File

@ -0,0 +1,6 @@
RES_BASE = "https://strawberry.thedevcave.net/~christoffermadsen/"
USERNAMES = ["christoffermadsen","jmaa","jacob","alexander"]
SHOT_DIR = "/var/shots/"
ERB_FILE = "dcav-index.erb"
HTML_FILE = "/var/shots/html/index.html"
LOG_DIR = "./log/"

View File

@ -1,11 +1,12 @@
require 'erb'
require 'filesize'
RES_BASE = "https://strawberry.thedevcave.net/~christoffermadsen/"
usernames = ["christoffermadsen","jmaa","jacob","alexander"]
shot_dir = "/var/shots/"
erb_file = "dcav-index.erb"
html_file = "/var/shots/html/index.html"
load 'config.rb'
usernames = USERNAMES
shot_dir = SHOT_DIR
erb_file = ERB_FILE
html_file = HTML_FILE
class User
attr_accessor :name, :count, :size, :avgsize

View File

@ -1,11 +1,15 @@
# coding: utf-8
users = ["christoffermadsen","jmaa","jacob","alexander"]
load 'config.rb'
users = USERNAMES
log_dir = LOG_DIR
colors = {}
users.each do |user|
colors[user] = "%06x" % (rand * 0xffffff)
end
log_dir = "./log/"
plotstring = %Q[set terminal 'svg' size 800,400 fname 'Verdana, Helvetica, Arial, sans-serif' \
fsize '14' rounded dashed
set key bottom center outside horizontal

View File

@ -1,6 +1,9 @@
users = ["christoffermadsen","jmaa","alexander","jacob"]
shot_dir = "/var/shots/"
log_dir = "./log/"
load 'config.rb'
users = USERNAMES
shot_dir = SHOT_DIR
log_dir = LOG_DIR
users.each do |user|
size = `du -B1 #{shot_dir}#{user}/ | awk {'print $1'} | head -n 1`
count = `ls -1 #{shot_dir}#{user}/ | wc -l | head -n 1`
@ -9,7 +12,7 @@ users.each do |user|
x.delete! "\n"
end
output = File.open("#{log_dir}/#{user}.log","a")
output << "#{Time.now.to_i} #{count} #{size}\n"
output.close
File.open("#{log_dir}/#{user}.log","a") do |f|
f << "#{Time.now.to_i} #{count} #{size}\n"
end
end