#!/usr/bin/ruby

require 'rubygems'
require 'rake'
require 'rake/clean'

begin
  require 'rubygems/package_task'
rescue LoadError
  require 'rake/gempackagetask'
  rake_gempackage = true
end

task :default => [:package]

# Create the gem specification for packaging
spec = Gem::Specification.new do |s|
    s.name = %q{rhc}
    s.version = /(Version: )(.*)/.match(File.read("client.spec"))[2]
    s.author = "Red Hat"
    s.email = %q{openshift@redhat.com}
    s.summary = %q{OpenShift Express Client Tools}
    s.homepage = %q{https://openshift.redhat.com/app/express}
    s.description = %q{The client tools for the OpenShift Express platform that allow for application management.}
    s.files = FileList['lib/**/*.rb', 'bin/*', 'conf/*'].to_a
    s.files += %w(LICENSE README Rakefile)
    s.executables = ['rhc-chk', 'rhc-create-app', 'rhc-create-domain', 'rhc-ctl-domain', 'rhc-ctl-app', 'rhc-snapshot', 'rhc-domain-info', 'rhc-user-info', 'rhc-tail-files']
    begin
    # Use Ruby version to target F13, RHEL5, Windows and OSX (assume no Xcode)
    if ENV['JSON_PURE'] or (RUBY_VERSION == "1.8.6" or RUBY_PLATFORM =~ /mswin/ or RUBY_PLATFORM =~ /darwin/)
        s.add_dependency('json_pure')
    else
        s.add_dependency('json')
    end
    end
    s.add_dependency('parseconfig')
    if RUBY_VERSION.to_f == 1.9
      s.add_dependency('test-unit')
    end
end

# Define a :package task that bundles the gem
if rake_gempackage
  Rake::GemPackageTask.new(spec) do |pkg, args|
    pkg.need_tar = false
  end
else
  Gem::PackageTask.new(spec) do |pkg, args|
    pkg.need_tar = false
  end
end

# Add the 'pkg' directory to the clean task
CLEAN.include("pkg")
