git-commits-analyzer 1.0.0 → 1.0.1

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: 3235fa842b69838ddc164316ad8394c08f71b6a5
4
- data.tar.gz: 6bb686c2baf86c75abc8d31f752c4968fd1931ed
3
+ metadata.gz: 32b24ca5fb34f38bbbe7457470d6e0a1095170d2
4
+ data.tar.gz: 3d70d001c83a376a0ab7bbddbfc2caf93e5f3d2b
5
5
  SHA512:
6
- metadata.gz: d7f5f16a6b4b26bcae93456c26d7df31de2fb3b6a35c74b5b268184f529c5303a81b6262a60a6da8d3075a9d901d8c13ef930285bb705978ee836de3ffb296a5
7
- data.tar.gz: 82f66448cfe0081c0881cb302dee08c080938e7778a6762fb8119e39143cec4145161412de4c511a5489ca6e1b3f1b1baf64c53aa44eddf368b71fc5c0ab7939
6
+ metadata.gz: 510ec2f13df1fbf487830fb44df3f1762b38140caabe477a63661ba71451224de0f6c33c3d7b20be6c2c35921299e7a2fab789ea790b049abd488152d53cdc18
7
+ data.tar.gz: b0b954e67fb375a60695a1240fc409002931531182ffa5707e95a54beb7cc7faeedb90a5f6a66b7114ede58fae23268fd72d6c233026d77f62b6df6dd982d8a9
data/bin/analyze_commits CHANGED
@@ -52,7 +52,14 @@ exit if git_commits_analyzer.commits_by_month.keys.empty?
52
52
  # Save data.
53
53
  puts '===== Save data ====='
54
54
  puts ''
55
- output_file = options[:output]
56
- File.open(output_file, 'w') { |file| file.write(git_commits_analyzer.to_json) }
55
+ output_directory = options[:output]
56
+
57
+ output_file_pretty = File.join(output_directory, 'git_contributions.pretty.json')
58
+ File.open(output_file_pretty, 'w') { |file| file.write(git_commits_analyzer.to_json(pretty: true)) }
59
+ puts "Re-generated #{output_file_pretty}."
60
+
61
+ output_file = File.join(output_directory, 'git_contributions.json')
62
+ File.open(output_file, 'w') { |file| file.write(git_commits_analyzer.to_json(pretty: false)) }
57
63
  puts "Re-generated #{output_file}."
64
+
58
65
  puts ''
@@ -143,7 +143,6 @@ class GitCommitsAnalyzer
143
143
  def parse_repo(repo:)
144
144
  git_repo = Git.open(repo, log: @logger)
145
145
 
146
- #return if repo != '/git_backups/github-guillaumeaubert/dot-files'
147
146
  # Note: override the default of 30 for count(), nil gives the whole git log
148
147
  # history.
149
148
  git_repo.log(count = nil).each do |commit|
@@ -227,17 +226,17 @@ class GitCommitsAnalyzer
227
226
  #
228
227
  # Returns: a JSON string.
229
228
  #
230
- def to_json()
229
+ def to_json(pretty: true)
231
230
  formatted_commits_by_month = []
232
231
  month_names = Date::ABBR_MONTHNAMES
233
232
  self.get_month_scale.each do |frame|
234
233
  display_key = month_names[frame[1]] + '-' + frame[0].to_s
235
234
  data_key = sprintf('%s-%02d', frame[0], frame[1])
236
- count = @commits_by_month[data_key].to_s
237
- formatted_commits_by_month << { month: display_key, commits: count.to_s }
235
+ count = @commits_by_month[data_key]
236
+ formatted_commits_by_month << { month: display_key, commits: count.to_i }
238
237
  end
239
238
 
240
- return JSON.pretty_generate(
239
+ data =
241
240
  {
242
241
  commits_total: @commits_total,
243
242
  commits_by_month: formatted_commits_by_month,
@@ -246,6 +245,11 @@ class GitCommitsAnalyzer
246
245
  commit_by_weekday_hour: @commit_weekdays_hours,
247
246
  lines_by_language: @lines_by_language
248
247
  }
249
- )
248
+
249
+ if pretty
250
+ JSON.pretty_generate(data)
251
+ else
252
+ JSON.generate(data)
253
+ end
250
254
  end
251
255
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-commits-analyzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Aubert