class Mdpresent::Github

Attributes

github[RW]

Public Class Methods

create_gh_pages_branch() click to toggle source
# File lib/mdpresent/github.rb, line 27
def create_gh_pages_branch
  Command.execute I18n.t("commands.github.create_gh_pages")
end
deploy() click to toggle source
# File lib/mdpresent/github.rb, line 45
def deploy
  Command.execute I18n.t("commands.github.switch_to_gh_page")
  Command.execute I18n.t("commands.github.merge_master")
  Command.execute I18n.t("commands.github.switch_to_master")
  Command.execute I18n.t("commands.github.push_gh_pages_to_github")
end
make_initial_commit() click to toggle source
# File lib/mdpresent/github.rb, line 21
def make_initial_commit
  success = true
  success &&= Command.execute I18n.t("commands.git.initial_add")
  success &&= Command.execute I18n.t("commands.git.initial_commit", date_time: Time.now)
end
open() click to toggle source
# File lib/mdpresent/github.rb, line 52
def open
  url = `git config --get remote.origin.url`
  user_name, repo_name = url.strip.match(/http:\/\/github.com\/(.*)\/(.*)/).captures
  Launchy.open("http://#{user_name}.github.com/#{repo_name}")
end
setup() click to toggle source
# File lib/mdpresent/github.rb, line 7
def setup
  Git.setup_git
  # setup the repo if not already set
  setup_repo unless Git.origin_remote_present?

  success = make_initial_commit

  abort "Aborting..git add was unsucessful" unless success

  create_gh_pages_branch unless Git.gh_pages_branch_present?

  Command.execute I18n.t("commands.git.checkout_master")
end
setup_repo() click to toggle source
# File lib/mdpresent/github.rb, line 31
def setup_repo

  print "Enter your github username: "
  user_name = $stdin.gets
  print "Enter the repo name: "
  repo_name = $stdin.gets

  # add remote to git
  unless user_name.nil? || user_name.empty? || repo_name.nil? || repo_name.empty?
    success = Git.git_add_remote(user_name, repo_name)
    fail("unable to add git remote") unless success
  end
end