Class: Jenkins::CiOrg::Credential

Inherits:
Object
  • Object
show all
Defined in:
lib/jenkins/jenkins-ci.org/credential.rb

Overview

credential to access jenkins-ci.org TODO: move it elsewhere

Constant Summary collapse

CREDENTIAL =
File.expand_path("~/.jenkins-ci.org")

Instance Method Summary collapse

Constructor Details

#initializeCredential

Returns a new instance of Credential.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/jenkins/jenkins-ci.org/credential.rb', line 8

def initialize
  @props = {}

  if File.exists?(CREDENTIAL) then
    File.open(CREDENTIAL,'r') do |f|
      f.each_line do |l|
        if l[0]=='#' then
          return  # comment
        end

        k,v = l.split("=",2)
        @props[k]=v.strip
      end
    end
  end
end

Instance Method Details

#has_credential?Boolean

do we already have the credential?

Returns:

  • (Boolean)


26
27
28
# File 'lib/jenkins/jenkins-ci.org/credential.rb', line 26

def has_credential?
  @props["userName"] && @props["password"]
end

#passwordObject



34
35
36
# File 'lib/jenkins/jenkins-ci.org/credential.rb', line 34

def password
  @props["password"]
end

#user_nameObject



30
31
32
# File 'lib/jenkins/jenkins-ci.org/credential.rb', line 30

def user_name
  @props["userName"]
end