clockout 0.5 → 0.5.1
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 +7 -0
 - data/bin/clock +12 -5
 - data/lib/clockout.rb +16 -14
 - data/lib/record.rb +0 -1
 - metadata +12 -19
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 7699cc7de9299eb18655d2f48767232a773519f3
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 33ae0150ea39fbf0df5057f2ecb82582619fb3a7
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: f74da6e936aae0e648d6821be438b3aa0f4738dd6c9419e3e320ffaee8a34e90d0f7e8bbf384a0c3301b4cbdeef6f1ba9fc660d693e6153a32f6d81a6578ca57
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 5bc55a18b4f7211fd1f78b03eb329a075668eeaa2315f52856e53ec7a597f9633f4142b299bfb1dead4b5f2cc7197b5a149c326f9bbfd86ed8d02263063af902
         
     | 
    
        data/bin/clock
    CHANGED
    
    | 
         @@ -162,9 +162,11 @@ if (ARGV[0] == "in" || ARGV[0] == "out") 
     | 
|
| 
       162 
162 
     | 
    
         
             
                    file << "\n#{seek_line}\n#{time_line}" if !mod
         
     | 
| 
       163 
163 
     | 
    
         
             
                end
         
     | 
| 
       164 
164 
     | 
    
         
             
            elsif (ARGV[0] == "last")
         
     | 
| 
       165 
     | 
    
         
            -
                 
     | 
| 
       166 
     | 
    
         
            -
                 
     | 
| 
       167 
     | 
    
         
            -
                 
     | 
| 
      
 165 
     | 
    
         
            +
                #need a decent amount of commits so we can get a good estimation of diffs rate (for pioneer commits), 
         
     | 
| 
      
 166 
     | 
    
         
            +
                #but we don't want the hook to take too long
         
     | 
| 
      
 167 
     | 
    
         
            +
                num = 150
         
     | 
| 
      
 168 
     | 
    
         
            +
                last = Clockout.new(path, nil, num).last
         
     | 
| 
      
 169 
     | 
    
         
            +
                puts "[clockout] ".green + "#{last.minutes.round(2)} minutes logged" if last
         
     | 
| 
       168 
170 
     | 
    
         
             
            else
         
     | 
| 
       169 
171 
     | 
    
         
             
                opts = parse_options(ARGV)
         
     | 
| 
       170 
172 
     | 
    
         | 
| 
         @@ -182,7 +184,7 @@ else 
     | 
|
| 
       182 
184 
     | 
    
         
             
                        end
         
     | 
| 
       183 
185 
     | 
    
         
             
                    elsif opts[:generate] == "hook"
         
     | 
| 
       184 
186 
     | 
    
         
             
                        hook_path = root+"/.git/hooks/post-commit"
         
     | 
| 
       185 
     | 
    
         
            -
                        hook_txt = "#clockout\nclock last 
     | 
| 
      
 187 
     | 
    
         
            +
                        hook_txt = "#clockout\nclock last"
         
     | 
| 
       186 
188 
     | 
    
         
             
                        if File.exist? hook_path
         
     | 
| 
       187 
189 
     | 
    
         
             
                            contents = File.open(hook_path).read
         
     | 
| 
       188 
190 
     | 
    
         
             
                            if (contents[hook_txt])
         
     | 
| 
         @@ -211,7 +213,8 @@ else 
     | 
|
| 
       211 
213 
     | 
    
         
             
                    puts "Showing hours for #{user}"
         
     | 
| 
       212 
214 
     | 
    
         
             
                end
         
     | 
| 
       213 
215 
     | 
    
         | 
| 
       214 
     | 
    
         
            -
                 
     | 
| 
      
 216 
     | 
    
         
            +
                max = 500
         
     | 
| 
      
 217 
     | 
    
         
            +
                clock = Clockout.new(path, user, max)
         
     | 
| 
       215 
218 
     | 
    
         
             
                printer = Printer.new(clock)
         
     | 
| 
       216 
219 
     | 
    
         | 
| 
       217 
220 
     | 
    
         
             
                if (opts[:estimations])
         
     | 
| 
         @@ -219,4 +222,8 @@ else 
     | 
