Sha256: 1ad76464ca598df04bd89eabda385c95347d75627ba77f17177be051337c6932

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

module Bushido
  class App
    class << self
      def create(url)
        Bushido::User.load_account

        puts "Creating from #{url} for #{Bushido::User.email}..."

        post({:app => {:url => url}})
      end

      def list
        response = Bushido::Command.get_command("#{Temple}/apps")

        response.each do |app|
          puts app["app"]['subdomain']
        end
      end

      def open(name)
        location = "http://#{name}.#{Bushido::Temple.gsub('http://','')}"
        puts "Opening \"#{location}\" ..."
        exec "open #{location}"
      end

      def get(name, params={})
        url = "#{Temple}/apps/#{name}"
        Bushido::Command.get_command(url, params)
      end

      def put(app, command, params={})
        url = "#{Temple}/apps/#{app}.json"
        params[:command] = command

        Bushido::Command.show_response Bushido::Command.put_command(url, params)
      end

      def post(params)
        url = "#{Temple}/apps"
        Bushido::Command.show_response Bushido::Command.post_command(url, params)
      end

      def show(name)
        result = get name
        puts result.inspect
      end

      def start(name)
        put name, :start
      end

      def stop(name)
        put name, :stop
      end

      def restart(name)
        put name, :restart
      end

      def claim(name)
        put name, :claim
      end

      def update(name)
        put name, :update
      end

      def add_var(name, key, value)
        puts put(name, :add_var, {:key => key, :value => value})
      end

      def remove_var(name, key)
        puts put(name, :remove_var, {:key => key})
      end

      def add_domain(name, domain)
        puts put(name, :add_domain, {:domain => domain})
      end

      def remove_domain(name)
        puts put(name, :remove_domain)
      end

      def clear_logs(name)
        puts put(name, :clear_logs)
      end

      def logs(name)
        puts get(name, {:gift => "logs"})
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bushido-0.0.8 lib/bushido/app.rb