Class: Pig

Inherits:
Object
  • Object
show all
Defined in:
lib/pig.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Pig

Returns a new instance of Pig.



10
11
12
# File 'lib/pig.rb', line 10

def initialize options
  @format = options[:format]
end

Instance Attribute Details

#formatObject

Returns the value of attribute format.



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

def format
  @format
end

Instance Method Details

#call(env) ⇒ Object



23
24
25
# File 'lib/pig.rb', line 23

def call env
  rack_response_template << [history]
end

#historyObject



14
15
16
17
18
19
20
21
# File 'lib/pig.rb', line 14

def history
  results = ""
  commits = repository.log(NUMBER_OF_COMMITS) || []
  commits.each do |commit|
    results << format_commit(commit)
  end
  wrap(results)
end

#rack_response_templateObject



27
28
29
# File 'lib/pig.rb', line 27

def rack_response_template
  [200, {"Content-Type" => "text/#{@format}"}]
end