|
| 
       219 
222 
     | 
    
         
             
                else
         
     | 
| 
       220 
223 
     | 
    
         
             
                    printer.print_chart(opts[:condensed])
         
     | 
| 
       221 
224 
     | 
    
         
             
                end
         
     | 
| 
      
 225 
     | 
    
         
            +
             
     | 
| 
      
 226 
     | 
    
         
            +
                if (clock.maxed_out)
         
     | 
| 
      
 227 
     | 
    
         
            +
                    puts "** only showing the #{max} most recent commits **"
         
     | 
| 
      
 228 
     | 
    
         
            +
                end
         
     | 
| 
       222 
229 
     | 
    
         
             
            end
         
     | 
    
        data/lib/clockout.rb
    CHANGED
    
    | 
         @@ -8,13 +8,14 @@ COLS = 80 
     | 
|
| 
       8 
8 
     | 
    
         
             
            DAY_FORMAT = '%B %e, %Y'
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
            class Clockout
         
     | 
| 
       11 
     | 
    
         
            -
                attr_accessor :blocks, :time_per_day
         
     | 
| 
      
 11 
     | 
    
         
            +
                attr_accessor :blocks, :time_per_day, :maxed_out
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
                def commits_to_records(grit_commits)
         
     | 
| 
      
 13 
     | 
    
         
            +
                def commits_to_records(grit_commits, commit_stats)
         
     | 
| 
       14 
14 
     | 
    
         
             
                    my_files = eval($opts[:my_files])
         
     | 
| 
       15 
15 
     | 
    
         
             
                    not_my_files = eval($opts[:not_my_files] || "")
         
     | 
| 
       16 
     | 
    
         
            -
                    grit_commits.map do |commit| 
         
     | 
| 
       17 
     | 
    
         
            -
                        c = Commit.new(commit) 
     | 
| 
      
 16 
     | 
    
         
            +
                    grit_commits.each_with_index.map do |commit, i| 
         
     | 
| 
      
 17 
     | 
    
         
            +
                        c = Commit.new(commit)
         
     | 
| 
      
 18 
     | 
    
         
            +
                        c.stats = commit_stats[i][1]
         
     | 
| 
       18 
19 
     | 
    
         
             
                        c.calculate_diffs(my_files, not_my_files)
         
     | 
| 
       19 
20 
     | 
    
         
             
                        c
         
     | 
| 
       20 
21 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -143,7 +144,7 @@ class Clockout 
     | 
|
| 
       143 
144 
     | 
    
         
             
                        if !first.minutes
         
     | 
| 
       144 
145 
     | 
    
         
             
                            first.estimated = true
         
     | 
| 
       145 
146 
     | 
    
         
             
                            if diffs_per_min.nan? || diffs_per_min.infinite?
         
     | 
| 
       146 
     | 
    
         
            -
                                first.minutes =  
     | 
| 
      
 147 
     | 
    
         
            +
                                first.minutes = first.addition
         
     | 
| 
       147 
148 
     | 
    
         
             
                            else
         
     | 
| 
       148 
149 
     | 
    
         
             
                                first.minutes = first.diffs/diffs_per_min * $opts[:estimation_factor] + first.addition
         
     | 
| 
       149 
150 
     | 
    
         
             
                            end
         
     | 
| 
         @@ -154,13 +155,13 @@ class Clockout 
     | 
|
| 
       154 
155 
     | 
    
         
             
                    blocks
         
     | 
| 
       155 
156 
     | 
    
         
             
                end
         
     | 
| 
       156 
157 
     | 
    
         | 
| 
       157 
     | 
    
         
            -
                def prepare_blocks(commits_in, author)
         
     | 
| 
      
 158 
     | 
    
         
            +
                def prepare_blocks(commits_in, commit_stats, author)
         
     | 
| 
       158 
159 
     | 
    
         
             
                    clockins = $opts[:in] || {}
         
     | 
| 
       159 
160 
     | 
    
         
             
                    clockouts = $opts[:out] || {}
         
     | 
| 
       160 
161 
     | 
    
         | 
| 
       161 
