timecost 0.0.1 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4c535194591fac9070a33bf8893093e7f267dad
4
- data.tar.gz: d8035799854d4d09803f1cef922f4cb2c8af24df
3
+ metadata.gz: ab1c4d27f50455f38f16e9a6713af684c5701096
4
+ data.tar.gz: 0e07a9b61f9346dac4a7ddbe46fe1b1af8783334
5
5
  SHA512:
6
- metadata.gz: 26a84c83f27764876c536d8a93ccfc3042d57941c7177d86225164e09527cb4cca1e9360df32ca68121d4e76898462cd46b269b1dee6bfe0ef8fe0d01dfce451
7
- data.tar.gz: cc6a7dae49c57478360e901acee687b633de7515e695b0e7a2aa0dfe699e97e233a649acd9e2060314b52e6c36c84746a426ed6b53b7f46845694ab6899cd0db
6
+ metadata.gz: 27afa269a23c3f5d1724b186ad1d29284ef41f3bc7f35fa7ea2811359b21adba91defeba3628d6faa8e992190540f2387d1d171a45bfe22e750d7ab2e2c228f3
7
+ data.tar.gz: 6db3c9e39ae742a8bb8778c138a6d0e5e43efd88dd897287cf5021498af89d11f55263754eb5c5a46d604adca275e637cb9b8a23939f499d83cdde9872fa1b64
data/lib/timecost/cli.rb CHANGED
@@ -7,7 +7,9 @@ module TimeCost
7
7
  :author_filter => ".*?",
8
8
 
9
9
  :date_filter_enable => false,
10
- :date_filter => ".*?",
10
+ :date_filter => [],
11
+
12
+ :branches_filter_enable => true,
11
13
 
12
14
  :input_dump => [],
13
15
  :output_dump => nil,
@@ -21,7 +23,7 @@ module TimeCost
21
23
  end
22
24
 
23
25
  def parse_cmdline args
24
- opts = OptionParser.new do |opts|
26
+ options = OptionParser.new do |opts|
25
27
  opts.banner = "Usage: #{File.basename $0} [options]"
26
28
 
27
29
  opts.on_tail("-v","--verbose", "Run verbosely") do |v|
@@ -33,6 +35,7 @@ module TimeCost
33
35
  exit 0
34
36
  end
35
37
 
38
+
36
39
  opts.on("-i","--input FILE", "Set input dump file") do |file|
37
40
  @config[:input_dump] << file
38
41
  end
@@ -41,13 +44,23 @@ module TimeCost
41
44
  @config[:output_dump] = file
42
45
  end
43
46
 
44
- opts.on("-d","--date DATE", "Keep only commits since DATE") do |date|
45
- puts "set date filter to #{date}"
46
- @config[:date_filter] = DateTime.parse(date);
47
+ opts.on("--before DATE", "Keep only commits before DATE") do |date|
48
+ puts "set date filter to <= #{date}"
49
+ @config[:date_filter] << lambda { |other|
50
+ return (other <= DateTime.parse(date))
51
+ }
52
+ @config[:date_filter_enable] = true
53
+ end
54
+
55
+ opts.on("--after DATE", "Keep only commits after DATE") do |date|
56
+ puts "set date filter to >= #{date}"
57
+ @config[:date_filter] << lambda { |other|
58
+ return (other >= DateTime.parse(date))
59
+ }
47
60
  @config[:date_filter_enable] = true
48
61
  end
49
62
 
50
- opts.on("-t","--time TIME", "Keep only commits on last TIME datys") do |time|
63
+ opts.on("-t","--time TIME", "Keep only commits on last TIME days") do |time|
51
64
  puts "set time filter to latest #{time} days"
52
65
  @config[:date_filter] = DateTime.now - time.to_f;
53
66
  puts "set date filter to date = #{@config[:date_filter]}"
@@ -60,6 +73,10 @@ module TimeCost
60
73
  @config[:author_filter_enable] = true
61
74
  end
62
75
 
76
+ opts.on_tail("--all", "Collect from all branches and refs") do
77
+ @config[:branches_filter_enable] = false
78
+ end
79
+
63
80
  # overlap :
64
81
  #
65
82
  opts.on("-s","--scotch GRANULARITY", "Use GRANULARITY (decimal hours) to merge ranges") do |granularity|
@@ -67,7 +84,7 @@ module TimeCost
67
84
  @config[:range_granularity] = granularity.to_f
68
85
  end
69
86
  end
70
- opts.parse! args
87
+ options.parse! args
71
88
 
72
89
  end
73
90
 
@@ -75,11 +92,17 @@ module TimeCost
75
92
  def analyze_git
76
93
  # git log
77
94
  # foreach, create time range (before) + logs
78
- process = IO.popen ["git", "log",
79
- "--date=iso",
80
- "--no-patch",
81
- "--","."]
82
95
 
96
+ cmd = [
97
+ "git", "log",
98
+ "--date=iso",
99
+ "--no-patch"
100
+ ]
101
+ if not @config[:branches_filter_enable] then
102
+ cmd << "--all"
103
+ end
104
+ cmd.concat ["--", "."]
105
+ process = IO.popen cmd
83
106
 
84
107
  @rangelist = {}
85
108
  commit = nil
@@ -121,10 +144,15 @@ module TimeCost
121
144
  unless commit.nil? then
122
145
  commit.date = $1
123
146
 
124
- if @config[:date_filter_enable] and
125
- (DateTime.parse(commit.date) < @config[:date_filter]) then
147
+ # reject if a some filter does not validate date
148
+ filter_keep = true
149
+ filters = @config[:date_filter]
150
+ filters.each do |f|
151
+ filter_keep &= f.call(DateTime.parse(commit.date))
152
+ end
153
+
154
+ if not filter_keep then
126
155
  commit = nil
127
- # reject
128
156
  end
129
157
  end
130
158
 
@@ -1,3 +1,3 @@
1
1
  module Timecost
2
- VERSION = "0.0.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timecost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glenn Y. Rolland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-26 00:00:00.000000000 Z
11
+ date: 2015-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler