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