Class: GitWrapper::Commands::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/git_wrapper/commands/git.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location_folder) ⇒ Git

Returns a new instance of Git.



8
9
10
# File 'lib/git_wrapper/commands/git.rb', line 8

def initialize(location_folder)
  @location_folder = location_folder
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



6
7
8
# File 'lib/git_wrapper/commands/git.rb', line 6

def error
  @error
end

#location_folderObject (readonly)

Returns the value of attribute location_folder.



4
5
6
# File 'lib/git_wrapper/commands/git.rb', line 4

def location_folder
  @location_folder
end

#outputObject (readonly)

Returns the value of attribute output.



5
6
7
# File 'lib/git_wrapper/commands/git.rb', line 5

def output
  @output
end

Instance Method Details

#executeObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/git_wrapper/commands/git.rb', line 12

def execute
  begin
    @output, @error, status = Shell.execute("git #{command}", :chdir => @location_folder)
    @success = status.success?

    log = {
      :command => command,
      :location_folder => @location_folder,
      :output => @output,
      :error => @error
    }
    GitWrapper.logger.debug "[GitWrapper] #{log}"

    return result
  rescue Exception => e
    GitWrapper.logger.error "[GitWrapper] #{e.message}"
    @error = e.message
    return false
  end
end

#resultObject



37
38
39
# File 'lib/git_wrapper/commands/git.rb', line 37

def result
  @success
end

#success?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/git_wrapper/commands/git.rb', line 33

def success?
  @success
end