Class: LgPodPlugin::LConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/lg_pod_plugin/config/l_config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLConfig

Returns a new instance of LConfig.



15
16
# File 'lib/lg_pod_plugin/config/l_config.rb', line 15

def initialize
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



11
12
13
# File 'lib/lg_pod_plugin/config/l_config.rb', line 11

def access_token
  @access_token
end

#base_urlObject

Returns the value of attribute base_url.



9
10
11
# File 'lib/lg_pod_plugin/config/l_config.rb', line 9

def base_url
  @base_url
end

#hostObject

Returns the value of attribute host.



8
9
10
# File 'lib/lg_pod_plugin/config/l_config.rb', line 8

def host
  @host
end

#projectObject

Returns the value of attribute project.



13
14
15
# File 'lib/lg_pod_plugin/config/l_config.rb', line 13

def project
  @project
end

#project_nameObject

Returns the value of attribute project_name.



10
11
12
# File 'lib/lg_pod_plugin/config/l_config.rb', line 10

def project_name
  @project_name
end

#refresh_tokenObject

Returns the value of attribute refresh_token.



12
13
14
# File 'lib/lg_pod_plugin/config/l_config.rb', line 12

def refresh_token
  @refresh_token
end

Class Method Details

.get_config(git, uri) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/lg_pod_plugin/config/l_config.rb', line 19

def self.get_config(git, uri)
  return nil unless uri&.hostname
  return nil unless LUtils.is_gitlab_uri(git, uri.hostname)
  user_id = LUserAuthInfo.get_user_id(uri.hostname)
   = LSqliteDb.shared.(user_id)
  if  != nil
     = GitLabAPI.check_gitlab_access_token_valid(uri, )
  else
     = GitLabAPI.get_gitlab_access_token(uri, user_id)
  end
  return nil unless 
  config = LConfig.new
  config.host = uri.hostname
  config.access_token = .access_token
  config.refresh_token = .refresh_token
  config.base_url = LUtils.get_gitlab_base_url(git)
  config.project_name = LUtils.get_git_project_name(git)
  config.project = LSqliteDb.shared.query_project_info(config.project_name, git)
  unless config.project
    config.project = GitLabAPI.request_project_info(config.host, config.project_name, config.access_token, git)
  end
  return config
end