Sha256: 537c35dcde10940625fb2787caef1f3e82258cdd3e7f2978919094a7f2eacf61

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

require 'json'
require 'uri'
require 'io/console'

module LgPodPlugin

  class LConfig
    attr_accessor :host
    attr_accessor :base_url
    attr_accessor :project_name
    attr_accessor :access_token
    attr_accessor :refresh_token
    attr_accessor :project

    def initialize
    end

    public
    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)
      user_info = LSqliteDb.shared.query_user_info(user_id)
      if user_info == nil
        user_info = GitLabAPI.get_gitlab_access_token(uri, user_id)
      end
      return nil unless user_info
      config = LConfig.new
      config.host = uri.hostname
      config.access_token = user_info.access_token
      config.refresh_token = user_info.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

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lg_pod_plugin-1.2.2 lib/lg_pod_plugin/config/l_config.rb
lg_pod_plugin-1.2.1 lib/lg_pod_plugin/config/l_config.rb
lg_pod_plugin-1.2.0.1 lib/lg_pod_plugin/config/l_config.rb
lg_pod_plugin-1.2.0.0 lib/lg_pod_plugin/config/l_config.rb