rresume 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ RRESUME_VERSION="0.1.2"
@@ -3,4 +3,5 @@ require 'rresume/project'
3
3
  require 'rresume/projectlist'
4
4
  require 'rresume/tool'
5
5
  require 'rresume/duration'
6
+ require 'RRESUME_VERSION'
6
7
 
@@ -1,9 +1,24 @@
1
+ #begin
2
+ # require 'pdf/writer'
3
+ #rescue LoadError => le
4
+ # if le.message =~ %r{pdf/writer$}
5
+ # $LOAD_PATH.unshift("../lib")
6
+ # require 'pdf/writer'
7
+ # else
8
+ # raise
9
+ # end
10
+ #end
11
+
12
+ require 'rubygems'
13
+ require 'pdf/writer'
14
+ require 'pdf/simpletable' # das musste man noch extra requirieren
1
15
 
2
16
  class Person
3
17
 
4
18
  attr_reader :firstname, :lastname
5
19
  attr_accessor :adresse, :plz, :ort, :telefon, :mobil, :email, :education_list,
6
- :weiterbildungen, :fremdsprachen, :sonstiges
20
+ :weiterbildungen, :fremdsprachen, :sonstiges, :stylesheet_text,
21
+ :einsatzort, :stundensatz
7
22
 
8
23
  def initialize(firstname="",lastname="")
9
24
  @firstname = firstname
@@ -11,6 +26,12 @@ class Person
11
26
  # @projectlist = Array.new
12
27
  @projectlist = ProjectList.new
13
28
  @categories = Hash.new
29
+ @stylesheet_text = ""
30
+ @pdf_table_width = 550
31
+ @pdf_h1 = 18
32
+ @pdf_h2 = 16
33
+ @pdf_h3 = 14
34
+ @pdf_h4 = 12
14
35
  end
15
36
 
16
37
  def <<(what)
@@ -50,15 +71,35 @@ class Person
50
71
  end
51
72
 
52
73
  def write(mode=:html, order=:newest_first, verfuegbarkeit=nil)
74
+ if mode == :pdf
75
+ pdf = PDF::Writer.new
76
+ pdf.select_font "Times-Roman"
77
+ pdf.text "Hello Ruby", :font_size => 12, :justification => :left
78
+ end
53
79
  output_oben if mode==:html
54
80
  ### output_category_links(mode)
55
- output_personal(mode,verfuegbarkeit)
56
- output_projects(mode, order)
81
+ if mode == :pdf
82
+ output_personal_pdf(pdf,verfuegbarkeit)
83
+ else
84
+ output_personal(mode,verfuegbarkeit)
85
+ end
86
+ if mode == :pdf
87
+ output_projects_pdf(pdf, order)
88
+ else
89
+ output_projects(mode, order)
90
+ end
57
91
  @categories.each {|output_category|
58
- output_category(output_category, mode)
92
+ if mode == :pdf
93
+ output_category_pdf(pdf, output_category)
94
+ else
95
+ output_category(output_category, mode)
96
+ end
59
97
  }
60
98
  output_sonstiges(mode)
61
99
  output_werbung(mode)
100
+ if mode == :pdf
101
+ pdf.save_as("profil.pdf")
102
+ end
62
103
  end
63
104
 
64
105
  ###TODO: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
@@ -69,6 +110,7 @@ class Person
69
110
  <html>
70
111
  <head>
71
112
  <title>Profil #{@firstname} #{@lastname}</title>
113
+ #{@stylesheet_text}
72
114
  </head>
73
115
 
74
116
  <body background="" bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
@@ -88,7 +130,7 @@ END
88
130
  def output_werbung(mode)
89
131
  if mode == :html
90
132
  puts <<END
