From 1ae0d8b29f76cb4f9df1f6494585e651649d6c19 Mon Sep 17 00:00:00 2001 From: "Timothy N. Tsvetkov" Date: Thu, 10 Mar 2011 14:21:31 +0300 Subject: [PATCH 1/2] added lib to the load path --- config/application.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/application.rb b/config/application.rb index 602250a0e..a3a619bc2 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,7 +9,8 @@ Bundler.require(:default, Rails.env) if defined?(Bundler) module Rosa class Application < Rails::Application -config.action_view.javascript_expansions[:defaults] = %w(jquery rails) + config.action_view.javascript_expansions[:defaults] = %w(jquery rails) + config.autoload_paths += %W(#{config.root}/lib) # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers @@ -33,7 +34,7 @@ config.action_view.javascript_expansions[:defaults] = %w(jquery rails) # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de - config.action_view.javascript_expansions[:defaults] = %w() + config.action_view.javascript_expansions[:defaults] = %w() # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" From 4afc10fa14763983e862c65b3abda30039557599 Mon Sep 17 00:00:00 2001 From: "Timothy N. Tsvetkov" Date: Thu, 10 Mar 2011 14:34:32 +0300 Subject: [PATCH 2/2] added my awesome git diff colorizer --- lib/git/diff/inline_callback.rb | 77 +++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 lib/git/diff/inline_callback.rb diff --git a/lib/git/diff/inline_callback.rb b/lib/git/diff/inline_callback.rb new file mode 100644 index 000000000..02c06a4ee --- /dev/null +++ b/lib/git/diff/inline_callback.rb @@ -0,0 +1,77 @@ +module Git + module Diff + class InlineCallback < ::Diff::Renderer::Base + def addline(line) + " + + + #{line.new_number} + #{render_line(line)} + " + end + + def remline(line) + " + + #{line.old_number} + + #{render_line(line)} + " + end + + def modline(line) + " + + #{line.old_number} + #{line.new_number} + #{render_line(line)} + " + end + + def unmodline(line) + " + + #{line.old_number} + #{line.new_number} + #{render_line(line)} + " + end + + def sepline(line) + " + + … + … + + " + end + + def nonewlineline(line) + " + + #{line.old_number} + #{line.new_number} + #{render_line(line)} + " + end + + protected + def escape(str) + str.to_s.gsub('&', '&').gsub('<', '<').gsub('>', '>').gsub('"', '"') + end + + def render_line(line) + res = '' + if line.inline_changes? + prefix, changed, postfix = line.segments.map{|segment| escape(segment) } + res += "#{prefix}#{changed}#{postfix}" + else + res += escape(line) + end + res += '' + + res + end + end + end +end