class Jeweler::Tasks

def define

def define
  task :version_required do
    unless jeweler.version_exists?
      abort "Expected VERSION or VERSION.yml to exist. See version:write to create an initial one."
    end
  end
  desc "Build gem"
  task :build do
    jeweler.build_gem
  end
  desc "Install gem using sudo"
  task :install => :build do
    jeweler.install_gem
  end
  desc "Generate and validates gemspec"
  task :gemspec => ['gemspec:generate', 'gemspec:validate']
  namespace :gemspec do
    desc "Validates the gemspec"
    task :validate => :version_required do
      jeweler.validate_gemspec
    end
    desc "Generates the gemspec, using version from VERSION"
    task :generate => :version_required do
      jeweler.write_gemspec
    end
  end
  desc "Displays the current version"
  task :version => :version_required do
    $stdout.puts "Current version: #{jeweler.version}"
  end
  namespace :version do
    desc "Writes out an explicit version. Respects the following environment variables, or defaults to 0: MAJOR, MINOR, PATCH"
    task :write do
      major, minor, patch = ENV['MAJOR'].to_i, ENV['MINOR'].to_i, ENV['PATCH'].to_i
      jeweler.write_version(major, minor, patch, :announce => false, :commit => false)
      $stdout.puts "Updated version: #{jeweler.version}"
    end
    namespace :bump do
      desc "Bump the gemspec by a major version."
      task :major => [:version_required, :version] do
        jeweler.bump_major_version
        $stdout.puts "Updated version: #{jeweler.version}"
      end
      desc "Bump the gemspec by a minor version."
      task :minor => [:version_required, :version] do
        jeweler.bump_minor_version
        $stdout.puts "Updated version: #{jeweler.version}"
      end
      desc "Bump the gemspec by a patch version."
      task :patch => [:version_required, :version] do
        jeweler.bump_patch_version
        $stdout.puts "Updated version: #{jeweler.version}"
      end
    end
  end
  desc "Release the current version. Includes updating the gemspec, pushing, and tagging the release"
  task :release do
    jeweler.release
  end
  desc "Check that runtime and development dependencies are installed" 
  task :check_dependencies do
    jeweler.check_dependencies
  end
  namespace :check_dependencies do
    desc "Check that runtime dependencies are installed"
    task :runtime  do
      jeweler.check_dependencies(:runtime)
    end
    desc"Check that development dependencies are installed"
    task :development do
      jeweler.check_dependencies(:development)
    end
  end
  
end