91
- <br>created with <a href="http://www.thopre.de/rresume/">rresume</a>
133
+ <br>created with <a href="http://www.thopre.de/rresume/">rresume</a> (V. #{RRESUME_VERSION})
92
134
  END
93
135
  else
94
136
  puts <<END
@@ -213,7 +255,7 @@ email: <a href="mailto:#{@email}">#{@email}</a><BR>
213
255
  </B>
214
256
  </TD>
215
257
  <TD >
216
- Raum Berlin.
258
+ #{@einsatzort}
217
259
  </TD>
218
260
  </TR>
219
261
  <TR>
@@ -225,7 +267,224 @@ Stundensatz:
225
267
  <TD >
226
268
  <!-- 70 &#8364;/h zuz&uuml;gl. MwSt.
227
269
  -->
228
- nach Vereinbarung
270
+ #{stundensatz}
271
+ </TD>
272
+
273
+ </TR>
274
+ </TABLE>
275
+
276
+ <h1><a name="link">Pers&ouml;nliche Daten</a></h1>
277
+ <TABLE width="95%" border="0" cellspacing="0" cellpadding="4">
278
+ <TR>
279
+ <!-- Row 1 Column 1 -->
280
+ <TD >
281
+ <B>
282
+ Geburtsdatum:
283
+ </B>
284
+ </TD>
285
+ <!-- Row 1 Column 2 -->
286
+ <TD >
287
+ 1961-11-21
288
+ </TD>
289
+ </TR>
290
+ <TR>
291
+ <!-- Row 2 Column 1 -->
292
+ <TD valign="top">
293
+ <B>
294
+ Ausbildung:
295
+ </B>
296
+ </TD>
297
+ <!-- Row 2 Column 2 -->
298
+ <TD >
299
+ <div id="educations"></div>
300
+ </TD>
301
+ </TR>
302
+ <TR>
303
+ <TD >
304
+ <B>
305
+ Fortbildung:
306
+ </B>
307
+ </TD>
308
+ <TD >
309
+ <div id="weiterbildungen"></div>
310
+ </TD>
311
+ </TR>
312
+ <TR>
313
+ <TD valign="top">
314
+ <B>
315
+ Fremdsprachen:
316
+ </B>
317
+ </TD>
318
+ <TD >
319
+ <div id="fremdsprachen"></div>
320
+ </TD>
321
+ </TR>
322
+ </TABLE>
323
+
324
+ END
325
+ #TODO: puts "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">"
326
+ array1 = @education_list
327
+ array2 = @weiterbildungen
328
+ array3 = @fremdsprachen
329
+ data = {
330
+ :educations => array1,
331
+ :weiterbildungen => array2,
332
+ :fremdsprachen => array3,
333
+ }
334
+
335
+ tmpl.prettyprint = true
336
+ #tmpl.expand(STDOUT, data)
337
+ tmpl.expand($stdout, data)
338
+ end # output_personal
339
+
340
+ def output_personal_pdf(pdf,p_verfuegbarkeit=nil)
341
+ verfuegbarkeit=<<END
342
+ Verf&uuml;gbarkeit: In den als frei gekennzeichneten Monaten bin ich aktuell
343
+ noch verf&uuml;gbar. In den anderen bin ich ganz oder teilweise
344
+ gebucht. Ggf. gibt es aber auch da M&ouml;glichkeiten einer Zusammenarbeit,
345
+ falls es sich um kleinere Aufgaben handelt.
346
+ <p>
347
+ <table border="1" width="100%">
348
+ <tr>
349
+ <td><b>Verf&uuml;gbarkeit</b> </td>
350
+ <td>01 </td>
351
+ <td>02 </td>
352
+ <td>03 </td>
353
+ <td>04 </td>
354
+ <td>05 </td>
355
+ <td>06 </td>
356
+ <td>07 </td>
357
+ <td>08 </td>
358
+ <td>09 </td>
359
+ <td>10 </td>
360
+ <td>11 </td>
361
+ <td>12 </td>
362
+ </tr>
363
+ <tr>
364
+ <td>2006</td>
365
+ <!-- 01 --> <td bgcolor="lightgreen">frei </td>
366
+ <!-- 02 --> <td bgcolor="lightgreen">frei </td>
367
+ <!-- 03 --> <td bgcolor="lightgreen">frei </td>
368
+ <!-- 04 --> <td bgcolor="lightgreen">frei </td>
369
+ <!-- 05 --> <td bgcolor="lightgreen">frei </td>
370
+ <!-- 06 --> <td bgcolor="black"><font color="white">gebucht</font></td>
371
+ <!-- 07 --> <td bgcolor="black"><font color="white">gebucht</font></td>
372
+ <!-- 08 --> <td bgcolor="black"><font color="white">gebucht</font></td>
373
+ <!-- 09 --> <td bgcolor="lightgreen">frei </td>
374
+ <!-- 10 --> <td bgcolor="lightgreen">frei </td>
375
+ <!-- 11 --> <td bgcolor="lightgreen">frei </td>
376
+ <!-- 12 --> <td bgcolor="lightgreen">frei </td>
377
+ </tr>
378
+ <tr>
379
+ <td>2007</td>
380
+ <!-- 01 --> <td bgcolor="lightgreen">frei </td>
381
+ <!-- 02 --> <td bgcolor="lightgreen">frei </td>
382
+ <!-- 03 --> <td bgcolor="lightgreen">frei </td>
383
+ <!-- 04 --> <td bgcolor="lightgreen">frei </td>
384
+ <!-- 05 --> <td bgcolor="lightgreen">frei </td>
385
+ <!-- 06 --> <td bgcolor="lightgreen">frei </td>
386
+ <!-- 07 --> <td bgcolor="lightgreen">frei </td>
387
+ <!-- 08 --> <td bgcolor="lightgreen">frei </td>
388
+ <!-- 09 --> <td bgcolor="lightgreen">frei </td>
389
+ <!-- 10 --> <td bgcolor="lightgreen">frei </td>
390
+ <!-- 11 --> <td bgcolor="lightgreen">frei </td>
391
+ <!-- 12 --> <td bgcolor="lightgreen">frei </td>
392
+ </tr>
393
+ </table>
394
+ END
395
+
396
+ if p_verfuegbarkeit!=:mit_verfuegbarkeit
397
+ verfuegbarkeit=""
398
+ end
399
+
400
+ dokument_source=<<__END__
401
+ Dokument: <code>
402
+ <a href="http://www.thopre.de/profil.html">
403
+ http://www.thopre.de/profil.html
404
+ </a>
405
+ </code>
406
+ __END__
407
+ #!!!
408
+ dokument_source=<<__END__
409
+ __END__
410
+
411
+ table = PDF::SimpleTable.new
412
+ table.data = [
413
+ { "c1" => "Profil von", "c2" => "#{adresse}", "c3" => "mobil: #{@mobil}" },
414
+ { "c1" => "#{firstname} #{lastname}", "c2" => "#{@plz} #{ort}", "c3" => "eMail:. #{@email}" },
415
+ { "c1" => "Stand: #{DateTime.now.to_s[0,10]}", "c2" => "Tel.: #{@telefon}", "c3" => "" },
416
+ ]
417
+ table.column_order = ["c1", "c2", "c3"]
418
+ table.width = @pdf_table_width
419
+ table.shade_rows = :none
420
+ table.show_headings = false
421
+ table.row_gap = 1
422
+ table.render_on(pdf)
423
+
424
+ pdf.text "Aktuelles", :font_size => @pdf_h1
425
+
426
+ table2 = PDF::SimpleTable.new
427
+ table2.data = [
428
+ { "c1" => "bevorzugter Einsatzort", "c2" => "#{@einsatzort}" },
429
+ { "c1" => "Stundensatz", "c2" => "#{@stundensatz}" },
430
+ { "c1" => "Stand: #{DateTime.now.to_s[0,10]}", "c2" => "Tel.: #{@telefon}", "c3" => "" },
431
+ ]
432
+ tmpl = TemplateText.new <<END
433
+
434
+
435
+ #{dokument_source}
436
+
437
+ <p>
438
+ <TABLE BORDER="1" WIDTH="100%" cellpadding="5">
439
+ <TR>
440
+ <TD valign="top">
441
+ <B>Profil</B> von<BR>
442
+ #{@firstname} #{@lastname}<br>
443
+ Stand: #{DateTime.now.to_s[0,10]}<br>
444
+ </TD>
445
+ <TD>
446
+ #{@adresse}<br>
447
+ #{@plz} #{@ort}<br>
448
+ Tel.: #{@telefon}<BR>
449
+ </TD>
450
+ <TD valign="top">
451
+ mobile: #{@mobil}<BR>
452
+ email: <a href="mailto:#{@email}">#{@email}</a><BR>
453
+
454
+ </TD>
455
+ </TR>
456
+ </TABLE>
457
+
458
+ #{links_as_string}
459
+ <hr>
460
+
461
+ <H1>Aktuelles</H1>
462
+
463
+ #{verfuegbarkeit}
464
+
465
+ <p>
466
+
467
+ <TABLE border="1" cellspacing="0" cellpadding="4">
468
+ <TR>
469
+ <TD >
470
+ <B>
471
+ bevorzugter Einsatzort:
472
+ </B>
473
+ </TD>
474
+ <TD >
475
+ #{@einsatzort}
476
+ </TD>
477
+ </TR>
478
+ <TR>
479
+ <TD >
480
+ <B>
481
+ Stundensatz:
482
+ </B>
483
+ </TD>
484
+ <TD >
485
+ <!-- 70 &#8364;/h zuz&uuml;gl. MwSt.
486
+ -->
487
+ #{@stundensatz}
229
488
  </TD>
230
489
 
231
490
  </TR>
@@ -326,7 +585,30 @@ END
326
585
  puts "</table>" if mode == :html
327
586
  end
328
587
 
588
+ def output_projects_pdf (pdf,order)
589
+ table = PDF::SimpleTable.new
590
+ table.data = []
591
+ pdf.text "Projekte", :font_size => @pdf_h1
592
+ pdf.text "", :font_size => @pdf_h1
593
+
594
+ if order == :newest_first
595
+ @projectlist.sort.reverse.each {|project|
596
+ project.output_pdf(table)
597
+ }
598
+ else
599
+ @projectlist.sort.each {|project|
600
+ project.output_pdf(table)
601
+ }
602
+ end
603
+ table.column_order = ["Branche", "Beschreibung", "Dauer", "zuletzt"]
604
+ table.width = @pdf_table_width
605
+ #table.shade_rows = :none
606
+ #table.show_headings = false
607
+ #table.row_gap = 1
608
+ table.render_on(pdf)
609
+ end
329
610
 
611
+
330
612
  def output_category (category, mode)
331
613
  array1 = []
332
614
  category[1].sort.each {|tool|
@@ -365,7 +647,65 @@ END
365
647
  #tmpl.expand(STDOUT, data)
366
648
  tmpl.expand($stdout, data)
367
649
  #f = File.open("hula#{cate[0]}.html","w")
368
- end
650
+ end # output_category
651
+
652
+ def output_category_pdf (pdf, category)
653
+ #array1 = []
654
+ table = PDF::SimpleTable.new
655
+ table.data = []
656
+ category[1].sort.each {|tool|
657
+ #monate = total_for(tool)
658
+ monate = tool.total_for
659
+ #print "ingesamt #{tool.name}: "+monate.to_s+" Monate"
660
+ #if monate > 12
661
+ #print "\t(> "+jahre(monate).to_s+" Jahre)"
662
+ #end
663
+ #puts " zuletzt "+projectlist.last_used(tool)
664
+ #array1 << { :name=>tool.name, :dauer=>human_months(monate), :zuletzt=>last_used(tool) }
665
+ #array1 << { :name=>tool.name, :dauer=>human_months(monate), :zuletzt=>tool.last_used }
666
+ table.data.push({ "Name" => tool.name, "Dauer" => human_months(monate), "zuletzt" => tool.last_used })
667
+ }
668
+ #######################################
669
+ pdf.text "#{category[0]}", :font_size => @pdf_h1
670
+ pdf.text "", :font_size => @pdf_h1
671
+ tmpl = TemplateText.new <<END
672
+ <a name="anchor_#{category[0].gsub(/ /,'_')}">
673
+ <h1>#{category[0]}</h1>
674
+ <table border="1" width="100%" cellpadding="5">
675
+ <tr>
676
+ <th>Name</th>
677
+ <th>Dauer</th>
678
+ <th>zuletzt</th>
679
+ </tr>
680
+ <tr id=table1>
681
+ <td id="name">
682
+ <td id="dauer">
683
+ <td id="zuletzt" align="right">
684
+ </tr>
685
+ </table>
686
+ END
687
+
688
+ #data = {
689
+ #:table1=>array1
690
+ #}
691
+ tmpl.prettyprint = true
692
+ #tmpl.expand(STDOUT, data)
693
+ #tmpl.expand($stdout, data)
694
+ #f = File.open("hula#{cate[0]}.html","w")
695
+ #######################################################
696
+ #table.data = [
697
+ #{ "c1" => "Profil von", "c2" => "#{adresse}", "c3" => "mobil: #{@mobil}" },
698
+ #{ "c1" => "#{firstname} #{lastname}", "c2" => "#{@plz} #{ort}", "c3" => "eMail:. #{@email}" },
699
+ #{ "c1" => "Stand: #{DateTime.now.to_s[0,10]}", "c2" => "Tel.: #{@telefon}", "c3" => "" },
700
+ #]
701
+ table.column_order = ["Name", "Dauer", "zuletzt"]
702
+ table.width = @pdf_table_width
703
+ table.shade_rows = :none
704
+ #table.show_headings = false
705
+ table.row_gap = 1
706
+ table.render_on(pdf)
707
+ #######################################################
708
+ end # output_category_pdf
369
709
 
370
710
  def output_sonstiges(mode)
371
711
  # array1 = []
@@ -73,6 +73,10 @@ class Project
73
73
  end
74
74
  end
75
75
 
76
+ def output_pdf(table)
77
+ table.data.push({ "Branche" => @branche, "Beschreibung" => @beschreibung, "Dauer" => "#{human_months(self.monate)}", "zuletzt" => "#{monatsbezeichnung(@bis_jahr,@bis_monat)}" })
78
+ end
79
+
76
80
  def von(monat,jahr)
77
81
  @von_monat = monat
78
82
  @von_jahr = jahr
@@ -102,6 +102,17 @@ sonstige Kenntnisse, die vorhanden sind, aber nicht speziellen Projekten zugeord
102
102
  <li>Extreme Programming</li>
103
103
  </ul>
104
104
  END
105
+ thomas.einsatzort = "Raum Berlin"
106
+ thomas.stundensatz = "150 Euro"
107
+
108
+ # Stylesheet-Links in diesem Format
109
+ # man kann diese Zuweisung ganz weglassen, in diesem Fall wird das Standard-Layout verwendet oder
110
+ # diese Zuweisung kann aus einem oder mehreren Link-Zeilen bestehen
111
+ #thomas.stylesheet_text=<<END
112
+ #<link rel="stylesheet" type="text/css" media="screen, projection" href="slashdot.css">
113
+ #<link rel="stylesheet" type="text/css" media="screen, projection" href="slashdot.css">
114
+ #<link rel="stylesheet" type="text/css" media="screen, projection" href="slashdot.css">
115
+ #END
105
116
 
106
117
  # ProjectList ist ein Container fuer saemtliche Projekte dieser Person
107
118
  projectlist = ProjectList.new(thomas)
@@ -552,7 +563,9 @@ Datenbank Oracle 7.x.x, Shell-Scripts, awk, Python. - Realisierung von Batchprog
552
563
  # Ausgabe im Format HTML, Sortierung: neuestes Projekt zuerst, Verfuegbarkeit wird weggelassen
553
564
  # die Ausgabe erfolgt auf die Standand-Ausgabe und mu� mit >"dateiname.html" in die richtige
554
565
  # html-Datei umgelenkt werden.
555
- thomas.write(mode=:html,order=:newest_first)
566
+ #thomas.write(mode=:html,order=:newest_first)
567
+ thomas.write(order=:newest_first)
568
+ #thomas.write(mode=:pdf)
556
569
 
557
570
  # Ausgabe zur�cksetzen
558
571
  $stdout = STDOUT