ical_punch 1.0.1 → 1.1.0
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.
- data/VERSION +1 -1
- data/bin/ical_punch +16 -9
- data/ical_punch.gemspec +2 -2
- data/lib/ical_punch.rb +8 -2
- metadata +3 -3
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            1.0 | 
| 1 | 
            +
            1.1.0
         | 
    
        data/bin/ical_punch
    CHANGED
    
    | @@ -18,16 +18,8 @@ BANNER | |
| 18 18 | 
             
              opts.separator ''
         | 
| 19 19 | 
             
              opts.on('-v', '--version',
         | 
| 20 20 | 
             
                      "Show the #{File.basename($0)} version number and exit") { puts "#{File.basename($0)} #{Punch.verson}"; exit  }
         | 
| 21 | 
            -
              # opts.on('--after [TIME]', String,
         | 
| 22 | 
            -
              #         "Restrict command to only after the given time") { |time|  OPTIONS[:after] = Time.parse(time) }
         | 
| 23 | 
            -
              # opts.on('--before [TIME]', String,
         | 
| 24 | 
            -
              #         "Restrict command to only before the given time") { |time|  OPTIONS[:before] = Time.parse(time) }
         | 
| 25 | 
            -
              # opts.on('--at [TIME]', '--time [TIME]', String,
         | 
| 26 | 
            -
              #         "Use the given time to punch in/out") { |time|  OPTIONS[:time] = Time.parse(time) }
         | 
| 27 | 
            -
              # opts.on('-m', '--message [MESSAGE]', String,
         | 
| 28 | 
            -
              #         "Add the given log message when punching in/out") { |message|  OPTIONS[:message] = message }
         | 
| 29 21 | 
             
              opts.on('-f', '--file [FILE_NAME]', String,
         | 
| 30 | 
            -
                        "File name of the you want to output to") {| | 
| 22 | 
            +
                        "File name of the you want to output to") {|file_name| OPTIONS[:file_name] = file_name}
         | 
| 31 23 | 
             
              opts.on("-h", "--help",
         | 
| 32 24 | 
             
                      "Show this help message.") { puts opts; exit }
         | 
| 33 25 | 
             
              opts.parse!(ARGV)
         | 
| @@ -55,7 +47,22 @@ commands = { | |
| 55 47 | 
             
                else
         | 
| 56 48 | 
             
                  IcalPunch.to_ical(project)
         | 
| 57 49 | 
             
                end
         | 
| 50 | 
            +
              end,
         | 
| 51 | 
            +
              'from_ical' => lambda do |project|
         | 
| 52 | 
            +
                if OPTIONS[:file_name] && OPTIONS[:file_name].size > 0
         | 
| 53 | 
            +
                  IcalPunch.load(OPTIONS[:file_name])
         | 
| 54 | 
            +
                  IcalPunch.from_ical(project)
         | 
| 55 | 
            +
                  IcalPunch.calendars_to_punch
         | 
| 56 | 
            +
                  IcalPunch.write(OPTIONS[:file_name])
         | 
| 57 | 
            +
                else
         | 
| 58 | 
            +
                  IcalPunch.load
         | 
| 59 | 
            +
                  IcalPunch.from_ical(project)
         | 
| 60 | 
            +
                  IcalPunch.calendars_to_punch
         | 
| 61 | 
            +
                  IcalPunch.write()
         | 
| 62 | 
            +
                end
         | 
| 58 63 | 
             
              end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
             | 
| 59 66 | 
             
              # 'status' => lambda do |project|
         | 
| 60 67 | 
             
              #   result = Punch.status(project)
         | 
| 61 68 | 
             
              #   if project
         | 
    
        data/ical_punch.gemspec
    CHANGED
    
    | @@ -5,11 +5,11 @@ | |
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |s|
         | 
| 7 7 | 
             
              s.name = %q{ical_punch}
         | 
| 8 | 
            -
              s.version = "1.0 | 
| 8 | 
            +
              s.version = "1.1.0"
         | 
| 9 9 |  | 
| 10 10 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 11 | 
             
              s.authors = ["Rob Kaufman"]
         | 
| 12 | 
            -
              s.date = %q{2010- | 
| 12 | 
            +
              s.date = %q{2010-07-06}
         | 
| 13 13 | 
             
              s.default_executable = %q{ical_punch}
         | 
| 14 14 | 
             
              s.description = %q{ical_punch converts between iCalendar files and the punch.yml format}
         | 
| 15 15 | 
             
              s.email = %q{rob@notch8.com}
         | 
    
        data/lib/ical_punch.rb
    CHANGED
    
    | @@ -86,9 +86,14 @@ module IcalPunch | |
| 86 86 | 
             
                def calendars_to_punch
         | 
| 87 87 | 
             
                  @data = {}
         | 
| 88 88 | 
             
                  @calendars.each do |calendar|
         | 
| 89 | 
            -
                    key = calendar. | 
| 89 | 
            +
                    key = calendar.events.first.summary
         | 
| 90 90 | 
             
                    @data[key] = calendar.events.collect do |event|
         | 
| 91 | 
            -
                       | 
| 91 | 
            +
                      if event.description.nil?
         | 
| 92 | 
            +
                        description = ["punch in @ #{event.dtstart}", "punch out @ #{event.dtend}"]
         | 
| 93 | 
            +
                      else
         | 
| 94 | 
            +
                        description = event.description.split("\n")
         | 
| 95 | 
            +
                      end
         | 
| 96 | 
            +
                      {"out" => event.dtend, "in" => event.dtstart, "total" => nil, "log" => description}
         | 
| 92 97 | 
             
                    end
         | 
| 93 98 | 
             
                  end
         | 
| 94 99 | 
             
                  return @data
         | 
| @@ -114,6 +119,7 @@ module IcalPunch | |
| 114 119 | 
             
                    @calendars = Icalendar.parse(file)
         | 
| 115 120 | 
             
                  end
         | 
| 116 121 | 
             
                end
         | 
| 122 | 
            +
                
         | 
| 117 123 | 
             
              end
         | 
| 118 124 |  | 
| 119 125 |  | 
    
        metadata
    CHANGED
    
    | @@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version | |
| 4 4 | 
             
              prerelease: false
         | 
| 5 5 | 
             
              segments: 
         | 
| 6 6 | 
             
              - 1
         | 
| 7 | 
            -
              - 0
         | 
| 8 7 | 
             
              - 1
         | 
| 9 | 
            -
               | 
| 8 | 
            +
              - 0
         | 
| 9 | 
            +
              version: 1.1.0
         | 
| 10 10 | 
             
            platform: ruby
         | 
| 11 11 | 
             
            authors: 
         | 
| 12 12 | 
             
            - Rob Kaufman
         | 
| @@ -14,7 +14,7 @@ autorequire: | |
| 14 14 | 
             
            bindir: bin
         | 
| 15 15 | 
             
            cert_chain: []
         | 
| 16 16 |  | 
| 17 | 
            -
            date: 2010- | 
| 17 | 
            +
            date: 2010-07-06 00:00:00 -07:00
         | 
| 18 18 | 
             
            default_executable: ical_punch
         | 
| 19 19 | 
             
            dependencies: 
         | 
| 20 20 | 
             
            - !ruby/object:Gem::Dependency 
         |