Browse files

Checking for a blank config file and whipping up the rake task for ge…

…neration
  • Loading branch information...
1 parent 7dddfc7 commit ccc89c1984ad71e1cda8e7278463f1d1ac799289 @qrush qrush committed Jul 7, 2009
Showing with 28 additions and 10 deletions.
  1. +1 −0 .gitignore
  2. +8 −3 Rakefile
  3. +11 −7 lib/pythagoras.rb
  4. +8 −0 test/pythagoras_test.rb
View
1 .gitignore
@@ -3,3 +3,4 @@
coverage
rdoc
pkg
+config.yml
View
11 Rakefile
@@ -1,6 +1,14 @@
require 'rubygems'
require 'rake'
+task :default => :test
+
+desc "Generate metrics"
+task :generate do
+ require 'lib/pythagoras'
+ Pythagoras.run
+end
+
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
@@ -36,9 +44,6 @@ rescue LoadError
end
end
-
-task :default => :test
-
require 'rake/rdoctask'
Rake::RDocTask.new do |rdoc|
if File.exist?('VERSION.yml')
View
18 lib/pythagoras.rb
@@ -11,20 +11,24 @@ def self.run
return
end
- Integrity.new(config[:integrity_config])
+ if config
+ Integrity.new(config[:integrity_config])
+ else
+ STDERR.puts "Your config file is blank."
+ return
+ end
begin
- projects = Integrity::Project.all
+ Integrity::Project.all.each do |project|
+ Pythagoras.new(project, config)
+ end
rescue Exception => e
- STDERR.puts "No projects were found at #{config[:integrity_config]}: #{e}"
+ STDERR.puts "There was a problem loading your projects from integrity: #{e}"
return
end
-
- projects.each do |project|
- Pythagoras.new(project, config)
- end
end
def initialize(project, config)
+ p project
end
end
View
8 test/pythagoras_test.rb
@@ -21,6 +21,14 @@ class PythagorasTest < Test::Unit::TestCase
mock(Pythagoras).new(anything).never
end
+ before_should "dump out if blank config file" do
+ mock(YAML).load_file("config.yml") { false }
+ mock(STDERR).puts(anything)
+
+ mock(Integrity).new(anything).never
+ mock(Pythagoras).new(anything).never
+ end
+
before_should "dump out if no projects" do
@config = {:integrity_config => "config path"}
mock(YAML).load_file("config.yml") { @config }

0 comments on commit ccc89c1

Please sign in to comment.