Class: Cheat::Controllers::Diff
- Inherits:
-
R
- Object
- R
- Cheat::Controllers::Diff
- Includes:
- Responder
- Defined in:
- lib/cheat/site.rb
Overview
we are going to start consolidating classes with respond_to and what not. diff is the first, as the api and the site will use the same code
Instance Method Summary collapse
Methods included from Responder
Instance Method Details
#get(title, old_version, new_version = nil) ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/cheat/site.rb', line 175 def get(title, old_version, new_version = nil) redirect "#{URL}/b/" and return unless old_version.to_i.nonzero? @sheet = Sheet.detect { |s| s.title == title } @old_sheet = @sheet.find_version(old_version) @new_sheet = (new_version ? @sheet.find_version(new_version) : @sheet) @diffed = Diffr.diff(@old_sheet, @new_sheet) rescue nil respond_to do |wants| wants.html { render :diff } wants.yaml { { @sheet.title => @diffed }.to_yaml } end end |