Class: Reaper::Client

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/reaper/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



10
11
12
13
14
15
16
17
18
# File 'lib/reaper/client.rb', line 10

def initialize
  # Look for .netrc credentials first; if they don't exist then prompt
  # for login.
  # TODO
  @client = Octokit::Client.new(access_token: ENV['GITHUB_ACCESS_TOKEN'])
  @repo = nil

  # TODO: Add things other than Github.
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



24
25
26
27
28
# File 'lib/reaper/client.rb', line 24

def method_missing(meth, *args, &block)
  raise "Must provide a Github repository." unless @repo

  @client.send(meth, *([@repo] + args), &block)
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



8
9
10
# File 'lib/reaper/client.rb', line 8

def client
  @client
end

#repoObject

Returns the value of attribute repo.



8
9
10
# File 'lib/reaper/client.rb', line 8

def repo
  @repo
end

Instance Method Details

#set_repo(repo) ⇒ Object



20
21
22
# File 'lib/reaper/client.rb', line 20

def set_repo(repo)
  @repo = repo
end