chuggle 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in chuggle.gemspec
4
+ gemspec
@@ -0,0 +1,14 @@
1
+ Hopefully-meaningful Metrics
2
+ ============================
3
+
4
+ A quick hack based on Michael Feathers' recent work in project churn and complexity:
5
+ http://www.stickyminds.com/sitewide.asp?Function=edetail&ObjectType=COL&ObjectId=16679&tth=DYN&tt=siteemail&iDyn=2
6
+
7
+
8
+ Usage
9
+ -----
10
+
11
+ chuggle /path/to/git/project
12
+
13
+
14
+ For now it just dumps out a hash of churn + flog metrics
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'chuggle'
3
+ require 'pp'
4
+ pp Chuggle.new(ARGV.first).metrics
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "chuggle/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "chuggle"
7
+ s.version = Chuggle::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Chad Fowler"]
10
+ s.email = ["chad@chadfowler.com"]
11
+ s.homepage = "http://chadfowler.com"
12
+ s.summary = %q{Automates churn + flog scoring on a git repo for a Ruby project}
13
+ s.description = %q{Based on this http://www.stickyminds.com/sitewide.asp?Function=edetail&ObjectType=COL&ObjectId=16679&tth=DYN&tt=siteemail&iDyn=2}
14
+
15
+ s.rubyforge_project = "chuggle"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,41 @@
1
+ require 'flog'
2
+ require 'stringio'
3
+
4
+ class Chuggle
5
+ attr_reader :dir
6
+ attr_reader :metrics
7
+ def initialize(dir)
8
+ @dir = dir
9
+ @metrics = {}
10
+ Dir.chdir(dir) do
11
+ @ruby_files = Dir["**/*\.rb"]
12
+ churn
13
+ flog
14
+ end
15
+ end
16
+
17
+ def churn
18
+ # borrowed from @coreyhaines
19
+ raw = `git log --all -M -C --name-only| sort | uniq -c | sort`.split(/\n/).map(&:split)
20
+ raw.select do |count, filename|
21
+ filename =~ /\.rb$/
22
+ end.each do |count, filename|
23
+ metrics_for(filename)[:churn] = Integer(count)
24
+ end
25
+ end
26
+
27
+ def flog
28
+ flogger = Flog.new
29
+ @ruby_files.each do |filename|
30
+ flogger.flog filename
31
+ report = StringIO.new
32
+ flogger.report(report)
33
+ score = Float(report.string.scan(/^\s+([^:]+).*average$/).flatten.first)
34
+ metrics_for(filename)[:flog] = score
35
+ end
36
+ end
37
+
38
+ def metrics_for(filename)
39
+ @metrics[filename] ||= {}
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ module Chuggle
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chuggle
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Chad Fowler
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-02-17 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Based on this http://www.stickyminds.com/sitewide.asp?Function=edetail&ObjectType=COL&ObjectId=16679&tth=DYN&tt=siteemail&iDyn=2
22
+ email:
23
+ - chad@chadfowler.com
24
+ executables:
25
+ - chuggle
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - .gitignore
32
+ - Gemfile
33
+ - README.md
34
+ - Rakefile
35
+ - bin/chuggle
36
+ - chuggle.gemspec
37
+ - lib/chuggle.rb
38
+ - lib/chuggle/version.rb
39
+ has_rdoc: true
40
+ homepage: http://chadfowler.com
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
55
+ version: "0"
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ requirements: []
65
+
66
+ rubyforge_project: chuggle
67
+ rubygems_version: 1.3.7
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Automates churn + flog scoring on a git repo for a Ruby project
71
+ test_files: []
72
+