162 
     | 
    
         
             
                    # Convert clock-in/-outs into Clock objs & commits into Commit objs
         
     | 
| 
       162 
163 
     | 
    
         
             
                    clocks = clocks_to_records(clockins, :in) + clocks_to_records(clockouts, :out)
         
     | 
| 
       163 
     | 
    
         
            -
                    commits = commits_to_records(commits_in)
         
     | 
| 
      
 164 
     | 
    
         
            +
                    commits = commits_to_records(commits_in, commit_stats)
         
     | 
| 
       164 
165 
     | 
    
         | 
| 
       165 
166 
     | 
    
         
             
                    # Merge & sort everything by date
         
     | 
| 
       166 
167 
     | 
    
         
             
                    data = (commits + clocks).sort { |a,b| a.date <=> b.date }
         
     | 
| 
         @@ -171,9 +172,8 @@ class Clockout 
     | 
|
| 
       171 
172 
     | 
    
         
             
                    @blocks = run(data)
         
     | 
| 
       172 
173 
     | 
    
         
             
                end
         
     | 
| 
       173 
174 
     | 
    
         | 
| 
       174 
     | 
    
         
            -
                def  
     | 
| 
       175 
     | 
    
         
            -
                     
     | 
| 
       176 
     | 
    
         
            -
                    puts "#{last.minutes.round(2)} minutes logged" if last
         
     | 
| 
      
 175 
     | 
    
         
            +
                def last
         
     | 
| 
      
 176 
     | 
    
         
            +
                    @blocks.last.last
         
     | 
| 
       177 
177 
     | 
    
         
             
                end
         
     | 
| 
       178 
178 
     | 
    
         | 
| 
       179 
179 
     | 
    
         
             
                def self.get_repo(path, original_path = nil)
         
     | 
| 
         @@ -225,7 +225,7 @@ class Clockout 
     | 
|
| 
       225 
225 
     | 
    
         
             
                    root_path
         
     | 
| 
       226 
226 
     | 
    
         
             
                end
         
     | 
| 
       227 
227 
     | 
    
         | 
