Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

generate code_swarm xml directly + better config

  • Loading branch information...
commit 3ba166ca6830e173bf239c565ba0b62dcde12762 1 parent 7490289
@igrigorik authored
Showing with 28 additions and 36 deletions.
  1. +6 −0 README
  2. +13 −27 gitter.rb
  3. +9 −9 swarm.config
View
6 README
@@ -9,3 +9,9 @@ Alternatively, you can try the pure Ruby version (using Cairo):
Wikipedia / Obama's Page: http://vimeo.com/2177573
+= GitHub API
+http://github.com/guides/the-github-api
+
+= Top Gitters:
+http://github.com/mmcgrana/clj-garden/raw/master/gitcred/RESULTS.txt
+
View
40 gitter.rb
@@ -1,20 +1,9 @@
require 'rubygems'
require 'open-uri'
-require 'date'
+require 'time'
require 'json'
-class DateTime
- def to_rfc2822
- sprintf("%.3s, %02d %.3s %04d %02d:%02d:%02d %s",
- Date::DAYNAMES[self.wday],
- self.day, Date::MONTHNAMES[self.mon],
- self.year, self.hour, self.min, self.sec,
- self.zone)
- end
-end
-
username = 'igrigorik'
-codeswarm_path = '/code/source/code_swarm/'
userdata = JSON.parse(open('http://github.com/api/v1/json/'+username).read)["user"]
puts "Author: #{userdata["name"]}"
@@ -24,7 +13,7 @@ def to_rfc2822
puts userdata["repositories"].collect {|r| r["name"] }.join(", ")
puts "\nCollecting commits"
-history = File.open("user-history.log", "w")
+history = File.open("user-history.log.xml", "w")
# Expected format in user_history.log
# ------------------------------------------------------------------------
@@ -59,7 +48,7 @@ def to_rfc2822
puts "#{repo["name"]}: #{commit["id"]}"
commitdata = JSON.parse(open("http://github.com/api/v1/json/#{username}/#{repo["name"]}/commit/#{commit["id"]}").read)["commit"]
- commit["committed_date"] = DateTime.parse(commit["committed_date"])
+ commit["committed_date"] = Time.parse(commit["committed_date"])
commit["repository"] = repo["name"]
commit["details"] = commitdata
@@ -67,16 +56,10 @@ def to_rfc2822
end
end
-user_commits.sort_by {|c| c["committed_date"]}
-user_commits.each do |commit|
-
- history.write("\n\n------------------------------------------------------------------------\n")
- history.write("r#{commit["id"][0,7]} | #{commit["repository"]} | ")
- history.write("#{commit["committed_date"].strftime("%Y-%m-%d %H:%M:%S %Z")} ")
- history.write("(#{commit["committed_date"].to_rfc2822}) | ")
- history.write("x lines\n")
- history.write("Changed paths:")
+history.puts '<?xml version="1.0"?>'
+history.puts '<file_events>'
+user_commits.sort_by {|c| c["committed_date"] }.each do |commit|
# Sample commit drilldown from API (JSON):
# {
# {"removed": [{"filename": "commands.rb"}, {"filename": "helpers.rb"}],
@@ -94,11 +77,14 @@ def to_rfc2822
# }
%w(added removed modified).each do |action|
- commit["details"][action].each do |file|
- history.write("\n#{action[0,1].capitalize} #{file["filename"]}")
+ commit["details"][action].each_with_index do |file, idx|
+ history.puts %{<event date="#{commit["committed_date"].to_i*1000}"
+ filename="#{file["filename"]}"
+ author="#{commit["repository"]}"
+ weight="#{commit["details"][action][idx]["diff"].size rescue 1}" />}
end
end
end
-# convert git logs to code_swarm XML format (make sure codeswarm/bin is in your path)
-`#{codeswarm_path}/bin/convert_logs.py -g user-history.log -o user-history.log.xml`
+history.puts '</file_events>'
+history.close
View
18 swarm.config
@@ -35,12 +35,12 @@ BoldFontSize=14
#SnapshotLocation=snapshots/code_swarm-#####.png
# Maximum number of Background processes
-MaxThreads=4
+MaxThreads=2
# Project time per frame
# -> 8640000 = 1 day
# -> 21915000 => 1 minute = 1 year
-MillisecondsPerFrame=21915000
+DateSkipper = 8640000
# Background in R,G,B
# Background=255,255,255
@@ -77,7 +77,7 @@ DrawNamesSharp=true
DrawNamesHalos=false
# Draw files (combinatory) :
-DrawFilesSharp=true
+DrawFilesSharp=false
DrawFilesFuzzy=true
DrawFilesJelly=true
@@ -91,18 +91,18 @@ ShowHistory=true
ShowDate=true
# Show edges between authors and files, mostly for debug purpose
-ShowEdges=true
+ShowEdges=false
# Turn on Debug counts.
-ShowDebug=true
+ShowDebug=false
# Natural distance of files to people
EdgeLength=25
# Amount of life to decrement
-EdgeDecrement=-2
-FileDecrement=-2
-PersonDecrement=-7
+#EdgeDecrement=-2
+#FileDecrement=-2
+#PersonDecrement=-7
#Speeds.
#Optional: NodeSpeed=7.0, If used, FileSpeed and PersonSpeed need not be set.
@@ -125,7 +125,7 @@ PersonLife=500
# Highlight percent.
# This is the amount of time that the person or
# file will be highlighted.
-HighlightPct=10
+#HighlightPct=10
# Uncomment to not use avatars
AvatarFetcher=NoAvatar

0 comments on commit 3ba166c

Please sign in to comment.
Something went wrong with that request. Please try again.