hotspots 0.0.9 → 0.0.10
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/.gitignore +1 -0
- data/CHANGELOG.markdown +18 -0
- data/README.markdown +1 -1
- data/Rakefile +37 -0
- data/bin/hotspots +1 -1
- data/lib/hotspots.rb +3 -3
- data/lib/hotspots/logger.rb +5 -5
- data/lib/hotspots/options_parser.rb +7 -4
- data/lib/hotspots/repository/driver/git.rb +0 -2
- data/lib/hotspots/repository/parser/git.rb +8 -2
- data/lib/hotspots/store.rb +1 -1
- data/lib/hotspots/version.rb +1 -1
- data/test/hotspots/options_parser_test.rb +1 -2
- data/test/hotspots/repository/parser/git_test.rb +43 -22
- data/test/hotspots/store_test.rb +9 -9
- metadata +4 -3
- data/test/hotspots_test.rb +0 -11
data/.gitignore
CHANGED
data/CHANGELOG.markdown
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
v0.0.10
|
2
|
+
-------
|
3
|
+
|
4
|
+
* Handle '\r' line endings
|
5
|
+
* *Don't disregard file-name case*
|
6
|
+
* Tests and coverage via rake
|
7
|
+
|
8
|
+
v0.0.9
|
9
|
+
------
|
10
|
+
|
11
|
+
* Add installation procedure
|
12
|
+
* Change website link
|
13
|
+
* Bump up version
|
14
|
+
|
15
|
+
v0.0.8
|
16
|
+
------
|
17
|
+
|
18
|
+
* Initial release
|
data/README.markdown
CHANGED
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
def load_all_tests
|
2
|
+
require 'rake/runtest'
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'minitest/spec'
|
5
|
+
|
6
|
+
lib = File.expand_path(File.dirname(__FILE__) + '/lib')
|
7
|
+
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
|
8
|
+
end
|
9
|
+
|
10
|
+
def run_all_tests
|
11
|
+
Dir[File.join(File.expand_path(File.dirname(__FILE__)), "test", "**", "*_test.rb")].each do |file|
|
12
|
+
Rake.run_tests file
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
task :test do
|
17
|
+
load_all_tests
|
18
|
+
run_all_tests
|
19
|
+
end
|
20
|
+
|
21
|
+
task :coverage do
|
22
|
+
require 'simplecov'
|
23
|
+
|
24
|
+
SimpleCov.start do
|
25
|
+
add_filter "/test/"
|
26
|
+
end
|
27
|
+
|
28
|
+
load_all_tests
|
29
|
+
|
30
|
+
Dir[File.join(File.expand_path(File.dirname(__FILE__)), "lib", "**", "*.rb")].each do |file|
|
31
|
+
require file
|
32
|
+
end
|
33
|
+
|
34
|
+
run_all_tests
|
35
|
+
end
|
36
|
+
|
37
|
+
task :default => [:test]
|
data/bin/hotspots
CHANGED
data/lib/hotspots.rb
CHANGED
@@ -4,19 +4,19 @@ require 'hotspots/store'
|
|
4
4
|
require 'hotspots/options_parser'
|
5
5
|
require 'hotspots/repository'
|
6
6
|
|
7
|
-
module
|
7
|
+
module Hotspots
|
8
8
|
class Main
|
9
9
|
attr_reader :logger, :options, :repository, :verbose,
|
10
10
|
:exit_code, :exit_message,
|
11
11
|
:driver, :parser, :store
|
12
12
|
|
13
13
|
def initialize
|
14
|
-
@logger = Hotspots::Logger.new
|
15
14
|
@options = Hotspots::OptionsParser.new.parse(*ARGV)
|
16
15
|
@repository = options[:repository]
|
17
16
|
@verbose = options[:verbose]
|
18
17
|
@exit_code = options[:exit][:code]
|
19
18
|
@exit_message = options[:exit][:message]
|
19
|
+
@logger = Hotspots::Logger.new
|
20
20
|
end
|
21
21
|
|
22
22
|
def execute!
|
@@ -58,7 +58,7 @@ module Repository
|
|
58
58
|
|
59
59
|
def set_logger
|
60
60
|
if verbose
|
61
|
-
logger.
|
61
|
+
logger.set_console
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
data/lib/hotspots/logger.rb
CHANGED
@@ -11,17 +11,17 @@ module Hotspots
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
attr_reader :
|
14
|
+
attr_reader :sink
|
15
15
|
def initialize
|
16
|
-
@
|
16
|
+
@sink = Null
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
@
|
19
|
+
def set_console
|
20
|
+
@sink = Console
|
21
21
|
end
|
22
22
|
|
23
23
|
def log(message)
|
24
|
-
@
|
24
|
+
@sink << format(message)
|
25
25
|
end
|
26
26
|
|
27
27
|
def format(message)
|
@@ -48,9 +48,10 @@ module Hotspots
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def set_banner_on(opts)
|
51
|
-
opts.banner = "Tool to find most modified files over the past few days in a git repository.
|
51
|
+
opts.banner = "Tool to find most modified files over the past few days in a git repository."
|
52
52
|
|
53
|
-
opts.separator "
|
53
|
+
opts.separator "Version #{::Hotspots::VERSION}"
|
54
|
+
opts.separator "Copyright (C) 2011-2012 Chirantan Mitra"
|
54
55
|
opts.separator ""
|
55
56
|
opts.separator "Usage: ruby hotspots [options]"
|
56
57
|
opts.separator ""
|
@@ -73,14 +74,16 @@ module Hotspots
|
|
73
74
|
|
74
75
|
def handle_file_filter_on(opts)
|
75
76
|
opts.on("-f", "--file-filter [REGEX]", String,
|
76
|
-
"Regular expression to filtering file names.
|
77
|
+
"Regular expression to filtering file names.",
|
78
|
+
"All files are allowed when not specified") do |o|
|
77
79
|
@options[:file_filter] = o.to_s
|
78
80
|
end
|
79
81
|
end
|
80
82
|
|
81
83
|
def handle_message_filter_on(opts)
|
82
84
|
opts.on("-m", "--message-filter [PIPE SEPARATED]", String,
|
83
|
-
"Pipe separated values to filter files names against each commit message separated by pipe.
|
85
|
+
"Pipe separated values to filter files names against each commit message separated by pipe.",
|
86
|
+
"All files are allowed when not specified") do |o|
|
84
87
|
@options[:message_filters] = o.to_s.split("|")
|
85
88
|
end
|
86
89
|
end
|
@@ -13,7 +13,6 @@ module Hotspots
|
|
13
13
|
.tap {|raw| logger.log "<Input> #{raw}"}
|
14
14
|
%x(#{command})
|
15
15
|
.tap {|raw| logger.log raw}
|
16
|
-
.gsub("\r", "")
|
17
16
|
end
|
18
17
|
|
19
18
|
def show_one_line_names(options)
|
@@ -21,7 +20,6 @@ module Hotspots
|
|
21
20
|
.tap {|raw| logger.log "<Input> #{raw}"}
|
22
21
|
%x(#{command})
|
23
22
|
.tap {|raw| logger.log "<Output> #{raw}"}
|
24
|
-
.gsub("\r", "")
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
@@ -10,13 +10,19 @@ module Hotspots
|
|
10
10
|
|
11
11
|
def files
|
12
12
|
filtered_commit_hashes.map do |commit_hash|
|
13
|
-
@driver.show_one_line_names(:commit_hash => commit_hash)
|
13
|
+
@driver.show_one_line_names(:commit_hash => commit_hash)
|
14
|
+
.gsub("\r\n", "\n")
|
15
|
+
.gsub("\r", "\n")
|
16
|
+
.split("\n")[1..-1]
|
14
17
|
end.flatten
|
15
18
|
end
|
16
19
|
|
17
20
|
def filtered_commit_hashes
|
18
21
|
@message_filters.map do |filter|
|
19
|
-
@driver.pretty_log(:since_days => @time, :message_filter => filter)
|
22
|
+
@driver.pretty_log(:since_days => @time, :message_filter => filter)
|
23
|
+
.gsub("\r\n", "\n")
|
24
|
+
.gsub("\r", "\n")
|
25
|
+
.split("\n")
|
20
26
|
end.flatten.uniq
|
21
27
|
end
|
22
28
|
end
|
data/lib/hotspots/store.rb
CHANGED
@@ -6,7 +6,7 @@ module Hotspots
|
|
6
6
|
@cutoff = options[:cutoff] || 0
|
7
7
|
@filter = options[:file_filter] || ""
|
8
8
|
|
9
|
-
@lines.map { |line| line.strip
|
9
|
+
@lines.map { |line| line.strip }
|
10
10
|
.select{ |line| not line.empty? and line =~ Regexp.new(@filter) }
|
11
11
|
.each { |line| @store[line] += 1 }
|
12
12
|
end
|
data/lib/hotspots/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'hotspots
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), '..', '..', '..', '..', 'lib', 'hotspots', 'repository', 'parser', 'git')
|
2
2
|
|
3
3
|
module Hotspots::Repository
|
4
4
|
describe "Parser::Git test" do
|
@@ -16,7 +16,7 @@ module Hotspots::Repository
|
|
16
16
|
|
17
17
|
it "fetches multiple commit hashes" do
|
18
18
|
options = {:time => 10, :message_filters => ["Foo", "Bar"]}
|
19
|
-
git_parser = Parser::Git.new StubGitDriver, options
|
19
|
+
git_parser = Parser::Git.new StubGitDriver.new, options
|
20
20
|
|
21
21
|
git_parser.filtered_commit_hashes.must_equal(["SHA1", "SHA2", "SHA3"])
|
22
22
|
end
|
@@ -36,39 +36,60 @@ module Hotspots::Repository
|
|
36
36
|
|
37
37
|
it "finds all affected files for multiple commit messages" do
|
38
38
|
options = {:time => 10, :message_filters => ["Foo", "Bar"]}
|
39
|
-
git_parser = Parser::Git.new StubGitDriver, options
|
39
|
+
git_parser = Parser::Git.new StubGitDriver.new, options
|
40
40
|
|
41
41
|
git_parser.files.must_equal(["file1", "file2", "file2", "file3", "file5", "file4"])
|
42
42
|
end
|
43
|
+
|
44
|
+
describe "handles line ending" do
|
45
|
+
it "of type \r\n" do
|
46
|
+
options = {:time => 10, :message_filters => ["Foo", "Bar"]}
|
47
|
+
git_parser = Parser::Git.new StubGitDriver.new(:line_ending => "\r\n"), options
|
48
|
+
|
49
|
+
git_parser.files.must_equal(["file1", "file2", "file2", "file3", "file5", "file4"])
|
50
|
+
end
|
51
|
+
|
52
|
+
it "of type \r" do
|
53
|
+
options = {:time => 10, :message_filters => ["Foo", "Bar"]}
|
54
|
+
git_parser = Parser::Git.new StubGitDriver.new(:line_ending => "\r"), options
|
55
|
+
|
56
|
+
git_parser.files.must_equal(["file1", "file2", "file2", "file3", "file5", "file4"])
|
57
|
+
end
|
58
|
+
end
|
43
59
|
end
|
44
60
|
|
45
61
|
describe "git driver stub" do
|
46
|
-
it "pretty log
|
47
|
-
|
48
|
-
|
62
|
+
it "has a sane pretty log" do
|
63
|
+
driver = StubGitDriver.new
|
64
|
+
driver.pretty_log(:time => 10, :message_filter => "Foo").must_equal "SHA1\nSHA2"
|
65
|
+
driver.pretty_log(:time => 10, :message_filter => "Bar").must_equal "SHA2\nSHA3"
|
49
66
|
end
|
50
67
|
|
51
|
-
it "show one line names
|
52
|
-
StubGitDriver.show_one_line_names(:commit_hash => "SHA2")
|
68
|
+
it "has a sane show one line names" do
|
69
|
+
StubGitDriver.new.show_one_line_names(:commit_hash => "SHA2")
|
70
|
+
.must_equal "SHA1 commit message\nfile2\nfile3\nfile5"
|
71
|
+
StubGitDriver.new(:line_ending => "\r\n").show_one_line_names(:commit_hash => "SHA2")
|
72
|
+
.must_equal "SHA1 commit message\r\nfile2\r\nfile3\r\nfile5"
|
53
73
|
end
|
54
74
|
end
|
55
75
|
|
56
76
|
class StubGitDriver
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
@pretty_log_enum.next
|
67
|
-
end
|
77
|
+
def initialize(options = {})
|
78
|
+
line_ending = options[:line_ending] || "\n"
|
79
|
+
@pretty_log_enum = ["SHA1#{line_ending}SHA2", "SHA2#{line_ending}SHA3"].cycle
|
80
|
+
@commits = {
|
81
|
+
"SHA1" => "SHA1 commit message#{line_ending}file1#{line_ending}file2",
|
82
|
+
"SHA2" => "SHA1 commit message#{line_ending}file2#{line_ending}file3#{line_ending}file5",
|
83
|
+
"SHA3" => "SHA1 commit message#{line_ending}file4",
|
84
|
+
}
|
85
|
+
end
|
68
86
|
|
69
|
-
|
70
|
-
|
71
|
-
|
87
|
+
def pretty_log(options)
|
88
|
+
@pretty_log_enum.next
|
89
|
+
end
|
90
|
+
|
91
|
+
def show_one_line_names(options)
|
92
|
+
@commits[options[:commit_hash]]
|
72
93
|
end
|
73
94
|
end
|
74
95
|
end
|
data/test/hotspots/store_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'hotspots
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), '..', '..', 'lib', 'hotspots', 'store')
|
2
2
|
|
3
3
|
module Hotspots
|
4
4
|
describe "Store test" do
|
@@ -31,14 +31,6 @@ module Hotspots
|
|
31
31
|
store.on("absent.txt").must_equal 0
|
32
32
|
end
|
33
33
|
|
34
|
-
it "disregards file case" do
|
35
|
-
lines = [
|
36
|
-
"ABC.TXT"
|
37
|
-
]
|
38
|
-
store = Store.new(lines)
|
39
|
-
store.on("abc.txt").must_equal 1
|
40
|
-
end
|
41
|
-
|
42
34
|
it "neglects empty lines" do
|
43
35
|
lines = [
|
44
36
|
" "
|
@@ -73,6 +65,14 @@ module Hotspots
|
|
73
65
|
store.to_s.must_equal "abc.txt,1\nefg.txt,1\n"
|
74
66
|
end
|
75
67
|
|
68
|
+
it "has a case-sensitive string representation" do
|
69
|
+
lines = [
|
70
|
+
"aBc.tXt"
|
71
|
+
]
|
72
|
+
store = Store.new(lines)
|
73
|
+
store.to_s.must_equal "aBc.tXt,1\n"
|
74
|
+
end
|
75
|
+
|
76
76
|
it "string representation has maximum occuring string at the top" do
|
77
77
|
lines = [
|
78
78
|
"abc.txt",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotspots
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-01-08 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! 'Find all files that changed over the past days for a git repository.
|
15
15
|
If the same file is modified over
|
@@ -28,9 +28,11 @@ extensions: []
|
|
28
28
|
extra_rdoc_files: []
|
29
29
|
files:
|
30
30
|
- .gitignore
|
31
|
+
- CHANGELOG.markdown
|
31
32
|
- Gemfile
|
32
33
|
- LICENSE
|
33
34
|
- README.markdown
|
35
|
+
- Rakefile
|
34
36
|
- bin/hotspots
|
35
37
|
- hotspots.gemspec
|
36
38
|
- lib/hotspots.rb
|
@@ -46,7 +48,6 @@ files:
|
|
46
48
|
- test/hotspots/options_parser_test.rb
|
47
49
|
- test/hotspots/repository/parser/git_test.rb
|
48
50
|
- test/hotspots/store_test.rb
|
49
|
-
- test/hotspots_test.rb
|
50
51
|
homepage: https://github.com/chiku/hotspots
|
51
52
|
licenses: []
|
52
53
|
post_install_message:
|
data/test/hotspots_test.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'minitest/autorun'
|
4
|
-
require 'minitest/spec'
|
5
|
-
|
6
|
-
lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
|
7
|
-
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
|
8
|
-
|
9
|
-
Dir[File.join(File.expand_path(File.dirname(__FILE__)), "hotspots", "**", "*_test.rb")].each do |file|
|
10
|
-
require file
|
11
|
-
end
|