Class: Augit::Presenter

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::DateHelper, ActionView::Helpers::TextHelper
Defined in:
lib/augit/presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, origin) ⇒ Presenter

Returns a new instance of Presenter.



10
11
12
13
# File 'lib/augit/presenter.rb', line 10

def initialize(name, origin)
  @name = name
  @origin = origin
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/augit/presenter.rb', line 8

def name
  @name
end

#originObject (readonly)

Returns the value of attribute origin.



8
9
10
# File 'lib/augit/presenter.rb', line 8

def origin
  @origin
end

Instance Method Details

#branchObject



37
38
39
# File 'lib/augit/presenter.rb', line 37

def branch
  @branch ||= Branch.new(name, origin)
end

#filesObject



41
42
43
# File 'lib/augit/presenter.rb', line 41

def files
  branch.files
end

#oneline(name, origin) ⇒ Object



32
33
34
35
# File 'lib/augit/presenter.rb', line 32

def oneline(name, origin)
  info = branch_info(name, origin)
  puts "  #{info[:name].send(presenter.age_color(info[:age]))}"
end


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/augit/presenter.rb', line 15

def print
  name = "#{branch.name}".send(age_color(branch.age))
  commits = pluralize(branch.commit_count, 'commit')
  age = distance_of_time_in_words_to_now(branch.age)
  filelist = files.first(5).compact.join("\n    ").light_black
  ellipsis = "\n...\nand #{files.length - 5} more...".light_black

  puts <<-eos

#{name}
  #{branch.author}
  #{commits} - #{age} ago
  #{filelist}#{ellipsis if files.length > 5}
  #{branch.compare_url}
eos
end