| 
       228 
     | 
    
         
            -
                def initialize(path = nil, author = nil, num= 
     | 
| 
      
 228 
     | 
    
         
            +
                def initialize(path = nil, author = nil, num = 1)
         
     | 
| 
       229 
229 
     | 
    
         
             
                    @time_per_day = Hash.new(0)
         
     | 
| 
       230 
230 
     | 
    
         | 
| 
       231 
231 
     | 
    
         
             
                    # Default options
         
     | 
| 
         @@ -240,10 +240,12 @@ class Clockout 
     | 
|
| 
       240 
240 
     | 
    
         
             
                        # Merge with config override options
         
     | 
| 
       241 
241 
     | 
    
         
             
                        $opts.merge!(clock_opts) if clock_opts
         
     | 
| 
       242 
242 
     | 
    
         | 
| 
       243 
     | 
    
         
            -
                        commits = repo.commits('master', num)
         
     | 
| 
       244 
     | 
    
         
            -
                         
     | 
| 
      
 243 
     | 
    
         
            +
                        commits = repo.commits('master', num).reverse
         
     | 
| 
      
 244 
     | 
    
         
            +
                        commit_stats = repo.commit_stats('master', num).reverse #much faster if retrieved in batch
         
     | 
| 
      
 245 
     | 
    
         
            +
             
     | 
| 
      
 246 
     | 
    
         
            +
                        @maxed_out = (commits.size == num)
         
     | 
| 
       245 
247 
     | 
    
         | 
| 
       246 
     | 
    
         
            -
                        prepare_blocks(commits, author)
         
     | 
| 
      
 248 
     | 
    
         
            +
                        prepare_blocks(commits, commit_stats, author)
         
     | 
| 
       247 
249 
     | 
    
         
             
                    end
         
     | 
| 
       248 
250 
     | 
    
         
             
                end
         
     | 
| 
       249 
251 
     | 
    
         
             
            end
         
     | 
    
        data/lib/record.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,46 +1,41 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: clockout
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version:  
     | 
| 
       5 
     | 
    
         
            -
              prerelease: 
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.5.1
         
     | 
| 
       6 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       8 
7 
     | 
    
         
             
            - Dan Hassin
         
     | 
| 
       9 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2013-10- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2013-10-14 00:00:00.000000000 Z
         
     | 
| 
       13 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
14 
     | 
    
         
             
              name: grit
         
     | 
| 
       16 
15 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       17 
     | 
    
         
            -
                none: false
         
     | 
| 
       18 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       19 
     | 
    
         
            -
                - -  
     | 
| 
      
 17 
     | 
    
         
            +
                - - '>='
         
     | 
| 
       20 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       21 
19 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       22 
20 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       23 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       24 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       25 
     | 
    
         
            -
                none: false
         
     | 
| 
       26 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
       27 
     | 
    
         
            -
                - -  
     | 
| 
      
 24 
     | 
    
         
            +
                - - '>='
         
     | 
| 
       28 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       29 
26 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       30 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       31 
28 
     | 
    
         
             
              name: rspec
         
     | 
| 
       32 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       33 
     | 
    
         
            -
                none: false
         
     | 
| 
       34 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       35 
     | 
    
         
            -
                - -  
     | 
| 
      
 31 
     | 
    
         
            +
                - - '>='
         
     | 
| 
       36 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       37 
33 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       38 
34 
     | 
    
         
             
              type: :development
         
     | 
| 
       39 
35 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       40 
36 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       41 
     | 
    
         
            -
                none: false
         
     | 
| 
       42 
37 
     | 
    
         
             
                requirements:
         
     | 
| 
       43 
     | 
    
         
            -
                - -  
     | 
| 
      
 38 
     | 
    
         
            +
                - - '>='
         
     | 
| 
       44 
39 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       45 
40 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       46 
41 
     | 
    
         
             
            description: Sort of an extension to Git to support clocking hours worked on a project.
         
     | 
| 
         @@ -54,30 +49,28 @@ files: 
     | 
|
| 
       54 
49 
     | 
    
         
             
            - lib/record.rb
         
     | 
| 
       55 
50 
     | 
    
         
             
            - lib/clockout.rb
         
     | 
| 
       56 
51 
     | 
    
         
             
            - lib/printer.rb
         
     | 
| 
       57 
     | 
    
         
            -
            -  
     | 
| 
       58 
     | 
    
         
            -
              YmluL2Nsb2Nr
         
     | 
| 
      
 52 
     | 
    
         
            +
            - bin/clock
         
     | 
| 
       59 
53 
     | 
    
         
             
            homepage: http://rubygems.org/gems/clockout
         
     | 
| 
       60 
54 
     | 
    
         
             
            licenses: []
         
     | 
| 
      
 55 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
       61 
56 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
       62 
57 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       63 
58 
     | 
    
         
             
            require_paths:
         
     | 
| 
       64 
59 
     | 
    
         
             
            - lib
         
     | 
| 
       65 
60 
     | 
    
         
             
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
       66 
     | 
    
         
            -
              none: false
         
     | 
| 
       67 
61 
     | 
    
         
             
              requirements:
         
     | 
| 
       68 
     | 
    
         
            -
              - -  
     | 
| 
      
 62 
     | 
    
         
            +
              - - '>='
         
     | 
| 
       69 
63 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       70 
64 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       71 
65 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       72 
     | 
    
         
            -
              none: false
         
     | 
| 
       73 
66 
     | 
    
         
             
              requirements:
         
     | 
| 
       74 
     | 
    
         
            -
              - -  
     | 
| 
      
 67 
     | 
    
         
            +
              - - '>='
         
     | 
| 
       75 
68 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       76 
69 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       77 
70 
     | 
    
         
             
            requirements: []
         
     | 
| 
       78 
71 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       79 
     | 
    
         
            -
            rubygems_version:  
     | 
| 
      
 72 
     | 
    
         
            +
            rubygems_version: 2.0.6
         
     | 
| 
       80 
73 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       81 
     | 
    
         
            -
            specification_version:  
     | 
| 
      
 74 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
       82 
75 
     | 
    
         
             
            summary: Clock your hours worked using Git
         
     | 
| 
       83 
76 
     | 
    
         
             
            test_files: []
         
     |