diff --git a/README.md b/README.md new file mode 100644 index 0000000..f299cad --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +Rake Tasks +========== + +A collection of rake tasks for use with [Trema][trema] and Trema apps. + +[trema]: https://github.com/trema/trema_ruby diff --git a/cucumber.rake b/cucumber.rake new file mode 100644 index 0000000..6833904 --- /dev/null +++ b/cucumber.rake @@ -0,0 +1,8 @@ +begin + require 'cucumber/rake/task' + Cucumber::Rake::Task.new +rescue LoadError + task :cucumber do + $stderr.puts 'Cucumber is disabled' + end +end diff --git a/flog.rake b/flog.rake new file mode 100644 index 0000000..01b64f6 --- /dev/null +++ b/flog.rake @@ -0,0 +1,25 @@ +begin + require 'flog' + + desc 'Analyze for code complexity' + task :flog do + flog = Flog.new(continue: true) + flog.flog(*FileList['*.rb']) + threshold = 0 + + bad_methods = flog.totals.select do |name, score| + !(/##{flog.no_method}$/ =~ name) && score > threshold + end + bad_methods.sort { |a, b| a[1] <=> b[1] }.reverse.each do |name, score| + printf "%8.1f: %s\n", score, name + end + unless bad_methods.empty? + $stderr.puts "#{bad_methods.size} methods "\ + "have a complexity > #{threshold}" + end + end +rescue LoadError + task :flog do + $stderr.puts 'Flog is disabled' + end +end diff --git a/reek.rake b/reek.rake new file mode 100644 index 0000000..8046ecf --- /dev/null +++ b/reek.rake @@ -0,0 +1,11 @@ +begin + require 'reek/rake/task' + Reek::Rake::Task.new do |t| + t.fail_on_error = false + t.verbose = false + end +rescue LoadError + task :reek do + $stderr.puts 'Reek is disabled' + end +end diff --git a/rspec.rake b/rspec.rake new file mode 100644 index 0000000..3c52bf9 --- /dev/null +++ b/rspec.rake @@ -0,0 +1,3 @@ +require 'rspec/core/rake_task' + +RSpec::Core::RakeTask.new diff --git a/rubocop.rake b/rubocop.rake new file mode 100644 index 0000000..ddbc893 --- /dev/null +++ b/rubocop.rake @@ -0,0 +1,8 @@ +begin + require 'rubocop/rake_task' + RuboCop::RakeTask.new +rescue LoadError + task :rubocop do + $stderr.puts 'RuboCop is disabled' + end +end diff --git a/yard.rake b/yard.rake new file mode 100644 index 0000000..b8b2d74 --- /dev/null +++ b/yard.rake @@ -0,0 +1,12 @@ +begin + require 'yard' + YARD::Rake::YardocTask.new do |t| + t.files = ['lib/**/*.rb'] + t.options = ['--no-private'] + t.options << '--debug' << '--verbose' if verbose == true + end +rescue LoadError + task :yard do + $stderr.puts 'YARD is disabled' + end +end