Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

KABLAME upgrade!

New rake tasks kablame:svn and kablame:git

takes parmeters DIRS and FORMATS

ex. rake kablame:git DIRS='app/views/admin' FORMATS='html.erb'


git-svn-id: http://kablame.googlecode.com/svn/kablame@8 fc056d42-643f-0410-81e7-b73d40e30204
  • Loading branch information...
commit 0d0461340e80b967f605d88eaec0d78cfdfac2dc 1 parent 9f6844a
@jdunphy authored
Showing with 50 additions and 8 deletions.
  1. +1 −1  README
  2. +33 −5 lib/kablame.rb
  3. +16 −2 tasks/kablame_tasks.rake
View
2  README
@@ -1,4 +1,4 @@
-= Kablame 0.1.1
+= Kablame 0.2
So who really gets bragging rights?
View
38 lib/kablame.rb
@@ -18,7 +18,7 @@ def kablame
unless(@users.empty?)
print_results
else
- puts "No results. Write some #{type.pluralize}!"
+ puts "No results. Write some #{type}!"
end
end
@@ -37,7 +37,8 @@ def print_results
@users.values.sort.each do |user|
puts user.to_s
end
- puts "**LOSER** #{@users.values.sort.last.name} **LOSER**"
+ puts "**LOSER** #{@users.values.sort.last.name} **LOSER**"
+ puts @info if @info
end
@@ -60,6 +61,8 @@ def name_match_regex; /\d+[\ ]+(\w+)/; end
def get_blame_lines(filename)
`svn blame #{filename}`.split("\n")
end
+
+ def version_control; 'svn'; end
end
module Git
@@ -67,7 +70,9 @@ def name_match_regex; /\((\w+)\s/; end
def get_blame_lines(filename)
`git blame #{filename}`.split("\n")
- end
+ end
+
+ def version_control; 'git'; end
end
class TestKablame < Kablame
@@ -79,7 +84,7 @@ def file_format_regex
/\.rb/
end
- def type; "test"; end
+ def type; "tests"; end
end
class SpecKablame < Kablame
@@ -91,7 +96,30 @@ def file_format_regex
/\.rb/
end
- def type; "spec"; end
+ def type; "specs"; end
+end
+
+class GeneralKablame < Kablame
+
+ def initialize(dirs, formats)
+ @folders = dirs ? dirs.split : %w{app lib}
+ @formats = formats ? formats.split : %w{rb r?html}
+ @info = "To get more detailed information use kablame:svn
+ Specify a set of directories and/or file formats
+ rake kablame:#{version_control} DIRS='app config' FORMATS='html xml'"
+
+ super()
+ end
+
+ def folders
+ @folders
+ end
+
+ def file_format_regex
+ %r{\.(#{@formats.join('|')})}
+ end
+
+ def type; "stuff"; end
end
class KablameUser
View
18 tasks/kablame_tasks.rake
@@ -1,5 +1,11 @@
-
namespace :kablame do
+
+ desc 'KABLAME anything: DIRS="app lib"'
+ task :svn => :environment do
+ require 'kablame'
+ GeneralKablame.send(:include, Svn)
+ GeneralKablame.new(ENV['DIRS'], ENV['FORMATS']).kablame
+ end
namespace :svn do
desc "KABLAME tests! See how much test code SVN says is yours"
task :tests => :environment do
@@ -13,8 +19,16 @@ namespace :kablame do
require 'kablame'
SpecKablame.send(:include, Svn)
SpecKablame.new.kablame
- end
+ end
end
+
+
+ desc 'KABLAME anything: DIRS="app lib"'
+ task :git => :environment do
+ require 'kablame'
+ GeneralKablame.send(:include, Git)
+ GeneralKablame.new(ENV['DIRS'], ENV['FORMATS']).kablame
+ end
namespace :git do
desc "KABLAME tests! See how much test code GIT says is yours"
task :tests => :environment do
Please sign in to comment.
Something went wrong with that request. Please try again.