Skip to content

Commit

Permalink
Moved most of cores.rb into json.rb, cores.rb now reads json data #19
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisnyman committed Dec 28, 2014
1 parent 9374a2f commit 058d8fd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 37 deletions.
36 changes: 4 additions & 32 deletions app/bin/cores.rb
Original file line number Diff line number Diff line change
@@ -1,47 +1,19 @@
#!/usr/bin/env ruby

log_args = ARGV[0] || '--since=2011-03-09'
git_command = 'git --git-dir=../drupalcore/.git --work-tree=drupal log 8.0.x ' + log_args + ' -s --format=%s'

Encoding.default_external = Encoding::UTF_8
require 'erb'
require 'yaml'
require 'time'
require 'json'

name_mappings = YAML::load_file('../config/name_mappings.yml')
contributors = Hash.new(0)
i = 1;
lastOrder = -1;
lastMentions = 0;
commits = Array.new
reverts = Array.new

%x[#{git_command}].split("\n").each do |c|
if c.index('Revert') == 0 then
reverts.push(c.scan(/#([0-9]+)/))
else
commits.push(c)
end
end

commits.each_with_index do |c, i|
if r = reverts.index{ |item| item == c.scan(/#([0-9]+)/) }
commits.delete_at(i)
reverts.delete_at(r)
end
end

commits.each do |m|
m.gsub(/\-/, '_').scan(/\s(?:by\s?)([[:word:]\s,.|]+):/i).each do |people|
people[0].split(/(?:,|\||\band\b|\bet al(?:.)?)/).each do |p|
name = p.strip.downcase
contributors[name_mappings[name] || name] += 1 unless p.nil?
end
end
end

file = file = File.read('../../dist/data.json')
data = JSON.parse(file)
contributors = data['contributors']
sum = contributors.values.reduce(:+).to_f
contributors = Hash[contributors.sort_by {|k, v| v }.reverse]
puts ERB.new(DATA.readlines.join, 0, '>').result

time = Time.now()
Expand Down
27 changes: 23 additions & 4 deletions app/bin/json.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,44 @@
#!/usr/bin/env ruby

log_args = ARGV[0] || '--since=2011-03-09'
git_command = 'git --git-dir=../drupalcore/.git --work-tree=drupal log 8.0.x ' + log_args + ' -s --format=%s'

Encoding.default_external = Encoding::UTF_8
require 'erb'
require 'yaml'
require 'json'

name_mappings = YAML::load_file('../config/name_mappings.yml')
contributors = Hash.new(0)
%x[git --git-dir=../drupalcore/.git --work-tree=drupal log 8.0.x --since=2011-03-09 -s --format=%s].split("\n").each do |m|
commits = Array.new
reverts = Array.new

%x[#{git_command}].split("\n").each do |c|
if c.index('Revert') == 0 then
reverts.push(c.scan(/#([0-9]+)/))
else
commits.push(c)
end
end

commits.each_with_index do |c, i|
if r = reverts.index{ |item| item == c.scan(/#([0-9]+)/) }
commits.delete_at(i)
reverts.delete_at(r)
end
end

commits.each do |m|
m.gsub(/\-/, '_').scan(/\s(?:by\s?)([[:word:]\s,.|]+):/i).each do |people|
people[0].split(/[,|]/).each do |p|
people[0].split(/(?:,|\||\band\b|\bet al(?:.)?)/).each do |p|
name = p.strip.downcase
contributors[name_mappings[name] || name] += 1 unless p.nil?
end
end
end

sum = contributors.values.reduce(:+).to_f
contributors = Hash[contributors.sort_by {|k, v| v }.reverse]


output = {
:date => Time.new,
:count => contributors.length,
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ gulp.task('drupalcore', function () {
});

// Build contributors page
gulp.task('buildcontributors', function () {
gulp.task('buildcontributors', ['buildjson'], function () {
return gulp.src('')
.pipe(shell(['./cores.rb > ../../dist/index.html'], { 'cwd': './app/bin'}));
});
Expand Down

0 comments on commit 058d8fd

Please sign in to comment.