Class: XcodeInstaller::Credentials
- Inherits:
-
Object
- Object
- XcodeInstaller::Credentials
- Defined in:
- lib/xcode-installer/credentials.rb
Instance Attribute Summary collapse
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #ask ⇒ Object
-
#initialize ⇒ Credentials
constructor
A new instance of Credentials.
- #load ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize ⇒ Credentials
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
#hostname ⇒ Object
Returns the value of attribute hostname.
5 6 7 |
# File 'lib/xcode-installer/credentials.rb', line 5 def hostname @hostname end |
#password ⇒ Object
Returns the value of attribute password.
5 6 7 |
# File 'lib/xcode-installer/credentials.rb', line 5 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
5 6 7 |
# File 'lib/xcode-installer/credentials.rb', line 5 def username @username end |
Instance Method Details
#ask ⇒ Object
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 |
#load ⇒ Object
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 |
#save ⇒ Object
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 |