Class: Diffhub::GitHub

Inherits:
Object
  • Object
show all
Defined in:
lib/diffhub/git_hub.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGitHub

Returns a new instance of GitHub.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
# File 'lib/diffhub/git_hub.rb', line 8

def initialize
  credentials = YAML.load_file(ENV['HOME'] + '/.github_config.yml')

  raise ArgumentError, "No password given" unless credentials['password']
  raise ArgumentError, "No login given" unless credentials['login']
  @github_gist = ::Github::Gists.new credentials
end

Instance Attribute Details

#github_gistObject (readonly)

Returns the value of attribute github_gist.



6
7
8
# File 'lib/diffhub/git_hub.rb', line 6

def github_gist
  @github_gist
end

Instance Method Details

#upload_diff!Object



16
17
18
19
20
21
# File 'lib/diffhub/git_hub.rb', line 16

def upload_diff!
  response = github_gist.create(:public => false, :files => {'git.diff' => {:content => `git diff`}}, :description => '')
  p response.html_url
rescue Github::Error::UnprocessableEntity
  p 'no diff given'
end