class GitHubLayer

Constants

REPO_NAME

Public Class Methods

create_repo_if_repo_does_not_exist(directory) click to toggle source
# File lib/homer/github_layer.rb, line 17
def create_repo_if_repo_does_not_exist(directory)
  Dir.chdir(directory)
  return if origin_added_as_remote?
  puts "I need your GitHub login to create a '#{REPO_NAME}' repo if it doesn't exist already"
  login = ask("Login: ")
  password = ask("Password: ") { |q| q.echo = false } 
  github = Github.new(login: login, password: password)
  begin
    github.repos.get(github.login, REPO_NAME)
  rescue Github::Error::NotFound
    github.repos.create(name: REPO_NAME)
  end
  %x{git init .}
  %x{git remote add origin git@github.com:#{login}/#{REPO_NAME}.git}
end
origin_added_as_remote?() click to toggle source
# File lib/homer/github_layer.rb, line 33
def origin_added_as_remote?
  remotes = %x{git remote -v}
  return remotes.include?("origin\t")
end
push(directory) click to toggle source
# File lib/homer/github_layer.rb, line 9
def push(directory)
  create_repo_if_repo_does_not_exist(directory)
  %x{git pull origin master}
  %x{git add .}
  %x{git commit -m "Homer push"}
  %x{git push origin master}
end