github-graphql 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/github/graphql.rb +38 -0
  3. metadata +128 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e62c56c9295d5d31712f4a85a0640c8b93c5a090
4
+ data.tar.gz: b181cc3fe475c4b684115f129de753e9227c3647
5
+ SHA512:
6
+ metadata.gz: d6ab9a7fea8e3dc8c39375c19706ba937ded28c30d05539c3f9e9d2455212f9bb2d52594318ef9b16f4e88917fab81adfbbf7a7707ad03728dcf081c8b351c79
7
+ data.tar.gz: bf6425362bf3c0327a3665ab2c2e0f85c188352133418e7939e18e38bf4774b3b7cd5ac8e0fbdbdd3c7eb6dd277f61307cbf317cfe44be20cebf26ba51ac9856
@@ -0,0 +1,38 @@
1
+ # Github Utilities Module
2
+ module Github
3
+ require 'net/http'
4
+ require 'uri'
5
+ require 'json'
6
+
7
+ # Used to Query the Github GraphQL API
8
+ class GraphQL
9
+ def initialize(token, query, vars)
10
+ @payload = {}
11
+
12
+ uri = URI.parse('https://api.github.com/graphql')
13
+ @http = Net::HTTP.new(uri.host, uri.port)
14
+ @http.use_ssl = true
15
+
16
+ @request = Net::HTTP::Post.new(uri)
17
+ @request['Content-type'] = 'application/json'
18
+
19
+ token(token)
20
+ payload(query, vars)
21
+ end
22
+
23
+ def token(token)
24
+ @request['Authorization'] = "bearer #{token}"
25
+ end
26
+
27
+ def payload(query, vars)
28
+ @payload['query'] = query
29
+ @payload['variables'] = vars
30
+ @request.body = @payload.to_json
31
+ end
32
+
33
+ def query
34
+ response = @http.request(@request)
35
+ JSON.parse(response.body)
36
+ end
37
+ end
38
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: github-graphql
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Caleb Smith
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-08-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.49'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.49'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.15'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.15'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '12.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '12.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: test-unit
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.2'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: github_changelog_generator
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.14'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.14'
97
+ description: Send GraphQL API Requests to Github
98
+ email: karagenit@outlook.com
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - lib/github/graphql.rb
104
+ homepage: https://github.com/karagenit/github-graphql
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib/
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.4.8
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Github GraphQL API Query
128
+ test_files: []