Class: Inq::Sources::Github

Inherits:
Object
  • Object
show all
Defined in:
lib/inq/sources/github.rb,
lib/inq/sources/github/pulls.rb,
lib/inq/sources/github/issues.rb,
lib/inq/sources/github/contributions.rb,
lib/inq/sources/github/issue_fetcher.rb

Overview

Contains configuration information for GitHub-based sources.

Defined Under Namespace

Classes: ConfigError, Contributions, IssueFetcher, Issues, Pulls

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Github

Returns a new instance of Github.



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

def initialize(config)
  must_have_key!(config, "sources/github")

  @config = config["sources/github"]

  must_have_key!(@config, "username")
  must_have_key!(@config, "token")
end

Instance Method Details

#access_tokenObject

A GitHub Personal Access Token which goes with username.



38
39
40
# File 'lib/inq/sources/github.rb', line 38

def access_token
  @config["token"]
end

#basic_authObject

A string containing both the GitHub username and access token, used in instances where we use Basic Auth.



44
45
46
# File 'lib/inq/sources/github.rb', line 44

def basic_auth
  "#{username}:#{access_token}"
end

#graphql(query_string) ⇒ Object

Submit a GraphQL query, and convert it from JSON to a Ruby object.



49
50
51
52
53
54
# File 'lib/inq/sources/github.rb', line 49

def graphql(query_string)
  Okay::GraphQL.query(query_string)
    .submit!(:github, {bearer_token: access_token})
    .or_raise!
    .from_json
end

#usernameObject

The GitHub username used for authenticating with GitHub.



33
34
35
# File 'lib/inq/sources/github.rb', line 33

def username
  @config["username"]
end