Class: XcodeInstaller::Credentials

Inherits:
Object
  • Object
show all
Defined in:
lib/xcode-installer/credentials.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCredentials

Returns a new instance of Credentials.



7
8
9
10
# File 'lib/xcode-installer/credentials.rb', line 7

def initialize
  super
  @hostname = XcodeInstaller::AppleDeveloperCenter::HOST
end

Instance Attribute Details

#hostnameObject

Returns the value of attribute hostname.



5
6
7
# File 'lib/xcode-installer/credentials.rb', line 5

def hostname
  @hostname
end

#passwordObject

Returns the value of attribute password.



5
6
7
# File 'lib/xcode-installer/credentials.rb', line 5

def password
  @password
end

#usernameObject

Returns the value of attribute username.



5
6
7
# File 'lib/xcode-installer/credentials.rb', line 5

def username
  @username
end

Instance Method Details

#askObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/xcode-installer/credentials.rb', line 17

def ask
      #def username
      #  @username ||= ask "Username:"
      #end
      #def password
      #  @password ||= pw "Password:"
      #end
  @username = ask "Username:"
  @password = pw "Password:"
  ask "Save these credentials in your keychain?"
end

#loadObject



12
13
14
15
# File 'lib/xcode-installer/credentials.rb', line 12

def load
  pw = Security::InternetPassword.find(:server => @hostname)
  @username, @password = pw.attributes['acct'], pw.password if pw
end

#saveObject



29
30
31
32
33
34
35
# File 'lib/xcode-installer/credentials.rb', line 29

def save
  #say_warning "You are already authenticated" if Security::InternetPassword.find(:server => @hostname)

  Security::InternetPassword.add(@hostname, @username, @password)

  say_ok "Account credentials saved"
end