git_stats 1.0.13 → 1.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fdf6acaebd3fce0aec44b46e2434c0e5d978a0aa
4
- data.tar.gz: 01568a5bfcba85be69a55838c885b318c6aeb113
3
+ metadata.gz: e8708738d81eee8acb9e0e9a7f63a4b34a043cf5
4
+ data.tar.gz: 8e81f4164072ce547b6d3917653d39be6ef295c4
5
5
  SHA512:
6
- metadata.gz: 5a6389f8e2e955b57eb7a4ef25637f99374a0e0f5eeaea1d8824f92d57a7fdc91ca0191976da15a0327850a50347386d811d97ac65574bbf8db6b26143bc6038
7
- data.tar.gz: cdbec24c61f9f579e56c65dcbbfbe7a2d0dc6d2c3d8f94928f1b146751e379d104e28a9dd0aec1b0a0595561dc8d61bfcea0e087760fcc750f9ae575afed5f8a
6
+ metadata.gz: fbab24e9508a3d4bc8ee28bea5f07b5158501e161d0b6c1d8417497585683ae247163fc5b50637ac76f1f66cf2d629c4fe0ab4931f23c9e06af1d4a45f96ebc4
7
+ data.tar.gz: 9eb0e555c79f0e85ee7012d1adc168576d0330953a1ed13289d893f6094d94da432e06d759cff89e4df37719626a530be2b40b002d03cf94fa563a4da8285214
data/README.md CHANGED
@@ -34,20 +34,22 @@ It browses the repository and outputs html page with statistics.
34
34
  git_stats generate
35
35
 
36
36
  Options:
37
- p, [--path=PATH] # Path to repository from which statistics should be generated.
38
- # Default: .
39
- o, [--out-path=OUT_PATH] # Output path where statistics should be written.
40
- # Default: ./git_stats
41
- l, [--language=LANGUAGE] # Language of written statistics.
42
- # Default: en
43
- f, [--from=FROM] # Commit from where statistics should start.
44
- t, [--to=TO] # Commit where statistics should stop.
45
- # Default: HEAD
46
- s, [--silent], [--no-silent] # Silent mode. Don't output anything.
47
- d, [--tree=TREE] # Tree where statistics should be generated.
48
- # Default: .
49
- c, [--comment=COMMENT] # The string which is used for comments.
50
- # Default: //
37
+ p, [--path=PATH] # Path to repository from which statistics should be generated.
38
+ # Default: .
39
+ o, [--out-path=OUT_PATH] # Output path where statistics should be written.
40
+ # Default: ./git_stats
41
+ l, [--language=LANGUAGE] # Language of written statistics.
42
+ # Default: en
43
+ f, [--first-commit-sha=FIRST_COMMIT_SHA] # Commit from where statistics should start.
44
+ t, [--last-commit-sha=LAST_COMMIT_SHA] # Commit where statistics should stop.
45
+ # Default: HEAD
46
+ s, [--silent], [--no-silent] # Silent mode. Don't output anything.
47
+ d, [--tree=TREE] # Tree where statistics should be generated.
48
+ # Default: .
49
+ c, [--comment-string=COMMENT_STRING] # The string which is used for comments.
50
+ # Default: //
51
+
52
+ Generates the statistics of a repository
51
53
 
52
54
 
53
55
 
@@ -8,13 +8,12 @@ require 'git_stats/version'
8
8
  require 'git_stats/i18n'
9
9
  require 'git_stats/cli'
10
10
  require 'git_stats/generator'
11
- require 'git_stats/validator'
11
+ require 'git_stats/command_runner'
12
+ require 'git_stats/command_parser'
12
13
 
13
14
  require 'git_stats/git_data/activity'
14
15
  require 'git_stats/git_data/author'
15
16
  require 'git_stats/git_data/blob'
16
- require 'git_stats/git_data/command_parser'
17
- require 'git_stats/git_data/command_runner'
18
17
  require 'git_stats/git_data/commit'
19
18
  require 'git_stats/git_data/repo'
20
19
  require 'git_stats/git_data/short_stat'
