Class: Unixoid::Git

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/unixoid/git.rb

Instance Method Summary collapse

Constructor Details

#initialize(github) ⇒ Git

Returns a new instance of Git.



12
13
14
15
# File 'lib/unixoid/git.rb', line 12

def initialize(github)
  @github = github
  @runner = Runner.new
end

Instance Method Details

#add(file) ⇒ Object



30
31
32
# File 'lib/unixoid/git.rb', line 30

def add(file)
  run("git add #{file}")
end

#add_remoteObject



38
39
40
# File 'lib/unixoid/git.rb', line 38

def add_remote
  run("git remote add origin https://:username::[email protected]/:username/unixoid_submission.git", params: {username: username, password: password})
end

#commit_resultsObject



34
35
36
# File 'lib/unixoid/git.rb', line 34

def commit_results
  run("git commit -m 'Unixoid submission'")
end

#configure(name, email) ⇒ Object



54
55
56
57
# File 'lib/unixoid/git.rb', line 54

def configure(name, email)
  run("git config --global user.name :name", params: {name: name})
  run("git config --global user.email :email", params: {email: email})
end

#configured?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/unixoid/git.rb', line 50

def configured?
  run('git config --get user.email', outcodes: [0, 1]) != '' && run('git config --get user.name', outcodes: [0, 1]) != ''
end

#create_repoObject



26
27
28
# File 'lib/unixoid/git.rb', line 26

def create_repo
  run('git init')
end

#push_resultsObject



42
43
44
# File 'lib/unixoid/git.rb', line 42

def push_results
  run('git push --force -u origin master')
end

#remove_remoteObject



46
47
48
# File 'lib/unixoid/git.rb', line 46

def remove_remote
  run('git remote rm origin')
end

#submit(file) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/unixoid/git.rb', line 17

def submit(file)
  create_repo
  add(file)
  commit_results
  add_remote
  push_results
  remove_remote
end