Class: NeetoCompliance::GithubAccess

Inherits:
Object
  • Object
show all
Defined in:
lib/neeto_compliance/github_access.rb

Class Method Summary collapse

Class Method Details

.get(uri) ⇒ Object



22
23
24
25
26
27
# File 'lib/neeto_compliance/github_access.rb', line 22

def self.get(uri)
  response = Net::HTTP.get_response(
    URI(uri), {
      "Authorization" => "Bearer #{token}"
    }).body
end

.latest_commit_sha(uri) ⇒ Object



18
19
20
# File 'lib/neeto_compliance/github_access.rb', line 18

def self.latest_commit_sha(uri)
  JSON.parse(get(uri))["sha"]
end

.tokenObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/neeto_compliance/github_access.rb', line 7

def self.token
  Base64.decode64(
    File.read("Gemfile.common.rb")
      .split("encoded_github_auth_string =")[1]
      .split("%{")[1]
      .split("}")[0]
      .gsub("\\r", "\r")
      .gsub("\\n", "\n")
   ).split(":")[1]
end