class Preseason::Recipe::Git
Attributes
github_username[R]
public_repo[R]
repo_name[R]
Public Instance Methods
prepare()
click to toggle source
# File lib/preseason/recipe/git.rb, line 4 def prepare remove_file 'README.rdoc' create_file 'README.md', parse_template('readme/README.md.erb') run 'rake db:migrate' run 'git init' run 'git add .' run 'git commit -m "Initial commit"' publish_to_github if github? end
Private Instance Methods
ask_repo_details()
click to toggle source
# File lib/preseason/recipe/git.rb, line 33 def ask_repo_details @repo_name = ask "What do you want to name the Github repo?" @github_username = ask "What is your Github username?" @public_repo = yes? "Is this a public repo? [y/n]" end
ask_repo_owner()
click to toggle source
# File lib/preseason/recipe/git.rb, line 39 def ask_repo_owner @repo_owner = ask "What is the org's name?" end
curl_params()
click to toggle source
# File lib/preseason/recipe/git.rb, line 59 def curl_params %Q[{"name":"#{repo_name}","public":"#{public_repo}"}] end
github?()
click to toggle source
# File lib/preseason/recipe/git.rb, line 29 def github? yes?("Do you want to create a Github repo? [y/n]") end
github_url()
click to toggle source
# File lib/preseason/recipe/git.rb, line 51 def github_url if repo_organization? "https://api.github.com/orgs/#{repo_owner}/repos" else "https://api.github.com/user/repos" end end
publish_to_github()
click to toggle source
# File lib/preseason/recipe/git.rb, line 17 def publish_to_github ask_repo_details ask_repo_owner if repo_organization? run "curl -u '#{github_username}' #{github_url} -d '#{curl_params}' > /dev/null" run "git remote add origin git@github.com:#{repo_owner}/#{repo_name}.git" run 'git push -u origin master' run 'git checkout -b staging' run 'git push -u origin staging' end
repo_organization?()
click to toggle source
# File lib/preseason/recipe/git.rb, line 47 def repo_organization? @repo_organization ||= yes? "Does this repo belong to an organization? [y/n]" end
repo_owner()
click to toggle source
# File lib/preseason/recipe/git.rb, line 43 def repo_owner @repo_owner || github_username end