bigtiger-rolex 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Pairing Workstation Bender
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,7 @@
1
+ = rolex
2
+
3
+ Description goes here.
4
+
5
+ == Copyright
6
+
7
+ Copyright (c) 2009 Pairing Workstation Bender. See LICENSE for details.
@@ -0,0 +1,48 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "rolex"
8
+ gem.summary = %Q{TODO}
9
+ gem.email = "dev+bigtiger+sandro@hashrocket.com"
10
+ gem.homepage = "http://github.com/bigtiger/rolex"
11
+ gem.authors = ["bigtiger", "sandro"]
12
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
+ end
14
+
15
+ rescue LoadError
16
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
17
+ end
18
+
19
+ require 'spec/rake/spectask'
20
+ Spec::Rake::SpecTask.new(:spec) do |spec|
21
+ spec.libs << 'lib' << 'spec'
22
+ spec.spec_files = FileList['spec/**/*_spec.rb']
23
+ end
24
+
25
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
26
+ spec.libs << 'lib' << 'spec'
27
+ spec.pattern = 'spec/**/*_spec.rb'
28
+ spec.rcov = true
29
+ end
30
+
31
+
32
+ task :default => :spec
33
+
34
+ require 'rake/rdoctask'
35
+ Rake::RDocTask.new do |rdoc|
36
+ if File.exist?('VERSION.yml')
37
+ config = YAML.load(File.read('VERSION.yml'))
38
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
39
+ else
40
+ version = ""
41
+ end
42
+
43
+ rdoc.rdoc_dir = 'rdoc'
44
+ rdoc.title = "rolex #{version}"
45
+ rdoc.rdoc_files.include('README*')
46
+ rdoc.rdoc_files.include('lib/**/*.rb')
47
+ end
48
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,5 @@
1
+ class Float
2
+ def round_to(x)
3
+ (self * 10**x).round.to_f / 10**x
4
+ end
5
+ end
@@ -0,0 +1,73 @@
1
+ $:.unshift(File.dirname(__FILE__))
2
+
3
+ begin; require 'rubygems'; rescue LoadError; end
4
+ require 'grit'
5
+ require 'float_ext'
6
+
7
+ class Rolex
8
+ attr_accessor :who
9
+
10
+ def initialize(repo_location, who)
11
+ @who = who
12
+ @repo = Grit::Repo.new(repo_location)
13
+ end
14
+
15
+ def today
16
+ commits = Grit::Commit.find_all(@repo, nil, :since => Time.today)
17
+ Report.new(commits, who).run
18
+ end
19
+
20
+ class Report
21
+ attr_reader :commits, :who
22
+
23
+ def initialize(commits, who)
24
+ @who = who
25
+ @commits = commits.reverse
26
+ @lines = []
27
+ end
28
+
29
+ def run
30
+ commits.each_with_index do |c,i|
31
+ elapsed = nil
32
+ if c != commits.first
33
+ previous = commits[i-1]
34
+ elapsed = c.committed_date - previous.committed_date
35
+ end
36
+
37
+ if c.author.email.include?(who)
38
+ @lines << Line.new(c.message, elapsed)
39
+ end
40
+ end
41
+ @lines << "Total time: #{total_elapsed_time}"
42
+ @lines.join("\n")
43
+ end
44
+
45
+ def total_elapsed_time
46
+ total = 0
47
+ @lines.each do |l|
48
+ total += l.elapsed_time_in_hours
49
+ end
50
+
51
+ total
52
+ end
53
+
54
+ end
55
+
56
+ class Line
57
+ attr_accessor :message, :elapsed
58
+
59
+ def initialize(message, elapsed)
60
+ @message = message
61
+ @elapsed = elapsed
62
+ end
63
+
64
+ def to_s
65
+ "#{message} - #{elapsed_time_in_hours}"
66
+ end
67
+
68
+ def elapsed_time_in_hours
69
+ (elapsed / 60 / 60).round_to(2)
70
+ end
71
+ end
72
+ end
73
+
@@ -0,0 +1,15 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Rolex" do
4
+ before do
5
+ @rolex = Rolex.new("~/hashrocket/newhomeguide", "bigtiger")
6
+ end
7
+
8
+ describe '#today' do
9
+ it "retrieves today's commits" do
10
+ Grit::Commit.should_receive(:find_all)
11
+ @rolex.today
12
+ end
13
+ end
14
+
15
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec'
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ require 'rolex'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bigtiger-rolex
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - bigtiger
8
+ - sandro
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-06-12 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description:
18
+ email: dev+bigtiger+sandro@hashrocket.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files:
24
+ - LICENSE
25
+ - README.rdoc
26
+ files:
27
+ - .document
28
+ - .gitignore
29
+ - LICENSE
30
+ - README.rdoc
31
+ - Rakefile
32
+ - VERSION
33
+ - lib/float_ext.rb
34
+ - lib/rolex.rb
35
+ - spec/rolex_spec.rb
36
+ - spec/spec_helper.rb
37
+ has_rdoc: true
38
+ homepage: http://github.com/bigtiger/rolex
39
+ post_install_message:
40
+ rdoc_options:
41
+ - --charset=UTF-8
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ version:
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ requirements: []
57
+
58
+ rubyforge_project:
59
+ rubygems_version: 1.2.0
60
+ signing_key:
61
+ specification_version: 2
62
+ summary: TODO
63
+ test_files:
64
+ - spec/rolex_spec.rb
65
+ - spec/spec_helper.rb