##// END OF EJS Templates
Removed Rails 2.3 patch for ruby1.9.3....
Jean-Philippe Lang -
r9349:abdcd7d705c5
parent child
Show More
@@ -1,86 +1,81
1 # Patches active_support/core_ext/load_error.rb to support 1.9.3 LoadError message
2 if RUBY_VERSION >= '1.9.3'
3 MissingSourceFile::REGEXPS << [/^cannot load such file -- (.+)$/i, 1]
4 end
5
6 1 require 'active_record'
7 2
8 3 module ActiveRecord
9 4 class Base
10 5 include Redmine::I18n
11 6 def self.named_scope(*args)
12 7 scope(*args)
13 8 end
14 9
15 10 # Translate attribute names for validation errors display
16 11 def self.human_attribute_name(attr, *args)
17 12 l("field_#{attr.to_s.gsub(/_id$/, '')}", :default => attr)
18 13 end
19 14 end
20 15 end
21 16
22 17 module ActionView
23 18 module Helpers
24 19 module DateHelper
25 20 # distance_of_time_in_words breaks when difference is greater than 30 years
26 21 def distance_of_date_in_words(from_date, to_date = 0, options = {})
27 22 from_date = from_date.to_date if from_date.respond_to?(:to_date)
28 23 to_date = to_date.to_date if to_date.respond_to?(:to_date)
29 24 distance_in_days = (to_date - from_date).abs
30 25
31 26 I18n.with_options :locale => options[:locale], :scope => :'datetime.distance_in_words' do |locale|
32 27 case distance_in_days
33 28 when 0..60 then locale.t :x_days, :count => distance_in_days.round
34 29 when 61..720 then locale.t :about_x_months, :count => (distance_in_days / 30).round
35 30 else locale.t :over_x_years, :count => (distance_in_days / 365).floor
36 31 end
37 32 end
38 33 end
39 34 end
40 35 end
41 36
42 37 class Resolver
43 38 def find_all(name, prefix=nil, partial=false, details={}, key=nil, locals=[])
44 39 cached(key, [name, prefix, partial], details, locals) do
45 40 if details[:formats] & [:xml, :json]
46 41 details = details.dup
47 42 details[:formats] = details[:formats].dup + [:api]
48 43 end
49 44 find_templates(name, prefix, partial, details)
50 45 end
51 46 end
52 47 end
53 48 end
54 49
55 50 ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}" }
56 51
57 52 module AsynchronousMailer
58 53 # Adds :async_smtp and :async_sendmail delivery methods
59 54 # to perform email deliveries asynchronously
60 55 %w(smtp sendmail).each do |type|
61 56 define_method("perform_delivery_async_#{type}") do |mail|
62 57 Thread.start do
63 58 send "perform_delivery_#{type}", mail
64 59 end
65 60 end
66 61 end
67 62
68 63 # Adds a delivery method that writes emails in tmp/emails for testing purpose
69 64 def perform_delivery_tmp_file(mail)
70 65 dest_dir = File.join(Rails.root, 'tmp', 'emails')
71 66 Dir.mkdir(dest_dir) unless File.directory?(dest_dir)
72 67 File.open(File.join(dest_dir, mail.message_id.gsub(/[<>]/, '') + '.eml'), 'wb') {|f| f.write(mail.encoded) }
73 68 end
74 69 end
75 70
76 71 ActionMailer::Base.send :include, AsynchronousMailer
77 72
78 73 module ActionController
79 74 module MimeResponds
80 75 class Collector
81 76 def api(&block)
82 77 any(:xml, :json, &block)
83 78 end
84 79 end
85 80 end
86 81 end
General Comments 0
You need to be logged in to leave comments. Login now