Cleanup and move common code to common.rb

This commit is contained in:
Joshua Wehner 2015-08-12 17:16:43 -05:00
Родитель 2f72bce79d
Коммит 8158b24dc0
2 изменённых файлов: 9 добавлений и 10 удалений

8
common.rb Normal file
Просмотреть файл

@ -0,0 +1,8 @@
REGEX = %r{github\.com/([^/]+/[^/]+)/issues/(\d+)}
# https://github.com/username/reponame/issues/2
# -> username/reponame, 2
def parse_issue_url(url)
if md = REGEX.match(url)
[md[1], md[2]]
end
end

Просмотреть файл

@ -10,22 +10,13 @@ BANNER
$stderr.sync = true
require 'octokit'
require 'optparse'
require './common'
file = __FILE__
issue_url = ARGV.first
token = ENV['TOKEN']
abort banner if !issue_url || issue_url == '-h'
REGEX = %r{github\.com/([^/]+/[^/]+)/issues/(\d+)}
# https://github.com/username/reponame/issues/2
# -> username/reponame, 2
def parse_issue_url(url)
if md = REGEX.match(url)
[md[1], md[2]]
end
end
Octokit.auto_paginate = true
client = Octokit::Client.new :access_token => ENV['GITHUBTEACHER_TOKEN']