Class: HackerNote::Git
- Inherits:
-
Object
- Object
- HackerNote::Git
- Defined in:
- lib/hackernote/git.rb
Instance Attribute Summary collapse
-
#git ⇒ Object
Returns the value of attribute git.
Instance Method Summary collapse
-
#initialize ⇒ Git
constructor
A new instance of Git.
-
#setup(project, git_url = '') ⇒ Object
Setup git repo.
Constructor Details
#initialize ⇒ Git
Returns a new instance of Git.
5 6 7 |
# File 'lib/hackernote/git.rb', line 5 def initialize @git = find_executable0 'git' end |
Instance Attribute Details
#git ⇒ Object
Returns the value of attribute git.
4 5 6 |
# File 'lib/hackernote/git.rb', line 4 def git @git end |
Instance Method Details
#setup(project, git_url = '') ⇒ Object
Setup git repo
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/hackernote/git.rb', line 10 def setup(project, git_url='') puts '[+] '.bold + 'Git Setup:'.bold.underline git_cmds = [ "git init", "git add -A", "git commit -m 'Initial #{project} commit'", "git remote add origin #{git_url}", "git push origin master", "git checkout -b YourName", "git push origin YourName" ] if @git puts '[>] '.bold + "Found 'git' installed!" puts '[-] '.bold + "Initiating local git repository." git_cmds.first(4).each do |cmd| puts "[>] ".bold + "executing: " + "#{cmd}".dark_green `#{cmd}` end puts "[!] ".yellow + "Please do not forget to:".underline git_cmds.last(3).each {|cmd| puts "$ ".bold + "#{cmd}".dark_green} else puts '[x] '.red.bold + "git command can't be found (or you didn't use '--git' switch)." puts '[!] '.yellow + "Please install 'git' command then do the following (or use --git switch if git is installed):" git_cmds.each {|cmd| puts "$> ".bold + "#{cmd}".dark_green} end end |