Class: Hotspots::Repository::Driver::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/hotspots/repository/driver/git.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ Git

Returns a new instance of Git.



7
8
9
# File 'lib/hotspots/repository/driver/git.rb', line 7

def initialize(logger)
  @logger = logger
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



5
6
7
# File 'lib/hotspots/repository/driver/git.rb', line 5

def logger
  @logger
end

Instance Method Details

#log_with_tag(tag, options, &block) ⇒ Object



21
22
23
# File 'lib/hotspots/repository/driver/git.rb', line 21

def log_with_tag(tag, options, &block)
  yield.tap { |raw| logger.log("<#{tag}>\n#{raw}<#{tag}/>", :as => options[:as]) }
end

#pretty_log(options) ⇒ Object



11
12
13
14
# File 'lib/hotspots/repository/driver/git.rb', line 11

def pretty_log(options)
  command = log_with_tag("Input", :as => :green) { Command::Git::Log.new(:since_days => options[:since_days], :message_filter => options[:message_filter]).build }
  log_with_tag("Output", :as => :red) { %x(#{command}) }
end

#show_one_line_names(options) ⇒ Object



16
17
18
19
# File 'lib/hotspots/repository/driver/git.rb', line 16

def show_one_line_names(options)
  command = log_with_tag("Input", :as => :green) { Command::Git::Show.new(:commit_hash => options[:commit_hash]).build }
  log_with_tag("Output", :as => :red) { %x(#{command}) }
end