Class: Bard::Github

Inherits:
Struct
  • Object
show all
Defined in:
lib/bard/github.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#project_nameObject

Returns the value of attribute project_name

Returns:

  • (Object)

    the current value of project_name



6
7
8
# File 'lib/bard/github.rb', line 6

def project_name
  @project_name
end

Instance Method Details

#add_deploy_key(title:, key:) ⇒ Object



27
28
29
# File 'lib/bard/github.rb', line 27

def add_deploy_key title:, key:
  post("keys", title:, key:)
end

#get(path, params = {}) ⇒ Object



7
8
9
10
11
12
# File 'lib/bard/github.rb', line 7

def get path, params={}
  request(path) do |uri|
    uri.query = URI.encode_www_form(params)
    Net::HTTP::Get.new(uri)
  end
end

#post(path, params = {}) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/bard/github.rb', line 14

def post path, params={}
  request(path) do |uri|
    Net::HTTP::Post.new(uri).tap do |r|
      r.body = JSON.dump(params)
    end
  end
end

#read_file(path, branch: "master") ⇒ Object



22
23
24
25
# File 'lib/bard/github.rb', line 22

def read_file path, branch: "master"
   = get("contents/#{path}", ref: branch)
  Base64.decode64(["content"])
end