require 'echoe' Echoe.new('flucti-cli', '0.1.16') do |p| p.description = "Command-line interface for managing Flucti VPS's" p.url = "http://doc.flucti.com/cli" p.author = "Roman Le NĂ©grate" p.email = "roman.lenegrate@gmail.com" p.ignore_pattern = "*.gemspec" p.dependencies = ["capistrano ~>2.5", "web-service", "capistrano-fixes"] p.development_dependencies = ["mocha"] p.rdoc_options = %w(--main README.mdown --inline-source --line-numbers --charset UTF-8) end namespace :check do task :namespacing do point_out_source_files "Absence of namespacing" do |file| case file.to_s.split('.').first when /(\b|_)tasks$/, /_pack$/, /\bvendor\b/ false else declaration = file.read. split("\n"). reject { |line| line.strip.empty? || line =~ /^\s*(?:require\b|\$:)/ }. first file if declaration !~ /\Amodule Flucti$/ end end end task :constants do point_out_source_files "Malformed constant names" do |file| malformed = file.read.scan(/\bflucti\b/i).flatten - ["Flucti", "flucti"] [file, *malformed] if malformed.any? end end def point_out_source_files(checking) require 'pathname' result = Pathname.glob('lib/**/*.rb'). map { |file| yield file }. select { |result| result }. map { |file, *rest| rest.any? ? "! %-30s %s" % ["#{file}:", rest.join(' ')] : "! #{file}" } if result.any? puts(checking, *result) else puts "%-30s (none)" % "#{checking}:" end end end task :check => ['check:namespacing', 'check:constants'] task :default => [:check, :test]