achoo 0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,43 @@
1
+ class Achoo; end
2
+
3
+ require 'achoo/vcs/subversion'
4
+ require 'achoo/vcs/git'
5
+
6
+ class Achoo::VCS
7
+
8
+ LINE_LENGTH = 80
9
+
10
+ def self.factory(dir)
11
+ klass = [Achoo::VCS::Git, Achoo::VCS::Subversion].find do |k|
12
+ k.repository?(dir)
13
+ end
14
+ return nil if klass.nil?
15
+ klass.new(dir)
16
+ end
17
+
18
+ def self.print_logs_for(date, vcs_dirs, io=$stdout)
19
+ vcs_dirs.each do |dir|
20
+ Dir.glob("#{dir}/*/").each do |dir|
21
+ vcs = factory(dir)
22
+ next if vcs.nil?
23
+
24
+ log = vcs.log_for(date)
25
+ print_log(log, dir, io)
26
+ end
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ def self.print_log(log, dir, io)
33
+ return if log.empty?
34
+ io.puts header(dir)
35
+ io.puts log.chomp
36
+ end
37
+
38
+ def self.header(dir)
39
+ project = "<( #{File.basename(dir).upcase} )>"
40
+ dashes = '-' * ((LINE_LENGTH - project.length) / 2)
41
+ dashes + project + dashes
42
+ end
43
+ end
@@ -0,0 +1,20 @@
1
+ class Achoo; class VCS; end; end
2
+
3
+ class Achoo::VCS::Git
4
+
5
+ def self.repository?(dir)
6
+ File.exists?("#{dir}/.git")
7
+ end
8
+
9
+ def initialize(dir)
10
+ @dir = dir
11
+ end
12
+
13
+ def log_for(date)
14
+ today = date.strftime('%Y-%m-%d')
15
+ tomorrow = date.next.strftime('%Y-%m-%d')
16
+
17
+ `cd #@dir; git log --author=#{ENV['USER']} --oneline --after=#{today} --before=#{tomorrow} | cut -d ' ' -f 2-`
18
+ end
19
+
20
+ end
@@ -0,0 +1,32 @@
1
+ require 'nokogiri'
2
+
3
+ class Achoo; class VCS; end; end
4
+
5
+ class Achoo::VCS::Subversion
6
+
7
+ def self.repository?(dir)
8
+ File.exist?("#{dir}/.svn")
9
+ end
10
+
11
+ def initialize(dir)
12
+ @dir = dir
13
+ end
14
+
15
+ def log_for(date)
16
+ date = date.strftime("%F")
17
+ xml = Nokogiri::XML(`cd #@dir; svn log --xml`)
18
+ logentries = xml.xpath("/log/logentry/author[contains(., \"#{ENV['USER']}\")]/parent::*")
19
+
20
+ # FIX are the dates in the xml local time, or do they need to be
21
+ # converted?
22
+ log = ""
23
+ logentries.each do |e|
24
+ if e.css('date').text.start_with?(date)
25
+ log << e.css('msg').text.strip << "\n"
26
+ end
27
+ end
28
+ log
29
+ end
30
+
31
+
32
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: achoo
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.3"
5
+ platform: ruby
6
+ authors:
7
+ - "Kjell-Magne \xC3\x98ierud"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-04-15 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mechanize
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.0.0
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: ri_cal
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ description: Command line interface for Achievo (http://achievo.org)
36
+ email: kjellm@acm.org
37
+ executables:
38
+ - achoo
39
+ - awake
40
+ - vcs_commits
41
+ - ical
42
+ extensions: []
43
+
44
+ extra_rdoc_files: []
45
+
46
+ files:
47
+ - bin/awake
48
+ - bin/achoo
49
+ - bin/vcs_commits
50
+ - bin/ical
51
+ - lib/achoo/hour_administration_form.rb
52
+ - lib/achoo/vcs/git.rb
53
+ - lib/achoo/vcs/subversion.rb
54
+ - lib/achoo/ui.rb
55
+ - lib/achoo/term.rb
56
+ - lib/achoo/system.rb
57
+ - lib/achoo/open_timespan.rb
58
+ - lib/achoo/lock_month_form.rb
59
+ - lib/achoo/hour_registration_form.rb
60
+ - lib/achoo/vcs.rb
61
+ - lib/achoo/ui/date_chooser.rb
62
+ - lib/achoo/ui/exception_handling.rb
63
+ - lib/achoo/ui/month_chooser.rb
64
+ - lib/achoo/ui/commands.rb
65
+ - lib/achoo/ui/optionally_ranged_date_chooser.rb
66
+ - lib/achoo/ui/common.rb
67
+ - lib/achoo/ui/date_choosers.rb
68
+ - lib/achoo/ui/register_hours.rb
69
+ - lib/achoo/ical.rb
70
+ - lib/achoo/binary/cstruct.rb
71
+ - lib/achoo/binary/utmp_record.rb
72
+ - lib/achoo/system/wtmp.rb
73
+ - lib/achoo/system/pm_suspend.rb
74
+ - lib/achoo/hour_registration_form_ranged.rb
75
+ - lib/achoo/rc_loader.rb
76
+ - lib/achoo/awake.rb
77
+ - lib/achoo/timespan.rb
78
+ - lib/achoo/binary.rb
79
+ - lib/achoo/form.rb
80
+ - lib/achoo/term/menu.rb
81
+ - lib/achoo/term/table.rb
82
+ - lib/achoo.rb
83
+ - Rakefile
84
+ - README.rdoc
85
+ - CHANGES
86
+ - COPYING
87
+ has_rdoc: true
88
+ homepage: http://github.com/kjellm/achoo/
89
+ licenses: []
90
+
91
+ post_install_message:
92
+ rdoc_options: []
93
+
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 1.8.1
101
+ version:
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: "0"
107
+ version:
108
+ requirements:
109
+ - none
110
+ rubyforge_project:
111
+ rubygems_version: 1.3.5
112
+ signing_key:
113
+ specification_version: 3
114
+ summary: Achievo CLI.
115
+ test_files: []
116
+