From: Tom Hughes Date: Sun, 8 Dec 2013 22:49:31 +0000 (+0000) Subject: Drop redundant monkey patches X-Git-Tag: live~5066 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/de9d26c7dfd8f5b5403846e54a1f2678fdbaf7a2 Drop redundant monkey patches --- diff --git a/config/initializers/action_cache_path.rb b/config/initializers/action_cache_path.rb deleted file mode 100644 index b25aa14db..000000000 --- a/config/initializers/action_cache_path.rb +++ /dev/null @@ -1,19 +0,0 @@ -module ActionController - module Caching - module Actions - class ActionCachePath - def initialize(controller, options = {}, infer_extension = true) - if infer_extension - @extension = controller.params[:format] - options.reverse_merge!(:format => @extension) if options.is_a?(Hash) - else - @extension = options[:format] - end - - path = controller.url_for(options).split(%r{://}).last - @path = normalize!(path) - end - end - end - end -end diff --git a/config/initializers/mail.rb b/config/initializers/mail.rb deleted file mode 100644 index b93c3f6d2..000000000 --- a/config/initializers/mail.rb +++ /dev/null @@ -1,25 +0,0 @@ -module Mail - class Ruby18 - def Ruby18.b_value_decode(str) - match = str.match(/\=\?(.+)?\?[Bb]\?(.+)?\?\=/m) - if match - encoding = match[1] - str = Ruby18.decode_base64(match[2]) - require 'iconv' - str = Iconv.conv("UTF-8//TRANSLIT//IGNORE", encoding, str) - end - str - end - - def Ruby18.q_value_decode(str) - match = str.match(/\=\?(.+)?\?[Qq]\?(.+)?\?\=/m) - if match - encoding = match[1] - str = Encodings::QuotedPrintable.decode(match[2].gsub(/_/, '=20')) - require 'iconv' - str = Iconv.conv("UTF-8//TRANSLIT//IGNORE", encoding, str) - end - str - end - end -end diff --git a/config/initializers/postgresql_adapter.rb b/config/initializers/postgresql_adapter.rb index ff1f7f87a..012e401d2 100644 --- a/config/initializers/postgresql_adapter.rb +++ b/config/initializers/postgresql_adapter.rb @@ -2,63 +2,6 @@ if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) module ActiveRecord module ConnectionAdapters class PostgreSQLAdapter - def supports_disable_referential_integrity?() #:nodoc: - version = query("SHOW server_version")[0][0].split('.') - (version[0].to_i >= 9 || (version[0].to_i == 8 && version[1].to_i >= 1)) ? true : false - rescue - return false - end - - def pk_and_sequence_for(table) - # First try looking for a sequence with a dependency on the - # given table's primary key. - result = query(<<-end_sql, 'PK and serial sequence')[0] - SELECT attr.attname, seq.relname - FROM pg_class seq, - pg_attribute attr, - pg_depend dep, - pg_namespace name, - pg_constraint cons - WHERE seq.oid = dep.objid - AND seq.relkind = 'S' - AND attr.attrelid = dep.refobjid - AND attr.attnum = dep.refobjsubid - AND attr.attrelid = cons.conrelid - AND attr.attnum = cons.conkey[1] - AND cons.contype = 'p' - AND dep.classid = '"pg_class"'::regclass - AND dep.refclassid = '"pg_class"'::regclass - AND dep.refobjid = '#{quote_table_name(table)}'::regclass - end_sql - - if result.nil? or result.empty? - # If that fails, try parsing the primary key's default value. - # Support the 7.x and 8.0 nextval('foo'::text) as well as - # the 8.1+ nextval('foo'::regclass). - result = query(<<-end_sql, 'PK and custom sequence')[0] - SELECT attr.attname, - CASE - WHEN split_part(def.adsrc, '''', 2) ~ '.' THEN - substr(split_part(def.adsrc, '''', 2), - strpos(split_part(def.adsrc, '''', 2), '.')+1) - ELSE split_part(def.adsrc, '''', 2) - END - FROM pg_class t - JOIN pg_attribute attr ON (t.oid = attrelid) - JOIN pg_attrdef def ON (adrelid = attrelid AND adnum = attnum) - JOIN pg_constraint cons ON (conrelid = adrelid AND adnum = conkey[1]) - WHERE t.oid = '#{quote_table_name(table)}'::regclass - AND cons.contype = 'p' - AND def.adsrc ~* 'nextval' - end_sql - end - - # [primary_key, sequence] - [result.first, result.last] - rescue - nil - end - def initialize_type_map_with_enums OID.alias_type "format_enum", "text" OID.alias_type "gpx_visibility_enum", "text"