Class: Github::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/gistdoit/github/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(config = UserConfig.new, network = GistDoIt::NetHTTPAdapter.new) ⇒ Client

Returns a new instance of Client.



8
9
10
11
# File 'lib/gistdoit/github/client.rb', line 8

def initialize(config = UserConfig.new, network = GistDoIt::NetHTTPAdapter.new)
  @config = config
  @network = network
end

Instance Method Details

#create_gist(gist) ⇒ Object



13
14
15
16
17
# File 'lib/gistdoit/github/client.rb', line 13

def create_gist(gist)
  @data = gist.to_json
  uri = URI("https://api.github.com/gists")
  @response = @network.post_with_token(token, uri, @data)
end

#github_username=(username) ⇒ Object



23
24
25
# File 'lib/gistdoit/github/client.rb', line 23

def github_username=(username)
  @config.set_github_username(username)
end

#has_github_username?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/gistdoit/github/client.rb', line 19

def has_github_username?
  @config.has_github_username?
end

#responseObject



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

def response
  @response
end

#tokenObject



31
32
33
# File 'lib/gistdoit/github/client.rb', line 31

def token
  @config.token
end