berichtsheft 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/README.md +36 -18
- data/Rakefile +7 -0
- data/berichtsheft.gemspec +13 -14
- data/lib/berichtsheft.rb +47 -5
- data/lib/berichtsheft/activities.rb +19 -19
- data/lib/berichtsheft/document.rb +34 -34
- data/lib/berichtsheft/employee.rb +5 -7
- data/lib/berichtsheft/parser.rb +28 -19
- data/lib/berichtsheft/version.rb +1 -1
- data/test/helper.rb +15 -0
- data/test/test_employee.rb +19 -0
- data/test/test_settings.rb +23 -0
- metadata +8 -24
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: b7c39f79323197b3be83526974cb624730e97151
         | 
| 4 | 
            +
              data.tar.gz: 70e8c3659bcdc9de3d93bfacf94fdd27ade71fb4
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 8657a1591a8d6755bef43825652b347d61c05fdd6bde2d337074cbddc17baf2f5f0f0cbc00874814e1e2b1bfff0fcaae43d83cce971539626dc2e67bcf1f9b7d
         | 
| 7 | 
            +
              data.tar.gz: 0e7b9d82b6d0a57fe9a8340a2849c6d189111c155f909c0643bed4c8727632ca02bed4de78c2b050cba4962a24a9c9228b6cebeafe7375b02fc9d90122ee1f5b
         | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -1,34 +1,52 @@ | |
| 1 1 | 
             
            Berichtsheft
         | 
| 2 2 | 
             
            ============
         | 
| 3 3 |  | 
| 4 | 
            -
            Berichtsheft is a ruby library that helps apprentices working in Germany  | 
| 5 | 
            -
             | 
| 4 | 
            +
            Berichtsheft is a ruby library that helps apprentices working in Germany create
         | 
| 5 | 
            +
            weekly reports. The default document template has been approved by
         | 
| 6 6 | 
             
            [IHK München / Oberbayern](https://www.muenchen.ihk.de/).
         | 
| 7 7 |  | 
| 8 8 | 
             
            ## Installation
         | 
| 9 | 
            -
             | 
| 9 | 
            +
            You need a working Ruby installation (2.1.1 or higher) to use this library. I
         | 
| 10 | 
            +
            recommend using rvm to set up your environment. This way you can ride with multiple
         | 
| 11 | 
            +
            Ruby versions installed on your machine. Also one of rvm's benefits is, that
         | 
| 12 | 
            +
            it installs everything into your home folder, so you won't have to mess around
         | 
| 13 | 
            +
            with sudo or your systems Ruby installation.
         | 
| 10 14 |  | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
            # id_for_week is a natural number that represents the workweek.
         | 
| 17 | 
            -
            # The second argument is the file path where the generated documents are saved.
         | 
| 18 | 
            -
            settings = Berichtsheft::Settings.new(id_for_week, '/path/to/file/')
         | 
| 15 | 
            +
            To set up rvm on a unix machine, open your terminal and type:
         | 
| 16 | 
            +
            ```
         | 
| 17 | 
            +
            $ \curl -sSL https://get.rvm.io | bash -s stable --ruby
         | 
| 18 | 
            +
            ```
         | 
| 19 | 
            +
            This command will also install the current stable release of Ruby.
         | 
| 19 20 |  | 
| 20 | 
            -
             | 
| 21 | 
            +
            You can verify that the installation was successful with:
         | 
| 22 | 
            +
            ```
         | 
| 23 | 
            +
            $ which ruby
         | 
| 24 | 
            +
            ```
         | 
| 25 | 
            +
            This should display the location of your current ruby installation.
         | 
| 21 26 |  | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 27 | 
            +
            After setting everything up, installing the berichtsheft gem is just simple as this:
         | 
| 28 | 
            +
            ```
         | 
| 29 | 
            +
            $ gem install berichtsheft
         | 
| 30 | 
            +
            ```
         | 
| 25 31 |  | 
| 26 | 
            -
             | 
| 32 | 
            +
            Done :)
         | 
| 27 33 |  | 
| 28 | 
            -
             | 
| 34 | 
            +
            ## Usage
         | 
| 29 35 |  | 
| 30 | 
            -
             | 
| 36 | 
            +
            ```ruby
         | 
| 37 | 
            +
            require 'berichtsheft'
         | 
| 31 38 |  | 
| 39 | 
            +
            weekly = Berichtsheft::Weekly.new(
         | 
| 40 | 
            +
              :csv_file => "~/berichtsheft/activities.csv",
         | 
| 41 | 
            +
              :save_to => "~/berichtsheft/documents/",
         | 
| 42 | 
            +
              :first_name => "Erkan",
         | 
| 43 | 
            +
              :last_name => "Alles",
         | 
| 44 | 
            +
              :department => "Wunderwerk",
         | 
| 45 | 
            +
              :id_for_week => 1,
         | 
| 46 | 
            +
              :template => "ihk_muenchen"
         | 
| 47 | 
            +
            )
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            weekly.generate
         | 
| 32 50 | 
             
            ```
         | 