@@ -0,0 +1,31 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module GitStats
3
+ class CommandParser
4
+ def parse(command, result)
5
+ cmd, params = command.scan(/git (.*) (.*)/).first.map(&:split).flatten
6
+ send("parse_#{cmd.underscore}", result, params)
7
+ end
8
+
9
+ def parse_shortlog(result, params)
10
+ result.lines.map do |line|
11
+ commits, name, email = line.scan(/(.*)\t(.*)<(.*)>/).first.map(&:strip)
12
+ {commits: commits.to_i, name: name, email: email}
13
+ end
14
+ end
15
+
16
+ def parse_ls_tree(result, params)
17
+ result.lines.map do |line|
18
+ mode, type, sha, filename = line.scan(/(.*) (.*) (.*)\t(.*)/).first.map(&:strip)
19
+ {mode: mode, type: type, sha: sha, filename: filename}
20
+ end
21
+ end
22
+
23
+ def parse_rev_list(result, params)
24
+ result.lines.map do |line|
25
+ sha, stamp, date, author_email = line.split('|').map(&:strip)
26
+ {sha: sha, stamp: stamp, date: date, author_email: author_email}
27
+ end
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,13 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module GitStats
3
+ class CommandRunner
4
+ def run(path, command)
5
+ execute(command, path).encode!('UTF-8', 'UTF-8', :invalid => :replace)
6
+ end
7
+
8
+ private
9
+ def execute(command, path)
10
+ Dir.chdir(path) { %x[#{command}] }
11
+ end
12
+ end
13
+ end
@@ -18,7 +18,12 @@ module GitStats
18
18
 
19
19
 
20
20
  def validate_repo_path(repo_path)
21
- raise ArgumentError, "#{repo_path} is not a git repository" unless Validator.new.valid_repo_path?(repo_path)
21
+ raise ArgumentError, "#{repo_path} is not a git repository" unless valid_repo_path?(repo_path)
22
+ end
23
+
24
+
25
+ def valid_repo_path?(repo_path)
26
+ Dir.exists?("#{repo_path}/.git") || File.exists?("#{repo_path}/.git") || File.exists?("#{repo_path}/HEAD")
22
27
  end
23
28
 
24
29
  end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module GitStats
3
- VERSION = "1.0.13"
3
+ VERSION = "1.0.14"
4
4
  end
@@ -6,34 +6,7 @@ describe GitStats::Generator do
6
6
  let(:out_path) { 'out_path' }
7
7
  let(:generator) { GitStats::Generator.new(path: repo_path, out_path: out_path) }
8
8
 
9
- before { Dir.stub(:exists? => true) }
10
-
11
9
  it 'should raise exception if given repo path is not a git repository' do
12
- Dir.should_receive(:exists?).with("#{repo_path}/.git").and_return(false)
13
- expect { generator }.to raise_error(ArgumentError)
14
- end
15
-
16
- it 'should pass command observer to repo' do
17
- repo = double('repo')
18
- GitStats::GitData::Repo.should_receive(:new).with(path: repo_path, out_path: out_path).and_return(repo)
19
-
20
- observer = double('observer')
21
- repo.should_receive(:add_command_observer).with(observer)
22
-
23
- generator.add_command_observer observer
24
- end
25
-
26
- it 'should render all templates with view data for this repo' do
27
- repo = double('repo')
28
- GitStats::GitData::Repo.should_receive(:new).with(path: repo_path, out_path: out_path).and_return(repo)
29
-
30
- view_data = double('view_data')
31
- GitStats::StatsView::ViewData.should_receive(:new).with(repo).and_return(view_data)
32
-
33
- view = double('view')
34
- GitStats::StatsView::View.should_receive(:new).with(view_data, out_path).and_return(view)
35
- view.should_receive(:render_all)
36
-
37
- generator.render_all
10
+ expect { generator }.to raise_error
38
11
  end
39
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.13
4
+ version: 1.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Gieniusz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-25 00:00:00.000000000 Z
11
+ date: 2014-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -147,6 +147,8 @@ files:
147
147
  - lib/git_stats.rb
148
148
  - lib/git_stats/base.rb
149
149
  - lib/git_stats/cli.rb
150
+ - lib/git_stats/command_parser.rb
151
+ - lib/git_stats/command_runner.rb
150
152
  - lib/git_stats/core_extensions/enumerable.rb
151
153
  - lib/git_stats/core_extensions/hash.rb
152
154
  - lib/git_stats/core_extensions/string.rb
@@ -155,8 +157,6 @@ files:
155
157
  - lib/git_stats/git_data/activity.rb
156
158
  - lib/git_stats/git_data/author.rb
157
159
  - lib/git_stats/git_data/blob.rb
158
- - lib/git_stats/git_data/command_parser.rb
159
- - lib/git_stats/git_data/command_runner.rb
160
160
  - lib/git_stats/git_data/comment_stat.rb
161
161
  - lib/git_stats/git_data/commit.rb
162
162
  - lib/git_stats/git_data/repo.rb
@@ -172,7 +172,6 @@ files:
172
172
  - lib/git_stats/stats_view/template.rb
173
173
  - lib/git_stats/stats_view/view.rb
174
174
  - lib/git_stats/stats_view/view_data.rb
175
- - lib/git_stats/validator.rb
176
175
  - lib/git_stats/version.rb
177
176
  - spec/factories.rb
178
177
  - spec/git_data/activity_spec.rb
@@ -1,33 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- module GitStats
3
- module GitData
4
- class CommandParser
5
- def parse(command, result)
6
- cmd, params = command.scan(/git (.*) (.*)/).first.map(&:split).flatten
7
- send("parse_#{cmd.underscore}", result, params)
8
- end
9
-
10
- def parse_shortlog(result, params)
11
- result.lines.map do |line|
12
- commits, name, email = line.scan(/(.*)\t(.*)<(.*)>/).first.map(&:strip)
13
- {commits: commits.to_i, name: name, email: email}
14
- end
15
- end
16
-
17
- def parse_ls_tree(result, params)
18
- result.lines.map do |line|
19
- mode, type, sha, filename = line.scan(/(.*) (.*) (.*)\t(.*)/).first.map(&:strip)
20
- {mode: mode, type: type, sha: sha, filename: filename}
21
- end
22
- end
23
-
24
- def parse_rev_list(result, params)
25
- result.lines.map do |line|
26
- sha, stamp, date, author_email = line.split('|').map(&:strip)
27
- {sha: sha, stamp: stamp, date: date, author_email: author_email}
28
- end
29
- end
30
-
31
- end
32
- end
33
- end
@@ -1,15 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- module GitStats
3
- module GitData
4
- class CommandRunner
5
- def run(path, command)
6
- execute(command, path).encode!('UTF-8', 'UTF-8', :invalid => :replace)
7
- end
8
-
9
- private
10
- def execute(command, path)
11
- Dir.chdir(path) { %x[#{command}] }
12
- end
13
- end
14
- end
15
- end
@@ -1,10 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- module GitStats
3
- class Validator
4
-
5
- def valid_repo_path?(repo_path)
6
- Dir.exists?("#{repo_path}/.git") || File.exists?("#{repo_path}/HEAD")
7
- end
8
-
9
- end
10
- end