class Bimble::GitStrategy::GithubApi

Public Class Methods

new(git_url, oauth_token) click to toggle source
# File lib/bimble/git_strategy/github_api.rb, line 7
def initialize(git_url, oauth_token)
  @git_url = git_url
  @oauth_token = oauth_token
end

Public Instance Methods

commit_file(name, content) click to toggle source
# File lib/bimble/git_strategy/github_api.rb, line 50
def commit_file(name, content)    
  blob_sha = create_blob(content)
  tree_sha = add_blob_to_tree(blob_sha, name)
  commit_sha = commit(tree_sha)
  create_branch(branch_name, commit_sha)
end
commit_to_new_branch() click to toggle source
# File lib/bimble/git_strategy/github_api.rb, line 46
def commit_to_new_branch
  commit_file("Gemfile.lock", File.read("Gemfile.lock"))
end
get_file(name) click to toggle source
# File lib/bimble/git_strategy/github_api.rb, line 42
def get_file(name)
  get_files(name)[name]
end
get_files(name) click to toggle source
# File lib/bimble/git_strategy/github_api.rb, line 29
def get_files(name)
  blobs = blob_shas(default_branch, name)
  Hash[blobs.map{|x| [x[0], blob_content(x[1])]}]
end
in_working_copy() { || ... } click to toggle source
# File lib/bimble/git_strategy/github_api.rb, line 12
def in_working_copy
  Dir.mktmpdir do |tmpdir|
    # Get files
    files = get_files("Gemfile.*").merge(get_files(".*gemspec"))
    Dir.chdir(tmpdir) do
      # Write files
      files.each_pair do |name, content|
        File.open(name, 'w') {|f| f.write(content) }
      end
      # Store md5 of lockfile
      @original_md5 = Digest::MD5.hexdigest(File.read("Gemfile.lock"))
      # Do the business
      yield
    end
  end
end
lock_md5() click to toggle source
# File lib/bimble/git_strategy/github_api.rb, line 34
def lock_md5
  Digest::MD5.hexdigest(File.read("Gemfile.lock"))
end
lockfile_changed?() click to toggle source
# File lib/bimble/git_strategy/github_api.rb, line 38
def lockfile_changed?
  lock_md5 != @original_md5
end