Module: GithubUtil
- Included in:
- GithubApi
- Defined in:
- lib/github_util.rb
Instance Method Summary collapse
- #configure ⇒ Object
- #info(msg) ⇒ Object
- #log(msg) ⇒ Object
- #post(path, options = {}) ⇒ Object
- #post_repo_show(repo, action, options = {}) ⇒ Object
- #post_repo_user(api_path, repo, action, options = {}) ⇒ Object
Instance Method Details
#configure ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/github_util.rb', line 2 def configure git_config = Git.global_config user_name = git_config['user.name'] user_email = git_config['user.email'] github_username = git_config['github.user'] github_token = git_config['github.token'] {:name => github_username, :token => github_token, :login => github_username} end |
#info(msg) ⇒ Object
13 14 15 |
# File 'lib/github_util.rb', line 13 def info(msg) puts msg if log_level > 0 end |
#log(msg) ⇒ Object
17 18 19 |
# File 'lib/github_util.rb', line 17 def log(msg) puts msg if log_level > 1 end |
#post(path, options = {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/github_util.rb', line 22 def post(path, = {}) opts = {'login' => config[:login], 'token' => config[:token]} res = Net::HTTP.post_form URI.parse(path), opts.merge() res.extend(GithubParser) end |
#post_repo_show(repo, action, options = {}) ⇒ Object
37 38 39 40 |
# File 'lib/github_util.rb', line 37 def post_repo_show(repo, action, = {}) res = post_repo_user 'repos/show', repo, action, res.parse_result(action) end |
#post_repo_user(api_path, repo, action, options = {}) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/github_util.rb', line 28 def post_repo_user(api_path, repo, action, = {}) user = [:user] ? [:user] : config[:name] path = 'http://github.com/api/v2/yaml/' path << api_path path << "/#{user}/#{repo}" path << "/#{action}" if action post path, end |