Skip to content

Instantly share code, notes, and snippets.

@b1nary
Created January 24, 2012 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b1nary/1672100 to your computer and use it in GitHub Desktop.
Save b1nary/1672100 to your computer and use it in GitHub Desktop.
A projekt based time plan maker

Generate Fancy ASCII/HTML tables for a simple projekt time plan

Made by me. Feel free to use and or modify ;)

4
DI:MI:DO:FR:MO:DI:MI:DO
Termin done in time:0:0..2:0:1..2
Done another day:1:0..1:2:0..1
Not yet done...:1:2..3:-1:0
#!/usr/bin/env ruby
data = File.open("data.seta").read.split("\n")
fields = data[0]
data.delete("-")
days = data[1].split(":")
data.delete_at(0)
data.delete_at(0)
# get biggest round...
maxsize = 0
data.each do |d|
xxx = d.split(":")[0].size
maxsize = xxx if xxx > maxsize
end
print "+"
(maxsize+2).times { print "-" }
print "+"
days.each { |d| print "-------+" }
puts ""
print "|"
print " *O*"
(maxsize-2).times { print " " }
print "|"
days.each { |d| print " #{d} |" }
puts ""
print "+"
(maxsize+2).times { print "-" }
print "+"
days.each { |d| print "-+-+-+-+" }
puts ""
# statistics
done = 0
open = 0
doneintime = 0
data.each do |x|
row = x.split(":")
print "| #{row[0]}"
((maxsize+1)-row[0].size).times { print " " }
p_days = [row[1].to_i]
p_hour = [row[2].to_i]
p_days = (eval(row[1])).to_a if row[1].include?'..'
p_hour = (eval(row[2])).to_a if row[2].include?'..'
d_days = [row[3].to_i]
d_hour = [row[4].to_i]
d_days = (eval(row[3])).to_a if row[3].include?'..'
d_hour = (eval(row[4])).to_a if row[4].include?'..'
done += 1 if d_days != [-1]
open += 1 if d_days == [-1]
print "|"
days.size.times do |di|
fields.to_i.times do |fi|
out = " "
out = "~" if p_days.include?(di) and p_hour.include?(fi)
out = "O" if d_days.include?(di) and d_hour.include?(fi)
if d_days.include?(di) and d_hour.include?(fi) and p_days.include?(di) and p_hour.include?(fi)
out = "#"
doneintime += 1
end
out += "|"
print out
end
end
puts ""
end
print "+"
(maxsize+2).times { print "-" }
print "+"
days.each { |d| print "-------+" }
print "
+------------------+ +---------------------------+
| Legend | | Statistic |
+---+--------------+ +--------------+------------+
| ~ | planned | | Done in Time | #{doneintime}
| O | done | | Done | #{done}
| # | done in time | | Open | #{open}
+---+--------------+ +--------------+ "
puts ""
#!/usr/bin/env ruby
data = File.open("data.seta").read.split("\n")
fields = data[0]
days = data[1].split(":")
data.delete_at(0)
data.delete_at(0)
print "<style type='text/css'>
body { font-family:Monospace; }
td { min-width:14px; border: 1px solid black; }
.green { background-color:lime; }
.darkgreen { color:darkgreen; vertical-align:center; }
.meh { color:darkblue; vertical-align:center; }
.noned { border:0px!important; padding-right:8px; }
</style>"
puts "<table>"
print "<tr><th></th>"
days.each { |d| print "<th colspan='#{fields}'>#{d}</th>" }
print "</tr>"
data.each do |x|
row = x.split(":")
print "<tr><td class='noned'>#{row[0]}</td>"
p_days = [row[1].to_i]
p_hour = [row[2].to_i]
p_days = (eval(row[1])).to_a if row[1].include?'..'
p_hour = (eval(row[2])).to_a if row[2].include?'..'
d_days = [row[3].to_i]
d_hour = [row[4].to_i]
d_days = (eval(row[3])).to_a if row[3].include?'..'
d_hour = (eval(row[4])).to_a if row[4].include?'..'
days.size.times do |di|
fields.to_i.times do |fi|
out = "<td"
out += " class='green'" if p_days.include?(di) and p_hour.include?(fi)
out += ">"
out += "<span class='darkgreen'>#</span>" if d_days.include?(di) and d_hour.include?(fi)
out += "</td>"
print out
end
end
print "</tr>"
end
print "</table>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment