committer-tools 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: baeeea1ac89f7a3b0800b9efbbb0d04676cb58a7
4
- data.tar.gz: 52c6f3bfcaca868db6934ee022b86ef893bcfe27
3
+ metadata.gz: 8b286ee5c5cd76c799824efcd9572409d0ff2469
4
+ data.tar.gz: a535dd5f5c529bfecb356b5ae7cb291b51372a4c
5
5
  SHA512:
6
- metadata.gz: 976ad1e3c7a8e839f3aa2e3d80951f2af7bbecfb9997674051d53a50d0a0767223b4cdd2bfbf778f0304c27ca6b350c2bc238085fba8538a7bf81610edd118b2
7
- data.tar.gz: 579389cdec2c8ea71bb73e48df0c8d6c94f8eeeab45b5b27f583a8809cc530fd82f4830e9b7dd09645295e239d3d09df3751e6a6ff228060da1736ae778c2314
6
+ metadata.gz: f0a2708b43a85a7fea21416f315a2bb4ca37a620f0b83cdc31ef81880d99fca98d5095f1c7d7238973a26965e824fea509ab4468132a8f803e4cce27c7980eb6
7
+ data.tar.gz: 39e4c9464b32a39731bfb6556a48d3297bc90a0f1fd7053aafeeaa47cd99a063217475bbaf0afca816b86c38b06aa30d79f44cbec359d8568656dc8018226304
data/README.md CHANGED
@@ -12,6 +12,15 @@ gem install committer-tools
12
12
 
13
13
  ### Usage
14
14
 
15
+ In order to use `committer-tools`, you need to create a `.ctconfig` file
16
+ in your home directory, with the following contents:
17
+
18
+ ```json
19
+ {
20
+ "token": "A GitHub token with user:email scope"
21
+ }
22
+ ```
23
+
15
24
  ##### `committer-tools land`
16
25
 
17
26
  - What this automates:
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'committer-tools'
5
- spec.version = '0.1.3'
5
+ spec.version = '0.1.4'
6
6
  spec.authors = 'Jon Moss'
7
7
  spec.email = 'me@jonathanmoss.me'
8
8
 
@@ -3,12 +3,18 @@ require 'rest-client'
3
3
 
4
4
  class HTTPHelper
5
5
  def self.get(url)
6
- RestClient.get(url, { params: { access_token: ENV['GH_TOKEN'] } }).body
6
+ RestClient.get(url, { params: { access_token: @@token } }).body
7
7
  end
8
8
 
9
9
  def self.get_json(url)
10
10
  JSON.parse(get(url))
11
11
  end
12
+
13
+ def self.with_auth(token, &block)
14
+ @@token = token
15
+ yield block
16
+ @@token = nil
17
+ end
12
18
  end
13
19
 
14
20
  class Lander
@@ -131,13 +137,26 @@ class MetadataCollector
131
137
  end
132
138
 
133
139
  class Preparer
140
+ AUTH_FILE = '.ctconfig'
141
+
134
142
  def run
135
- pr = get_pr()
136
- get_github_pr(pr)
143
+ HTTPHelper.with_auth(get_auth) do
144
+ pr = get_pr()
145
+ get_github_pr(pr)
146
+ end
137
147
  end
138
148
 
139
149
  private
140
150
 
151
+ def get_auth
152
+ begin
153
+ auth = File.read("#{ENV['HOME']}/#{AUTH_FILE}")
154
+ JSON.parse(auth)['token']
155
+ rescue
156
+ raise "Unable to load authentication information"
157
+ end
158
+ end
159
+
141
160
  def get_github_pr(pr)
142
161
  HTTPHelper.get_json(
143
162
  "https://api.github.com/repos/#{pr[:org]}/#{pr[:repo]}/pulls/#{pr[:id]}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: committer-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Moss
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-22 00:00:00.000000000 Z
11
+ date: 2017-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client