require "bundler/gem_tasks" namespace :metrics do task :lines do lines, codelines, total_lines, total_codelines = 0, 0, 0, 0 for file_name in FileList['lib/**/*.rb', 'bin/generate-api'] f = File.open(file_name) while line = f.gets lines += 1 next if line =~ /^\s*$/ next if line =~ /^\s*#/ codelines += 1 end puts "L: #{sprintf('%4d', lines)}, " + "LOC #{sprintf('%4d', codelines)} | #{file_name}" total_lines += lines total_codelines += codelines lines, codelines = 0, 0 end puts "Total: Lines #{total_lines}, LOC #{total_codelines}" end end require 'rubocop/rake_task' desc 'Run RuboCop on the lib directory' RuboCop::RakeTask.new(:rubocop) do |task| task.patterns = ['lib/**/*.rb'] # only show the files with failures task.formatters = ['progress'] # don't abort rake on failure task.fail_on_error = false end require 'rake/clean' CLOBBER.include('coverage') require 'rspec/core/rake_task' namespace :spec do RSpec::Core::RakeTask.new(:all) end desc 'Alias to spec:all' task 'spec' => 'spec:all' begin require 'yard' require 'yard/rake/yardoc_task' YARD::Rake::YardocTask.new do |t| t.files = ['lib/**/*.rb', 'generated/**/*.rb'] t.options = ['--verbose', '--markup', 'markdown'] end rescue LoadError puts "YARD not available" end task :default => :spec