github-graphql 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/github/graphql.rb +36 -2
  3. metadata +15 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b787724c4b0aca62917c14ccc07a76cda920e449
4
- data.tar.gz: 5e39ec8434559bdcc2994fccfc39bae45ab6b999
3
+ metadata.gz: 9e629e8d8167946aa97d0bae290b2e13368f82bc
4
+ data.tar.gz: e39d3eee7f3b1c920da89070e16083d528537c8c
5
5
  SHA512:
6
- metadata.gz: 87926f25f026f87a35a5bb210e3a4b32c83367f69effb38bff62ec77405ab12909ab1cc3cb9b972683e2a3f4dbc068cfa75e7c7b01924317c990505de37ad36f
7
- data.tar.gz: cde8169468bc8f054cbd5f7dbeb60f980cb14827a16063ba59303ca3e05388e3d08c99a18ac611b12f7466e1d2bad2582a34ac34cf0a4f2a0291ff258f34a998
6
+ metadata.gz: f7747e6b7be1dc312d0d849d1b765de98fe5f81d78bcf8fec572c09480455bb261ccf050932348715bac0f0d3bea125ba20ec847ed468f66d8344c7575ddedbb
7
+ data.tar.gz: 41ba79ce2c8074d66586d008af5dd4ef44764c3c427fd41c1d3d1ee40e9df9b89e47afc071917b65b6bdd1852f621755cd17d888494bf4673dfe515b2d01fbbe
@@ -1,11 +1,22 @@
1
- # Github Utilities Module
1
+ ##
2
+ # This module contains tools for interacting with the Github API
3
+ #
2
4
  module Github
3
5
  require 'net/http'
4
6
  require 'uri'
5
7
  require 'json'
6
8
 
7
- # Used to Query the Github GraphQL API
9
+ ##
10
+ # This class is used to make queries to the Github GraphQL API
11
+ #
8
12
  class GraphQL
13
+ ##
14
+ # Expects a valid Github OAuth token & the GraphQL query string,
15
+ # and optionally a hash array of any variables to be passed with
16
+ # the query.
17
+ #
18
+ # With raise an ArgumentError if either token or query are nil.
19
+ #
9
20
  def initialize(token, query, vars = nil)
10
21
  @payload = {}
11
22
 
@@ -20,11 +31,22 @@ module Github
20
31
  payload(query, vars)
21
32
  end
22
33
 
34
+ ##
35
+ # Set the OAuth token.
36
+ #
37
+ # Will raise an ArgumentError if token is nil
38
+ #
23
39
  def token(token)
24
40
  raise ArgumentError, 'Cannot have nil token!', caller if token.nil?
25
41
  @request['Authorization'] = "bearer #{token}"
26
42
  end
27
43
 
44
+ ##
45
+ # Set the query string and optionally the variables to be passed
46
+ # with the query.
47
+ #
48
+ # Will raise an ArgumentError if query is nil
49
+ #
28
50
  def payload(query, vars = nil)
29
51
  raise ArgumentError, 'Cannot have nil query!', caller if query.nil?
30
52
  @payload['query'] = query
@@ -32,12 +54,24 @@ module Github
32
54
  @request.body = @payload.to_json
33
55
  end
34
56
 
57
+ ##
58
+ # Execute the query.
59
+ #
60
+ # Returns a ruby hash array of the response from Github.
61
+ #
35
62
  def query
36
63
  response = @http.request(@request)
37
64
  JSON.parse(response.body)
38
65
  end
39
66
  end
40
67
 
68
+ ##
69
+ # Execute a query to the GraphQL API. Expects a valid Github OAuth
70
+ # token and the query string, and optionally a hash array of the
71
+ # variables to be passed with the query.
72
+ #
73
+ # Will raise an ArgumentException if either token or query are nil.
74
+ #
41
75
  def self.query(token, query, vars = nil)
42
76
  GraphQL.new(token, query, vars).query
43
77
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Smith
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.49'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rdoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '4.2'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement