class Devtunnel::Account

Attributes

api_key[RW]
email[RW]
port[RW]
user[RW]

Public Class Methods

forward(port) click to toggle source
# File lib/devtunnel/account.rb, line 38
          def self.forward port
params = {:port => port}
Devtunnel::Api.request :post, "/forward", params
          end
from_creds() click to toggle source
# File lib/devtunnel/account.rb, line 24
def self.from_creds
        fn = File.expand_path("~/.devtunnel_auth")
        raise Exception.new("Please log in first") unless File.exist? fn
        File.open(fn, "r") do |f|
                hash = JSON.parse f.read
                self.new hash
        end
end
login(email, password) click to toggle source
# File lib/devtunnel/account.rb, line 8
def self.login(email, password)
  params = {:basic_username => email, :basic_password => password}
  Devtunnel::Api.request :post, "/login", params
end
logout() click to toggle source
# File lib/devtunnel/account.rb, line 33
def self.logout
        fn = File.expand_path("~/.devtunnel_auth")
        File.unlink(fn) if File.exist? fn
end
signup(email) click to toggle source
# File lib/devtunnel/account.rb, line 13
def self.signup(email)
  params = {:email => email}
  Devtunnel::Api.request :post, "/signup", params
end

Public Instance Methods

write_creds() click to toggle source
# File lib/devtunnel/account.rb, line 18
def write_creds
        File.open(File.expand_path("~/.devtunnel_auth"), "w") do |f|
                f.write({api_key: api_key, email: email}.to_json)
        end
end