| 33 51 |  | 
| 34 52 | 
             
            ## Contact
         | 
    
        data/Rakefile
    ADDED
    
    
    
        data/berichtsheft.gemspec
    CHANGED
    
    | @@ -1,21 +1,20 @@ | |
| 1 | 
            -
            # -*- encodingL utf-8 -*-
         | 
| 2 | 
            -
            lib = File.expand_path( | 
| 1 | 
            +
            `git ls-files`.split("\n") - %w[.gitignore]# -*- encodingL utf-8 -*-
         | 
| 2 | 
            +
            lib = File.expand_path("../lib", __FILE__)
         | 
| 3 3 | 
             
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            -
            require  | 
| 4 | 
            +
            require "berichtsheft/version"
         | 
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |s|
         | 
| 7 | 
            -
              s.name        =  | 
| 7 | 
            +
              s.name        = "berichtsheft"
         | 
| 8 8 | 
             
              s.version     = Berichtsheft::VERSION
         | 
| 9 | 
            -
              s.licenses    = [ | 
| 10 | 
            -
              s.summary     =  | 
| 11 | 
            -
              s.description =  | 
| 12 | 
            -
                               | 
| 13 | 
            -
              s.authors     = [ | 
| 14 | 
            -
              s.email       =  | 
| 9 | 
            +
              s.licenses    = ["GPLv3"]
         | 
| 10 | 
            +
              s.summary     = "Create weekly reports"
         | 
| 11 | 
            +
              s.description = "Berichtsheft is a ruby library that helps apprentices r" \
         | 
| 12 | 
            +
                              "working in Germany create weekly reports."
         | 
| 13 | 
            +
              s.authors     = ["Volkan Edis"]
         | 
| 14 | 
            +
              s.email       = "mail@vedis.io"
         | 
| 15 15 | 
             
              s.files       = `git ls-files`.split("\n") - %w[.gitignore]
         | 
| 16 | 
            -
              s.homepage    =  | 
| 16 | 
            +
              s.homepage    = "https://github.com/vedis/berichtsheft"
         | 
| 17 17 |  | 
| 18 | 
            -
              s.required_ruby_version =  | 
| 19 | 
            -
              s.add_dependency( | 
| 20 | 
            -
              s.add_development_dependency('rspec', '~> 2.14', '>= 2.14.1')
         | 
| 18 | 
            +
              s.required_ruby_version = ">= 2.1.1"
         | 
| 19 | 
            +
              s.add_dependency("prawn", "~> 1.0", ">= 1.0.0")
         | 
| 21 20 | 
             
            end
         | 
    
        data/lib/berichtsheft.rb
    CHANGED
    
    | @@ -1,5 +1,47 @@ | |
| 1 | 
            -
            require_relative  | 
| 2 | 
            -
            require_relative  | 
| 3 | 
            -
            require_relative  | 
| 4 | 
            -
            require_relative  | 
| 5 | 
            -
            require_relative  | 
| 1 | 
            +
            require_relative "berichtsheft/settings"
         | 
| 2 | 
            +
            require_relative "berichtsheft/employee"
         | 
| 3 | 
            +
            require_relative "berichtsheft/parser"
         | 
| 4 | 
            +
            require_relative "berichtsheft/activities"
         | 
| 5 | 
            +
            require_relative "berichtsheft/document"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            module Berichtsheft
         | 
| 8 | 
            +
              class Weekly
         | 
| 9 | 
            +
                def initialize(args)
         | 
| 10 | 
            +
                  @csv_file = args[:csv_file]
         | 
| 11 | 
            +
                  @save_to = args[:save_to]
         | 
| 12 | 
            +
                  @first_name = args[:first_name]
         | 
| 13 | 
            +
                  @last_name = args[:last_name]
         | 
| 14 | 
            +
                  @department = args[:department]
         | 
| 15 | 
            +
                  @id_for_week = args[:id_for_week]
         | 
| 16 | 
            +
                  @template = args[:template]
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                def settings
         | 
| 20 | 
            +
                  Berichtsheft::Settings.new(@id_for_week, @save_to)
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                def employee
         | 
| 24 | 
            +
                  Berichtsheft::Employee.new(
         | 
| 25 | 
            +
                    :first_name => @first_name,
         | 
| 26 | 
            +
                    :last_name => @last_name,
         | 
| 27 | 
            +
                    :department => @department
         | 
| 28 | 
            +
                  )
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                def parser
         | 
| 32 | 
            +
                  Berichtsheft::CSVParser.new(@csv_file)
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                def activities
         | 
| 36 | 
            +
                  Berichtsheft::Activities.new(parser.data, @id_for_week)
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                def document
         | 
| 40 | 
            +
                  Berichtsheft::Document.new(employee, activities, settings)
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                def generate
         | 
| 44 | 
            +
                  document.generate
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
              end
         | 
| 47 | 
            +
            end
         | 
| @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            require  | 
| 1 | 
            +
            require "date"
         | 
| 2 2 |  | 
| 3 3 | 
             
            module Berichtsheft
         | 
| 4 4 | 
             
              # Holds information for activities in an array of hashes.
         | 
| @@ -14,7 +14,7 @@ module Berichtsheft | |
| 14 14 | 
             
                def for_week(data, id_for_week)
         | 
| 15 15 | 
             
                  activities_for_week = []
         | 
| 16 16 | 
             
                  data.each do |activity|
         | 
| 17 | 
            -
                    if id_for_week == activity[ | 
| 17 | 
            +
                    if id_for_week == activity["id_for_week"]
         | 
| 18 18 | 
             
                      activities_for_week.push(activity)
         | 
| 19 19 | 
             
                    end
         | 
| 20 20 | 
             
                  end
         | 
| @@ -23,12 +23,12 @@ module Berichtsheft | |
| 23 23 | 
             
                end
         | 
| 24 24 |  | 
| 25 25 | 
             
                def start_date
         | 
| 26 | 
            -
                  format_date(@all[0][ | 
| 26 | 
            +
                  format_date(@all[0]["date"])
         | 
| 27 27 | 
             
                end
         | 
| 28 28 |  | 
| 29 29 | 
             
                def end_date
         | 
| 30 30 | 
             
                  last_entry = @all.count - 1
         | 
| 31 | 
            -
                  format_date(@all[last_entry][ | 
| 31 | 
            +
                  format_date(@all[last_entry]["date"])
         | 
| 32 32 | 
             
                end
         | 
| 33 33 |  | 
| 34 34 | 
             
                def format_date(date)
         | 
| @@ -42,7 +42,7 @@ module Berichtsheft | |
| 42 42 | 
             
                  monday = []
         | 
| 43 43 |  | 
| 44 44 | 
             
                  @all.each do |entry|
         | 
| 45 | 
            -
                    if Date.parse(entry[ | 
| 45 | 
            +
                    if Date.parse(entry["date"]).monday?
         | 
| 46 46 | 
             
                      monday.push(entry)
         | 
| 47 47 | 
             
                    end
         | 
| 48 48 | 
             
                  end
         | 
| @@ -54,7 +54,7 @@ module Berichtsheft | |
| 54 54 | 
             
                  tuesday = []
         | 
| 55 55 |  | 
| 56 56 | 
             
                  @all.each do |entry|
         | 
| 57 | 
            -
                    if Date.parse(entry[ | 
| 57 | 
            +
                    if Date.parse(entry["date"]).tuesday?
         | 
| 58 58 | 
             
                      tuesday.push(entry)
         | 
| 59 59 | 
             
                    end
         | 
| 60 60 | 
             
                  end
         | 
| @@ -66,7 +66,7 @@ module Berichtsheft | |
| 66 66 | 
             
                  wednesday = []
         | 
| 67 67 |  | 
| 68 68 | 
             
                  @all.each do |entry|
         | 
| 69 | 
            -
                    if Date.parse(entry[ | 
| 69 | 
            +
                    if Date.parse(entry["date"]).wednesday?
         | 
| 70 70 | 
             
                      wednesday.push(entry)
         | 
| 71 71 | 
             
                    end
         | 
| 72 72 | 
             
                  end
         | 
| @@ -78,7 +78,7 @@ module Berichtsheft | |
| 78 78 | 
             
                  thursday = []
         | 
| 79 79 |  | 
| 80 80 | 
             
                  @all.each do |entry|
         | 
| 81 | 
            -
                    if Date.parse(entry[ | 
| 81 | 
            +
                    if Date.parse(entry["date"]).thursday?
         | 
| 82 82 | 
             
                      thursday.push(entry)
         | 
| 83 83 | 
             
                    end
         | 
| 84 84 | 
             
                  end
         | 
| @@ -90,7 +90,7 @@ module Berichtsheft | |
| 90 90 | 
             
                  friday = []
         | 
| 91 91 |  | 
| 92 92 | 
             
                  @all.each do |entry|
         | 
| 93 | 
            -
                    if Date.parse(entry[ | 
| 93 | 
            +
                    if Date.parse(entry["date"]).friday?
         | 
| 94 94 | 
             
                      friday.push(entry)
         | 
| 95 95 | 
             
                    end
         | 
| 96 96 | 
             
                  end
         | 
| @@ -102,55 +102,55 @@ module Berichtsheft | |
| 102 102 | 
             
                  if for_monday
         | 
| 103 103 | 
             
                    time = 0
         | 
| 104 104 | 
             
                    for_monday.each do |activity|
         | 
| 105 | 
            -
                      time += convert_string_to_time(activity[ | 
| 105 | 
            +
                      time += convert_string_to_time(activity["duration"])
         | 
| 106 106 | 
             
                    end
         | 
| 107 107 | 
             
                  end
         | 
| 108 108 |  | 
| 109 | 
            -
                  Time.at(time).utc.strftime( | 
| 109 | 
            +
                  Time.at(time).utc.strftime("%H:%M")
         | 
| 110 110 | 
             
                end
         | 
| 111 111 |  | 
| 112 112 | 
             
                def total_time_tuesday
         | 
| 113 113 | 
             
                  if for_tuesday
         | 
| 114 114 | 
             
                    time = 0
         | 
| 115 115 | 
             
                    for_tuesday.each do |activity|
         | 
| 116 | 
            -
                      time += convert_string_to_time(activity[ | 
| 116 | 
            +
                      time += convert_string_to_time(activity["duration"])
         | 
| 117 117 | 
             
                    end
         | 
| 118 118 | 
             
                  end
         | 
| 119 119 |  | 
| 120 | 
            -
                  Time.at(time).utc.strftime( | 
| 120 | 
            +
                  Time.at(time).utc.strftime("%H:%M")
         | 
| 121 121 | 
             
                end
         | 
| 122 122 |  | 
| 123 123 | 
             
                def total_time_wednesday
         | 
| 124 124 | 
             
                  if for_wednesday
         | 
| 125 125 | 
             
                    time = 0
         | 
| 126 126 | 
             
                    for_wednesday.each do |activity|
         | 
| 127 | 
            -
                      time += convert_string_to_time(activity[ | 
| 127 | 
            +
                      time += convert_string_to_time(activity["duration"])
         | 
| 128 128 | 
             
                    end
         | 
| 129 129 | 
             
                  end
         | 
| 130 130 |  | 
| 131 | 
            -
                  Time.at(time).utc.strftime( | 
| 131 | 
            +
                  Time.at(time).utc.strftime("%H:%M")
         | 
| 132 132 | 
             
                end
         | 
| 133 133 |  | 
| 134 134 | 
             
                def total_time_thursday
         | 
| 135 135 | 
             
                  if for_thursday
         | 
| 136 136 | 
             
                    time = 0
         | 
| 137 137 | 
             
                    for_thursday.each do |activity|
         | 
| 138 | 
            -
                      time += convert_string_to_time(activity[ | 
| 138 | 
            +
                      time += convert_string_to_time(activity["duration"])
         | 
| 139 139 | 
             
                    end
         | 
| 140 140 | 
             
                  end
         | 
| 141 141 |  | 
| 142 | 
            -
                  Time.at(time).utc.strftime( | 
| 142 | 
            +
                  Time.at(time).utc.strftime("%H:%M")
         | 
| 143 143 | 
             
                end
         | 
| 144 144 |  | 
| 145 145 | 
             
                def total_time_friday
         | 
| 146 146 | 
             
                  if for_friday
         | 
| 147 147 | 
             
                    time = 0
         | 
| 148 148 | 
             
                    for_friday.each do |activity|
         | 
| 149 | 
            -
                      time += convert_string_to_time(activity[ | 
| 149 | 
            +
                      time += convert_string_to_time(activity["duration"])
         | 
| 150 150 | 
             
                    end
         | 
| 151 151 | 
             
                  end
         | 
| 152 152 |  | 
| 153 | 
            -
                  Time.at(time).utc.strftime( | 
| 153 | 
            +
                  Time.at(time).utc.strftime("%H:%M")
         | 
| 154 154 | 
             
                end
         | 
| 155 155 |  | 
| 156 156 | 
             
                def convert_string_to_time(time)
         | 
| @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            require  | 
| 1 | 
            +
            require "prawn"
         | 
| 2 2 |  | 
| 3 3 | 
             
            module Berichtsheft
         | 
| 4 4 | 
             
              # Implements the default document template for weekly reports.
         | 
| @@ -16,11 +16,11 @@ module Berichtsheft | |
| 16 16 | 
             
                  pdf.define_grid(columns: 3, rows: 9, gutter: 5)
         | 
| 17 17 |  | 
| 18 18 | 
             
                  pdf.grid(0, 0).bounding_box do
         | 
| 19 | 
            -
                    pdf.text  | 
| 19 | 
            +
                    pdf.text "<b>Name und Vorname: </b>", inline_format: true
         | 
| 20 20 | 
             
                    pdf.move_down 5
         | 
| 21 | 
            -
                    pdf.text  | 
| 21 | 
            +
                    pdf.text "<b>Ausbildungsabteilung: </b>", inline_format: true
         | 
| 22 22 | 
             
                    pdf.move_down 5
         | 
| 23 | 
            -
                    pdf.text  | 
| 23 | 
            +
                    pdf.text "<b>Ausbildungsnachweis Nr.: </b>", inline_format: true
         | 
| 24 24 | 
             
                  end
         | 
| 25 25 |  | 
| 26 26 | 
             
                  pdf.grid(0, 1).bounding_box do
         | 
| @@ -43,80 +43,80 @@ module Berichtsheft | |
| 43 43 | 
             
                  pdf.move_down -10
         | 
| 44 44 |  | 
| 45 45 | 
             
                  data = [[
         | 
| 46 | 
            -
                     | 
| 46 | 
            +
                    "Tag", "Ausgeführte Arbeiten", "Einzelstunden", "Gesamtstunden"
         | 
| 47 47 | 
             
                  ]]
         | 
| 48 48 |  | 
| 49 | 
            -
                  activities_for_monday =  | 
| 50 | 
            -
                  time_for_monday =  | 
| 49 | 
            +
                  activities_for_monday = ""
         | 
| 50 | 
            +
                  time_for_monday = ""
         | 
| 51 51 |  | 
| 52 52 | 
             
                  @activities.for_monday.each do |activity|
         | 
| 53 | 
            -
                    activities_for_monday += "#{activity[ | 
| 54 | 
            -
                    time_for_monday += "#{activity[ | 
| 53 | 
            +
                    activities_for_monday += "#{activity["description"]}\n"
         | 
| 54 | 
            +
                    time_for_monday += "#{activity["duration"]}\n"
         | 
| 55 55 | 
             
                  end
         | 
| 56 56 |  | 
| 57 57 | 
             
                  data += [[
         | 
| 58 | 
            -
                     | 
| 58 | 
            +
                    "Mo",
         | 
| 59 59 | 
             
                    activities_for_monday,
         | 
| 60 60 | 
             
                    time_for_monday,
         | 
| 61 61 | 
             
                    @activities.total_time_monday
         | 
| 62 62 | 
             
                    ]]
         | 
| 63 63 |  | 
| 64 64 |  | 
| 65 | 
            -
                  activities_for_tuesday =  | 
| 66 | 
            -
                  time_for_tuesday =  | 
| 65 | 
            +
                  activities_for_tuesday = ""
         | 
| 66 | 
            +
                  time_for_tuesday = ""
         | 
| 67 67 |  | 
| 68 68 | 
             
                  @activities.for_tuesday.each do |activity|
         | 
| 69 | 
            -
                    activities_for_tuesday += "#{activity[ | 
| 70 | 
            -
                    time_for_tuesday += "#{activity[ | 
| 69 | 
            +
                    activities_for_tuesday += "#{activity["description"]}\n"
         | 
| 70 | 
            +
                    time_for_tuesday += "#{activity["duration"]}\n"
         | 
| 71 71 | 
             
                  end
         | 
| 72 72 |  | 
| 73 73 | 
             
                  data += [[
         | 
| 74 | 
            -
                     | 
| 74 | 
            +
                    "Di",
         | 
| 75 75 | 
             
                    activities_for_tuesday,
         | 
| 76 76 | 
             
                    time_for_tuesday,
         | 
| 77 77 | 
             
                    @activities.total_time_tuesday
         | 
| 78 78 | 
             
                    ]]
         | 
| 79 79 |  | 
| 80 | 
            -
                  activities_for_wednesday =  | 
| 81 | 
            -
                  time_for_wednesday =  | 
| 80 | 
            +
                  activities_for_wednesday = ""
         | 
| 81 | 
            +
                  time_for_wednesday = ""
         | 
| 82 82 |  | 
| 83 83 | 
             
                  @activities.for_wednesday.each do |activity|
         | 
| 84 | 
            -
                    activities_for_wednesday += "#{activity[ | 
| 85 | 
            -
                    time_for_wednesday += "#{activity[ | 
| 84 | 
            +
                    activities_for_wednesday += "#{activity["description"]}\n"
         | 
| 85 | 
            +
                    time_for_wednesday += "#{activity["duration"]}\n"
         | 
| 86 86 | 
             
                  end
         | 
| 87 87 |  | 
| 88 88 | 
             
                  data += [[
         | 
| 89 | 
            -
                     | 
| 89 | 
            +
                    "Mi",
         | 
| 90 90 | 
             
                    activities_for_wednesday,
         | 
| 91 91 | 
             
                    time_for_wednesday,
         | 
| 92 92 | 
             
                    @activities.total_time_wednesday
         | 
| 93 93 | 
             
                    ]]
         | 
| 94 94 |  | 
| 95 | 
            -
                  activities_for_thursday =  | 
| 96 | 
            -
                  time_for_thursday =  | 
| 95 | 
            +
                  activities_for_thursday = ""
         | 
| 96 | 
            +
                  time_for_thursday = ""
         | 
| 97 97 |  | 
| 98 98 | 
             
                  @activities.for_thursday.each do |activity|
         | 
| 99 | 
            -
                    activities_for_thursday += "#{activity[ | 
| 100 | 
            -
                    time_for_thursday += "#{activity[ | 
| 99 | 
            +
                    activities_for_thursday += "#{activity["description"]}\n"
         | 
| 100 | 
            +
                    time_for_thursday += "#{activity["duration"]}\n"
         | 
| 101 101 | 
             
                  end
         | 
| 102 102 |  | 
| 103 103 | 
             
                  data += [[
         | 
| 104 | 
            -
                     | 
| 104 | 
            +
                    "Do",
         | 
| 105 105 | 
             
                    activities_for_thursday,
         | 
| 106 106 | 
             
                    time_for_thursday,
         | 
| 107 107 | 
             
                    @activities.total_time_thursday
         | 
| 108 108 | 
             
                    ]]
         | 
| 109 109 |  | 
| 110 | 
            -
                  activities_for_friday =  | 
| 111 | 
            -
                  time_for_friday =  | 
| 110 | 
            +
                  activities_for_friday = ""
         | 
| 111 | 
            +
                  time_for_friday = ""
         | 
| 112 112 |  | 
| 113 113 | 
             
                  @activities.for_friday.each do |activity|
         | 
| 114 | 
            -
                    activities_for_friday += "#{activity[ | 
| 115 | 
            -
                    time_for_friday += "#{activity[ | 
| 114 | 
            +
                    activities_for_friday += "#{activity["description"]}\n"
         | 
| 115 | 
            +
                    time_for_friday += "#{activity["duration"]}\n"
         | 
| 116 116 | 
             
                  end
         | 
| 117 117 |  | 
| 118 118 | 
             
                  data += [[
         | 
| 119 | 
            -
                     | 
| 119 | 
            +
                    "Fr",
         | 
| 120 120 | 
             
                    activities_for_friday,
         | 
| 121 121 | 
             
                    time_for_friday,
         | 
| 122 122 | 
             
                    @activities.total_time_friday
         | 
| @@ -131,20 +131,20 @@ module Berichtsheft | |
| 131 131 |  | 
| 132 132 | 
             
                  pdf.move_down 20
         | 
| 133 133 |  | 
| 134 | 
            -
                  pdf.text  | 
| 135 | 
            -
                  note_field = [[ | 
| 134 | 
            +
                  pdf.text "Bemerkung des Ausbilders/Auszubildenden"
         | 
| 135 | 
            +
                  note_field = [[""]]
         | 
| 136 136 | 
             
                  pdf.table note_field, column_widths: { 0 => 540 } do
         | 
| 137 137 | 
             
                    rows(0).height = 35
         | 
| 138 138 | 
             
                  end
         | 
| 139 139 |  | 
| 140 140 | 
             
                  pdf.move_down 20
         | 
| 141 141 |  | 
| 142 | 
            -
                  footer_data = [[ | 
| 142 | 
            +
                  footer_data = [["", "", "", ""]]
         | 
| 143 143 | 
             
                  footer_data += [[
         | 
| 144 144 | 
             
                    "Auszubildender\nDatum und Unterschrift",
         | 
| 145 145 | 
             
                    "Ausbilder\nDatum und Unterschrift",
         | 
| 146 146 | 
             
                    "Gesetzlicher Vertreter\nDatum und Unterschrift",
         | 
| 147 | 
            -
                     | 
| 147 | 
            +
                    "Bemerkung"
         | 
| 148 148 | 
             
                  ]]
         | 
| 149 149 |  | 
| 150 150 | 
             
                  pdf.table footer_data, column_widths: {
         | 
| @@ -1,14 +1,12 @@ | |
| 1 1 | 
             
            module Berichtsheft
         | 
| 2 2 | 
             
              # Provides user specific information.
         | 
| 3 3 | 
             
              class Employee
         | 
| 4 | 
            -
                 | 
| 5 | 
            -
                attr_accessor :last_name
         | 
| 6 | 
            -
                attr_accessor :department
         | 
| 4 | 
            +
                attr_reader :first_name, :last_name, :department
         | 
| 7 5 |  | 
| 8 | 
            -
                def initialize( | 
| 9 | 
            -
                  @first_name = first_name
         | 
| 10 | 
            -
                  @last_name = last_name
         | 
| 11 | 
            -
                  @department = department
         | 
| 6 | 
            +
                def initialize(args)
         | 
| 7 | 
            +
                  @first_name = args[:first_name]
         | 
| 8 | 
            +
                  @last_name = args[:last_name]
         | 
| 9 | 
            +
                  @department = args[:department]
         | 
| 12 10 | 
             
                end
         | 
| 13 11 | 
             
              end
         | 
| 14 12 | 
             
            end
         | 
    
        data/lib/berichtsheft/parser.rb
    CHANGED
    
    | @@ -1,34 +1,43 @@ | |
| 1 1 | 
             
            module Berichtsheft
         | 
| 2 | 
            -
              # Implements the CSV parser. | 
| 3 | 
            -
              # have to in the following order:
         | 
| 4 | 
            -
              # id_for_week,description_for_activity,date(YYYY-MM-DD),duration
         | 
| 2 | 
            +
              # Implements the CSV parser.
         | 
| 5 3 | 
             
              class CSVParser
         | 
| 6 4 | 
             
                attr_reader :data
         | 
| 7 5 |  | 
| 6 | 
            +
                def initialize(csv_file)
         | 
| 7 | 
            +
                  @data = read_file(csv_file)
         | 
| 8 | 
            +
                end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                def data
         | 
| 11 | 
            +
                  @data
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
             | 
| 8 14 | 
             
                def read_file(csv_file)
         | 
| 9 15 | 
             
                  all_activities = []
         | 
| 10 | 
            -
                  file = File.open(csv_file, 'r')
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                  while (line = file.gets)
         | 
| 13 | 
            -
                    entry = line.force_encoding(Encoding::UTF_8).split(',')
         | 
| 14 | 
            -
                    id_for_week = entry[0]
         | 
| 15 | 
            -
                    description = entry[1]
         | 
| 16 | 
            -
                    date = entry[2]
         | 
| 17 | 
            -
                    duration = entry[3]
         | 
| 18 16 |  | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
                       | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 17 | 
            +
                  begin
         | 
| 18 | 
            +
                    file = File.open(csv_file, "r")
         | 
| 19 | 
            +
                    while line = file.gets
         | 
| 20 | 
            +
                      all_activities.push parse_line(line)
         | 
| 21 | 
            +
                    end
         | 
| 22 | 
            +
                  rescue IOError => e
         | 
| 23 | 
            +
                    puts e
         | 
| 24 | 
            +
                  ensure
         | 
| 25 | 
            +
                    file.close unless file.nil?
         | 
| 25 26 | 
             
                  end
         | 
| 26 27 |  | 
| 27 28 | 
             
                  all_activities
         | 
| 28 29 | 
             
                end
         | 
| 29 30 |  | 
| 30 | 
            -
                 | 
| 31 | 
            -
             | 
| 31 | 
            +
                # Expected values for each line:
         | 
| 32 | 
            +
                # date(YYYY-MM-DD),description,duration(HH-MM),id_for_week
         | 
| 33 | 
            +
                def parse_line(line)
         | 
| 34 | 
            +
                  entity = line.force_encoding(Encoding::UTF_8).split(",")
         | 
| 35 | 
            +
                  Hash[
         | 
| 36 | 
            +
                    "date" => entity[0],
         | 
| 37 | 
            +
                    "description" => entity[1],
         | 
| 38 | 
            +
                    "duration" => entity[2],
         | 
| 39 | 
            +
                    "id_for_week" => entity[3].to_i
         | 
| 40 | 
            +
                  ]
         | 
| 32 41 | 
             
                end
         | 
| 33 42 | 
             
              end
         | 
| 34 43 | 
             
            end
         | 
    
        data/lib/berichtsheft/version.rb
    CHANGED
    
    
    
        data/test/helper.rb
    ADDED
    
    | @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            $:.unshift File.expand_path("../../lib", __FILE__)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require "minitest/autorun"
         | 
| 4 | 
            +
            require "berichtsheft"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            class Berichtsheft::TestCase < MiniTest::Unit::TestCase
         | 
| 7 | 
            +
              def setup
         | 
| 8 | 
            +
                @settings = Berichtsheft::Settings.new(13, "/usr")
         | 
| 9 | 
            +
                @employee = Berichtsheft::Employee.new("John", "Doe", "Wonderland")
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              def teardown
         | 
| 13 | 
            +
                @settings = nil
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            require File.expand_path("../helper", __FILE__)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class TestEmployee < Berichtsheft::TestCase
         | 
| 4 | 
            +
              def test_employee_can_be_created
         | 
| 5 | 
            +
                refute_nil @employee
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              def test_first_name_is_not_nil
         | 
| 9 | 
            +
                refute_nil @employee.first_name
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              def test_last_name_is_not_nil
         | 
| 13 | 
            +
                refute_nil @employee.last_name
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              def test_department_is_not_nil
         | 
| 17 | 
            +
                refute_nil @employee.department
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
            end
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            require File.expand_path("../helper", __FILE__)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class TestSettings < Berichtsheft::TestCase
         | 
| 4 | 
            +
              def test_settings_can_be_created
         | 
| 5 | 
            +
                refute_nil @settings
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              def test_id_for_week_is_not_nil
         | 
| 9 | 
            +
                refute_nil @settings.id_for_week
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              def test_id_for_week_is_a_fixnum
         | 
| 13 | 
            +
                assert_instance_of Fixnum, @settings.id_for_week
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              def test_file_path_is_not_nil
         | 
| 17 | 
            +
                refute_nil @settings.file_path
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              def test_file_path_is_a_directory
         | 
| 21 | 
            +
                assert true, File.directory?(@settings.file_path)
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: berichtsheft
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.5
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Volkan Edis
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014- | 
| 11 | 
            +
            date: 2014-06-08 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: prawn
         | 
| @@ -30,28 +30,8 @@ dependencies: | |
| 30 30 | 
             
                - - ">="
         | 
| 31 31 | 
             
                  - !ruby/object:Gem::Version
         | 
| 32 32 | 
             
                    version: 1.0.0
         | 
| 33 | 
            -
             | 
| 34 | 
            -
               | 
| 35 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 36 | 
            -
                requirements:
         | 
| 37 | 
            -
                - - "~>"
         | 
| 38 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 39 | 
            -
                    version: '2.14'
         | 
| 40 | 
            -
                - - ">="
         | 
| 41 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 42 | 
            -
                    version: 2.14.1
         | 
| 43 | 
            -
              type: :development
         | 
| 44 | 
            -
              prerelease: false
         | 
| 45 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 46 | 
            -
                requirements:
         | 
| 47 | 
            -
                - - "~>"
         | 
| 48 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 49 | 
            -
                    version: '2.14'
         | 
| 50 | 
            -
                - - ">="
         | 
| 51 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 52 | 
            -
                    version: 2.14.1
         | 
| 53 | 
            -
            description: Berichtsheft is a ruby library that helps apprentices working in Germany
         | 
| 54 | 
            -
              to create weekly reports.
         | 
| 33 | 
            +
            description: Berichtsheft is a ruby library that helps apprentices rworking in Germany
         | 
| 34 | 
            +
              create weekly reports.
         | 
| 55 35 | 
             
            email: mail@vedis.io
         | 
| 56 36 | 
             
            executables: []
         | 
| 57 37 | 
             
            extensions: []
         | 
| @@ -60,6 +40,7 @@ files: | |
| 60 40 | 
             
            - Gemfile
         | 
| 61 41 | 
             
            - LICENSE
         | 
| 62 42 | 
             
            - README.md
         | 
| 43 | 
            +
            - Rakefile
         | 
| 63 44 | 
             
            - berichtsheft.gemspec
         | 
| 64 45 | 
             
            - lib/berichtsheft.rb
         | 
| 65 46 | 
             
            - lib/berichtsheft/activities.rb
         | 
| @@ -68,6 +49,9 @@ files: | |
| 68 49 | 
             
            - lib/berichtsheft/parser.rb
         | 
| 69 50 | 
             
            - lib/berichtsheft/settings.rb
         | 
| 70 51 | 
             
            - lib/berichtsheft/version.rb
         | 
| 52 | 
            +
            - test/helper.rb
         | 
| 53 | 
            +
            - test/test_employee.rb
         | 
| 54 | 
            +
            - test/test_settings.rb
         | 
| 71 55 | 
             
            homepage: https://github.com/vedis/berichtsheft
         | 
| 72 56 | 
             
            licenses:
         | 
| 73 57 | 
             
            - GPLv3
         |