lib/tonic/gh_pages.rb in tonic-0.0.2 vs lib/tonic/gh_pages.rb in tonic-0.0.3

- old
+ new

@@ -1,11 +1,11 @@ module Tonic module GhPages class << self - def activate - gh_pages + def activate(template = nil) + gh_pages(template) end def push_pages if in_gh_pages_branch? exec 'git push -f origin gh-pages' @@ -19,21 +19,42 @@ def in_gh_pages_branch? branches = sh('git branch') branches.lines.any? { |it| it =~ /\* gh-pages/ } end - def gh_pages + def gh_pages(template = nil) + are_you_in_repo? + if branch_exists? abort 'You shall no pass. First you should delete gh-pages branch' end puts 'Do you really want to create gh-pages branch with tonic? [y/n]' if gets.chomp =~ /y/i check_status create_branch remove_all_files - Template.create + create template commit_changes + end + end + + def create(template = nil) + case template + when 'middleman' + sh 'middleman init ./' + when 'jekyll' + puts 'I will add integration with Jekyll later, now I will install tonic-template' + Template.create + else + Template.create + end + end + + def are_you_in_repo? + check = sh('git status').to_s + if check =~ /Not a git repository/ + abort "You are not in git repo. If you want to create tonic-template write `tonic new my_app`" end end def branch_exists? branches = sh('git branch')