Parent

Heroku::Kensa::Client

Attributes

options[RW]

Public Class Methods

new(args, options = {}) click to toggle source
# File lib/heroku/kensa/client.rb, line 11
def initialize(args, options = {})
  @args    = args
  @options = OptParser.parse(args).merge(options)
end

Public Instance Methods

create() click to toggle source
# File lib/heroku/kensa/client.rb, line 34
def create
  app_name = @args.shift
  template = @options[:template]
  raise CommandInvalid.new("Need to supply an application name") unless app_name
  raise CommandInvalid.new("Need to supply a template") unless template
  begin
    Git.clone(app_name, template) and screen.message "Created #{app_name} from #{template} template\n"
    Dir.chdir(app_name)
    @options[:foreman] = true
    init
  rescue Exception => e
    raise CommandInvalid.new("error cloning #{Git.clone_url(template)} into #{app_name}") 
  end
end
init() click to toggle source
# File lib/heroku/kensa/client.rb, line 24
def init
  manifest = Manifest.new(@options)
  protect_current_manifest!
  manifest.write
  screen.message "Initialized new addon manifest in #{filename}\n" 
  if @options[:foreman]
    screen.message "Initialized new .env file for foreman\n"
  end
end
pull() click to toggle source
# File lib/heroku/kensa/client.rb, line 103
def pull
  addon = @args.first || abort('usage: kensa pull <add-on name>')
  protect_current_manifest!

  user, password = ask_for_credentials
  host     = heroku_host
  resource = RestClient::Resource.new(host, user, password)
  manifest = resource["provider/addons/#{addon}"].get(headers)
  File.open(filename, 'w') { |f| f.puts manifest }
  puts "-----> Manifest for \"#{addon}\" received successfully"
end
push() click to toggle source
# File lib/heroku/kensa/client.rb, line 87
def push
  user, password = ask_for_credentials
  host     = heroku_host
  data     = decoded_manifest
  resource = RestClient::Resource.new(host, user, password)
  resource['provider/addons'].post(resolve_manifest, headers)
  puts "-----> Manifest for \"#{data['id']}\" was pushed successfully"
  puts "       Continue at #{(heroku_host)}/provider/addons/#{data['id']}"
rescue RestClient::UnprocessableEntity, RestClient::BadRequest => e
  abort("FAILED: #{e.response}")
rescue RestClient::Unauthorized
  abort("Authentication failure")
rescue RestClient::Forbidden
  abort("Not authorized to push this manifest. Please make sure you have permissions to push it")
end
run() click to toggle source
# File lib/heroku/kensa/client.rb, line 74
def run
  abort "! missing command to run; see usage" if @args.empty?
  run_check AllCheck, :args => @args
end
run!() click to toggle source
# File lib/heroku/kensa/client.rb, line 18
def run!
  command = @args.shift || @options[:command]
  raise CommandInvalid unless command && respond_to?(command)
  send(command)
end
sso() click to toggle source
# File lib/heroku/kensa/client.rb, line 79
def sso
  id = @args.shift || abort("! no id specified; see usage")
  data = decoded_manifest
  sso = Sso.new(data.merge(@options).merge(:id => id)).start
  puts sso.message
  Launchy.open sso.sso_url
end
test() click to toggle source
# File lib/heroku/kensa/client.rb, line 49
def test
  case check = @args.shift
    when "manifest"
      run_check ManifestCheck
    when "provision"
      run_check ManifestCheck, ProvisionCheck
    when "deprovision"
      id = @args.shift || abort("! no id specified; see usage")
      run_check ManifestCheck, DeprovisionCheck, :id => id
    when "planchange"
      id   = @args.shift || abort("! no id specified; see usage")
      plan = @args.shift || abort("! no plan specified; see usage")
      run_check ManifestCheck, PlanChangeCheck, :id => id, :plan => plan
    when "sso"
      id = @args.shift || abort("! no id specified; see usage")
      run_check ManifestCheck, SsoCheck, :id => id
    when "all"
      run_check AllCheck
    when nil
      run_check AllCheck
    else
      abort "! Unknown test '#{check}'; see usage"
  end
end
version() click to toggle source
# File lib/heroku/kensa/client.rb, line 115
def version
  puts "Kensa #{VERSION}"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.