git_heat 0.1.0 → 0.2.0

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: c51fd8f30762f4d67b4f35ab7f5959783078809d
4
- data.tar.gz: 379c5c34ac554d7f1dfa961e984582c558d9fd95
3
+ metadata.gz: 19c32b72702bccd51da7217e4cf6426781163791
4
+ data.tar.gz: 44fb1cfae2db909563cc2aaba5e971c8e8bd23eb
5
5
  SHA512:
6
- metadata.gz: 93a76f7ac9d84db387f62553cac35e6cb2aa2e0cf39bc9cc2cce8c4f6e2f368d648af902cd74f621989b3a981bee6974e49bb5877af7e730e86895ab9954187f
7
- data.tar.gz: 991d3780b9d53cbb781be933c4e901669327239741fe6914641276df321f6ec2a9f6e074e910e61fd8f1f11ed55ac09e40b20017a4ca81dd4a557583e9de1e57
6
+ metadata.gz: 3eb46c59231275601a7a1d4773c17ca3292f12798c88ab9b5cdd0aff31cf365940fc372f4c648eb819bdbdc6ac42272c909a297b512fe39b10cfea641e5b6e80
7
+ data.tar.gz: fab2edf1b613ed23be35691f9f3c391fcd52224c8e020f6d5eedab94ccc1bbe9586685ca6a8f24014da6dd726657bee5d818b3abffdf5e65d433190c3d4c06a7
data/Gemfile CHANGED
@@ -2,3 +2,9 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in git_heat.gemspec
4
4
  gemspec
5
+
6
+ if ENV["TOPCHART_DEV_MODE"]
7
+ gem 'topchart', path: "../topchart"
8
+ else
9
+ gem 'topchart'
10
+ end
@@ -1,12 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_heat (0.0.1)
4
+ git_heat (0.1.0)
5
+ topchart
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
10
+ coderay (1.1.0)
9
11
  diff-lcs (1.2.5)
12
+ method_source (0.8.2)
13
+ pry (0.9.12.4)
14
+ coderay (~> 1.0)
15
+ method_source (~> 0.8)
16
+ slop (~> 3.4)
10
17
  rake (10.3.1)
11
18
  rspec (2.14.1)
12
19
  rspec-core (~> 2.14.0)
@@ -16,6 +23,8 @@ GEM
16
23
  rspec-expectations (2.14.5)
17
24
  diff-lcs (>= 1.1.3, < 2.0)
18
25
  rspec-mocks (2.14.6)
26
+ slop (3.4.7)
27
+ topchart (0.0.1)
19
28
 
20
29
  PLATFORMS
21
30
  ruby
@@ -23,5 +32,7 @@ PLATFORMS
23
32
  DEPENDENCIES
24
33
  bundler (~> 1.3)
25
34
  git_heat!
35
+ pry
26
36
  rake
27
37
  rspec
38
+ topchart
@@ -3,16 +3,69 @@
3
3
  require_relative '../lib/git_heat/git_stat'
4
4
  require_relative '../lib/git_heat/git_client'
5
5
  require_relative '../lib/git_heat/calculator'
6
+ require 'topchart'
6
7
 
7
- dir = ARGV[0] || Dir.pwd
8
-
9
- begin
10
- puts(Calculator.new(Time.now).go(
11
- GitStat.new(
12
- GitClient.new(dir)
13
- ).stats
14
- ).map do |a|
15
- a[0].to_s.ljust(100) + a[1].to_s
16
- end.to_a)
17
- rescue Errno::EPIPE
8
+ class Object
9
+ def pat(&blk)
10
+ !self.nil? && blk.call(self)
11
+ end
12
+ end
13
+
14
+
15
+ class Runner
16
+ def initialize(time)
17
+ @time = time
18
+ end
19
+
20
+ def go(args,opts)
21
+ args = Array(args)
22
+ opts = Array(opts)
23
+ dir = args[0] || Dir.pwd
24
+
25
+ begin
26
+ Calculator.new(@time).go(
27
+ GitStat.new(
28
+ GitClient.new(dir)
29
+ ).stats
30
+ ).map do |a|
31
+ if opts.include? '--no-scores'
32
+ a[0]
33
+ else
34
+ a[0].to_s.ljust(80) + a[1].to_s
35
+ end
36
+ end.to_a
37
+ rescue Errno::EPIPE
38
+ end
39
+ end
40
+ end
41
+
42
+ opt = ->(a){ a[/^-/] }
43
+ opts = ARGV.select(&opt)
44
+ args = ARGV.reject(&opt)
45
+
46
+ time_opt = opts.detect{|o| o[/--time=(.*)/, 1] }.pat(&Time.method(:parse))
47
+ time = time_opt || Time.now
48
+ a_day = 60*60*24
49
+ chart_opt = opts.map{|o| o[/--chart(.*)$/, 1] }.compact.last.pat do |dur_str|
50
+ dur_str = dur_str.gsub("=","")
51
+ case dur_str
52
+ when "day"
53
+ a_day
54
+ when "week"
55
+ a_day*7
56
+ when "30day"
57
+ a_day*30
58
+ else
59
+ dur_str.to_i*a_day
60
+ end
61
+ end
62
+ chart_duration = chart_opt || a_day
63
+
64
+ if chart_opt
65
+ puts Topchart.new.chart(
66
+ Runner.new(time-chart_duration).go(args, ["--no-scores"]),
67
+ Runner.new(time).go(args, ["--no-scores"])
68
+ ).map{|l| l.join(" ")}
69
+ else
70
+ puts Runner.new(time).go(args, opts)
18
71
  end
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "pry"
24
24
  spec.add_development_dependency "rspec"
25
+ spec.add_dependency "topchart"
25
26
  end
@@ -8,6 +8,7 @@ class Calculator
8
8
  def go(stats)
9
9
  heat = {}
10
10
  stats.each do |commit|
11
+ next if commit[:time] > @time
11
12
  time_delta = @time - commit[:time]
12
13
  unless commit[:affected_files]
13
14
  next
@@ -1,3 +1,3 @@
1
1
  module GitHeat
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_heat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serguei Filimonov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-22 00:00:00.000000000 Z
11
+ date: 2014-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: topchart
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: 'Reports a measure of activity in each file of a git repo '
70
84
  email:
71
85
  - serguei.filimonov@gmail.com