forked from scudco/taza
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
144 lines (121 loc) · 4.44 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# -*- ruby -*-
$:.unshift(File.join(File.dirname(__FILE__), 'lib'))
require 'rubygems'
require 'config/vendorized_gems'
require 'taza'
require 'spec/rake/spectask'
require 'spec/rake/verify_rcov'
require 'rake/clean'
ARTIFACTS_DIR = 'artifacts'
RCOV_THRESHOLD = 100.0
RCOV_DIR = File.join(ARTIFACTS_DIR,"rcov")
FLOG_THRESHOLD = 40.0
FLOG_REPORT = File.join(ARTIFACTS_DIR,"flog_report.txt")
FLOG_LINE = /^(.*): \((\d+\.\d+)\)/
begin
require 'jeweler'
Jeweler::Tasks.new do |s|
s.name = 'watircraft'
s.rubyforge_project = 'watir'
s.email = "[email protected]"
s.homepage = nil # TODO
s.summary = "WatirCraft is a testing framework for web testing."
s.description = s.summary
s.authors = ["Bret Pettichord", "Jim Matthews", "Charley Baker", "Adam Anderson"]
s.executables = ["watircraft"]
s.files = $files = FileList["[A-Z]*.*", "{bin,watircraft_generators,lib,spec}/**/*"]
s.add_dependency(%q<taglob>, [">= 1.1.1"])
s.add_dependency(%q<rake>, [">= 0.8.3"])
s.add_dependency(%q<mocha>, [">= 0.9.3"])
s.add_dependency(%q<rspec>, [">= 1.1.12"])
s.add_dependency(%q<rubigen>, [">= 1.4.0"])
s.add_dependency(%q<cucumber>, [">= 0.1.13"])
s.extra_rdoc_files = ["History.txt", "README"]
s.has_rdoc = true
s.rdoc_options = ["--main", "README"]
end
rescue LoadError
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
end
desc "Build RDoc"
task :rdoc do
system "ruby ./vendor/gems/gems/allison-2.0.3/bin/allison --line-numbers --inline-source --main README --title 'Taza RDoc' README History.txt lib "
end
Spec::Rake::SpecTask.new do |t|
t.libs << File.join(File.dirname(__FILE__), 'lib')
t.spec_files = FileList['spec/**/*_spec.rb']
end
desc "Run all examples with RCov"
Spec::Rake::SpecTask.new(:rcov) do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.libs << File.join(File.dirname(__FILE__), 'lib')
t.rcov = true
t.rcov_dir = RCOV_DIR
t.rcov_opts << '--text-report'
t.rcov_opts << '--exclude spec'
end
desc "Verify Code Coverage"
RCov::VerifyTask.new(:verify_rcov => :rcov) do |t|
t.threshold = RCOV_THRESHOLD
t.index_html = File.join(RCOV_DIR,"index.html")
end
desc "Run flog against all the files in the lib"
task :flog do
require "flog"
flogger = Flog.new
flogger.flog_files Dir["lib/**/*.rb"]
FileUtils.mkdir_p(ARTIFACTS_DIR)
File.open(FLOG_REPORT,"w") {|file| flogger.report file }
puts File.readlines(FLOG_REPORT).select {|line| line =~ FLOG_LINE || line =~ /Total Flog/}
end
desc "Verify Flog Score is under threshold"
task :verify_flog => :flog do |t|
# I hate how ridiclous this is (Adam)
messages = File.readlines(FLOG_REPORT).inject([]) do |messages,line|
line =~ FLOG_LINE && $2.to_f > FLOG_THRESHOLD ?
messages << "#{$1}(#{$2})" : messages
end
#lol flog log
flog_log = "\nFLOG THRESHOLD(#{FLOG_THRESHOLD}) EXCEEDED\n #{messages.join("\n ")}\n\n"
raise flog_log unless messages.empty?
end
desc "Run saikuro cyclo complexity against the lib"
task :saikuro do
#we can specify options like ignore filters and set warning or error thresholds
system "ruby vendor/gems/gems/Saikuro-1.1.0/bin/saikuro -c -t -i lib -y 0 -o #{ARTIFACTS_DIR}/saikuro"
end
desc "Should you check-in?"
task :quick_build => [:verify_rcov, :verify_flog]
file "lib/watircraft/version.rb" => 'VERSION.yml' do
require 'jeweler'
version = Jeweler::Version.new('.')
File.open("lib/watircraft/version.rb", "w") do |file|
file.puts "# This file is autogenerated. Do not edit."
file.puts "# Use 'rake version.rb' to update."
file.puts "module WatirCraft; VERSION = '#{version}'; end"
end
end
task :gemspec => ["lib/watircraft/version.rb", 'Manifest.txt']
CLEAN << 'pkg' << FileList['*.gem'] << 'Manifest.txt'
namespace :gem do
desc "Uninstall all watircraft gems"
task :uninstall do
system("call gem uninstall watircraft --all --executables")
end
desc "Install the current watircraft gem (because other install task is broken on windows)"
task :install_win do
require 'jeweler'
version = Jeweler::Version.new('.')
system("call gem install ./pkg/watircraft-#{version}.gem")
end
end
desc "Install new gem after uninstalling previous"
task :install => ['gem:uninstall', 'gem:install_win']
file 'Manifest.txt' => :clean do
File.open('Manifest.txt', 'w') do |f|
f.puts $files
end
end
desc "Build and install a gem from scratch"
task "build" => ['gemspec', 'gem', 'install']
# vim: syntax=ruby