hotspots 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +6 -0
- data/LICENSE +1 -1
- data/README.md +1 -0
- data/TODO.md +3 -0
- data/bin/hotspots +1 -1
- data/lib/hotspots.rb +58 -59
- data/lib/hotspots/compatibility.rb +4 -0
- data/lib/hotspots/logger.rb +2 -2
- data/lib/hotspots/option_based_exit.rb +1 -1
- data/lib/hotspots/options_parser.rb +2 -2
- data/lib/hotspots/repository/command/git.rb +1 -1
- data/lib/hotspots/repository/driver/git.rb +1 -1
- data/lib/hotspots/repository/parser/git.rb +7 -15
- data/lib/hotspots/store.rb +1 -1
- data/lib/hotspots/version.rb +2 -2
- data/test/hotspots/options_parser_test.rb +1 -1
- data/test/hotspots/repository/parser/git_test.rb +6 -17
- data/test/hotspots/store_test.rb +1 -1
- metadata +14 -19
data/CHANGELOG.md
CHANGED
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
Copyright (c) 2011-2013 Chirantan Mitra
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
4
|
|
data/README.md
CHANGED
data/TODO.md
CHANGED
@@ -1,2 +1,5 @@
|
|
1
1
|
* Allow better use as a library - add documentation
|
2
|
+
* Use builtin logger instead of a custom one
|
2
3
|
* Reduce conditionals
|
4
|
+
* Split responsibilities of OptionsParser. It shouldn't be responsible for holding default options. It should just setting overrides.
|
5
|
+
* Group files based on their extensions
|
data/bin/hotspots
CHANGED
data/lib/hotspots.rb
CHANGED
@@ -3,81 +3,80 @@ require 'hotspots/logger'
|
|
3
3
|
require 'hotspots/store'
|
4
4
|
require 'hotspots/options_parser'
|
5
5
|
require 'hotspots/repository'
|
6
|
+
require 'hotspots/compatibility'
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
:time, :message_filters, :file_filter, :cutoff
|
8
|
+
class Hotspots
|
9
|
+
attr_reader :logger, :repository, :verbose, :colour,
|
10
|
+
:exit_strategy, :driver, :parser, :store,
|
11
|
+
:time, :message_filters, :file_filter, :cutoff
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
def initialize(opts)
|
14
|
+
options = Hotspots::OptionsParser.default_options.merge(opts)
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
@logger = Hotspots::Logger.new
|
17
|
+
@repository = options[:repository]
|
18
|
+
@verbose = options[:verbose]
|
19
|
+
@colour = options[:colour]
|
20
|
+
@exit_strategy = options[:exit_strategy]
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
@time = options[:time]
|
23
|
+
@message_filters = options[:message_filters]
|
24
|
+
@file_filter = options[:file_filter]
|
25
|
+
@cutoff = options[:cutoff]
|
26
|
+
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
def output
|
29
|
+
validate
|
30
|
+
set
|
31
|
+
run
|
32
|
+
end
|
33
33
|
|
34
|
-
|
34
|
+
private
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
def validate #:nodoc:
|
37
|
+
exit_if_options_are_for_help
|
38
|
+
exit_if_not_git_repository
|
39
|
+
end
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
def set #:nodoc:
|
42
|
+
configure_logger
|
43
|
+
set_path
|
44
|
+
assign
|
45
|
+
end
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
def run #:nodoc:
|
48
|
+
puts store.to_s
|
49
|
+
end
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
def exit_if_options_are_for_help
|
52
|
+
exit_strategy.perform
|
53
|
+
end
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
55
|
+
def exit_if_not_git_repository
|
56
|
+
output = `git status 2>&1`
|
57
|
+
unless $? == 0
|
58
|
+
puts "'#{repository}' doesn't seem to be a git repository!"
|
59
|
+
exit 10
|
61
60
|
end
|
61
|
+
end
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
if colour
|
69
|
-
logger.colourize
|
70
|
-
end
|
63
|
+
def configure_logger
|
64
|
+
if verbose
|
65
|
+
logger.as_console
|
71
66
|
end
|
72
67
|
|
73
|
-
|
74
|
-
|
68
|
+
if colour
|
69
|
+
logger.colourize
|
75
70
|
end
|
71
|
+
end
|
76
72
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
73
|
+
def set_path
|
74
|
+
Dir.chdir(repository)
|
75
|
+
end
|
76
|
+
|
77
|
+
def assign
|
78
|
+
@driver = Hotspots::Repository::Driver::Git.new logger
|
79
|
+
@parser = Hotspots::Repository::Parser::Git.new driver, :time => time, :message_filters => message_filters
|
80
|
+
@store = Hotspots::Store.new parser.files, :cutoff => cutoff, :file_filter => file_filter
|
82
81
|
end
|
83
82
|
end
|
data/lib/hotspots/logger.rb
CHANGED
@@ -3,7 +3,7 @@ require 'optparse'
|
|
3
3
|
require 'hotspots/version'
|
4
4
|
require 'hotspots/option_based_exit'
|
5
5
|
|
6
|
-
|
6
|
+
class Hotspots
|
7
7
|
class OptionsParser #:nodoc: all
|
8
8
|
class << self
|
9
9
|
def default_options
|
@@ -60,7 +60,7 @@ module Hotspots
|
|
60
60
|
opts.banner = "Tool to find most modified files over the past few days in a git repository."
|
61
61
|
|
62
62
|
opts.separator "Version #{::Hotspots::VERSION}"
|
63
|
-
opts.separator "Copyright (C) 2011-
|
63
|
+
opts.separator "Copyright (C) 2011-2013 Chirantan Mitra"
|
64
64
|
opts.separator ""
|
65
65
|
opts.separator "Usage: ruby hotspots [options]"
|
66
66
|
opts.separator ""
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
class Hotspots
|
2
2
|
module Repository #:nodoc: all
|
3
3
|
module Parser
|
4
4
|
class Git
|
@@ -10,24 +10,16 @@ module Hotspots
|
|
10
10
|
@message_filters = options[:message_filters]
|
11
11
|
end
|
12
12
|
|
13
|
-
# TODO : replace with each_line
|
14
13
|
def files
|
15
|
-
filtered_commit_hashes.
|
16
|
-
driver.show_one_line_names(:commit_hash => commit_hash).
|
17
|
-
|
18
|
-
gsub("\r", "\n").
|
19
|
-
split("\n")[1..-1]
|
20
|
-
end.flatten
|
14
|
+
filtered_commit_hashes.reduce([]) do |acc, commit_hash|
|
15
|
+
acc + driver.show_one_line_names(:commit_hash => commit_hash).lines.map(&:strip)[1..-1]
|
16
|
+
end
|
21
17
|
end
|
22
18
|
|
23
|
-
# TODO : replace with each_line
|
24
19
|
def filtered_commit_hashes
|
25
|
-
message_filters.
|
26
|
-
driver.pretty_log(:since_days => time, :message_filter => filter).
|
27
|
-
|
28
|
-
gsub("\r", "\n").
|
29
|
-
split("\n")
|
30
|
-
end.flatten.uniq
|
20
|
+
message_filters.reduce([]) do |acc, filter|
|
21
|
+
acc + driver.pretty_log(:since_days => time, :message_filter => filter).lines.map(&:strip)
|
22
|
+
end.uniq
|
31
23
|
end
|
32
24
|
end
|
33
25
|
end
|
data/lib/hotspots/store.rb
CHANGED
data/lib/hotspots/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = "1.
|
1
|
+
class Hotspots
|
2
|
+
VERSION = "1.1.0"
|
3
3
|
end
|
@@ -41,20 +41,11 @@ module Hotspots::Repository
|
|
41
41
|
git_parser.files.must_equal(["file1", "file2", "file2", "file3", "file5", "file4"])
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
44
|
+
it "handles line ending" do
|
45
|
+
options = {:time => 10, :message_filters => ["Foo", "Bar"]}
|
46
|
+
git_parser = Parser::Git.new StubGitDriver.new, options
|
55
47
|
|
56
|
-
|
57
|
-
end
|
48
|
+
git_parser.files.must_equal(["file1", "file2", "file2", "file3", "file5", "file4"])
|
58
49
|
end
|
59
50
|
end
|
60
51
|
|
@@ -68,14 +59,12 @@ module Hotspots::Repository
|
|
68
59
|
it "has a sane show one line names" do
|
69
60
|
StubGitDriver.new.show_one_line_names(:commit_hash => "SHA2").
|
70
61
|
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"
|
73
62
|
end
|
74
63
|
end
|
75
64
|
|
76
65
|
class StubGitDriver
|
77
|
-
def initialize
|
78
|
-
line_ending =
|
66
|
+
def initialize
|
67
|
+
line_ending = "\n"
|
79
68
|
@pretty_log_enum = ["SHA1#{line_ending}SHA2", "SHA2#{line_ending}SHA3"].cycle
|
80
69
|
@commits = {
|
81
70
|
"SHA1" => "SHA1 commit message#{line_ending}file1#{line_ending}file2",
|
data/test/hotspots/store_test.rb
CHANGED
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: 1.
|
4
|
+
version: 1.1.0
|
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: 2013-04-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ansi
|
@@ -91,25 +91,26 @@ executables:
|
|
91
91
|
extensions: []
|
92
92
|
extra_rdoc_files: []
|
93
93
|
files:
|
94
|
-
- lib/hotspots/logger.rb
|
95
|
-
- lib/hotspots/option_based_exit.rb
|
96
94
|
- lib/hotspots/options_parser.rb
|
95
|
+
- lib/hotspots/version.rb
|
96
|
+
- lib/hotspots/option_based_exit.rb
|
97
|
+
- lib/hotspots/logger.rb
|
98
|
+
- lib/hotspots/repository.rb
|
97
99
|
- lib/hotspots/repository/command/git.rb
|
98
|
-
- lib/hotspots/repository/command.rb
|
99
100
|
- lib/hotspots/repository/driver/git.rb
|
100
101
|
- lib/hotspots/repository/driver.rb
|
101
|
-
- lib/hotspots/repository/
|
102
|
+
- lib/hotspots/repository/command.rb
|
102
103
|
- lib/hotspots/repository/parser.rb
|
103
|
-
- lib/hotspots/repository.rb
|
104
|
+
- lib/hotspots/repository/parser/git.rb
|
104
105
|
- lib/hotspots/store.rb
|
105
|
-
- lib/hotspots/
|
106
|
+
- lib/hotspots/compatibility.rb
|
106
107
|
- lib/hotspots.rb
|
107
108
|
- bin/hotspots
|
108
|
-
- test/
|
109
|
+
- test/minitest_helper.rb
|
109
110
|
- test/hotspots/repository/command/git_test.rb
|
110
111
|
- test/hotspots/repository/parser/git_test.rb
|
111
112
|
- test/hotspots/store_test.rb
|
112
|
-
- test/
|
113
|
+
- test/hotspots/options_parser_test.rb
|
113
114
|
- LICENSE
|
114
115
|
- README.md
|
115
116
|
- CHANGELOG.md
|
@@ -126,27 +127,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
127
|
- - ! '>='
|
127
128
|
- !ruby/object:Gem::Version
|
128
129
|
version: '0'
|
129
|
-
segments:
|
130
|
-
- 0
|
131
|
-
hash: 684827185202909371
|
132
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
131
|
none: false
|
134
132
|
requirements:
|
135
133
|
- - ! '>='
|
136
134
|
- !ruby/object:Gem::Version
|
137
135
|
version: '0'
|
138
|
-
segments:
|
139
|
-
- 0
|
140
|
-
hash: 684827185202909371
|
141
136
|
requirements: []
|
142
137
|
rubyforge_project: hotspots
|
143
|
-
rubygems_version: 1.8.
|
138
|
+
rubygems_version: 1.8.25
|
144
139
|
signing_key:
|
145
140
|
specification_version: 3
|
146
141
|
summary: Find all files that changed over the past in a git repository based on conditions
|
147
142
|
test_files:
|
148
|
-
- test/
|
143
|
+
- test/minitest_helper.rb
|
149
144
|
- test/hotspots/repository/command/git_test.rb
|
150
145
|
- test/hotspots/repository/parser/git_test.rb
|
151
146
|
- test/hotspots/store_test.rb
|
152
|
-
- test/
|
147
|
+
- test/hotspots/options_parser_test.rb
|