aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames McKinney <james@slashpoundbang.com>2015-05-21 15:12:57 -0400
committerJames McKinney <james@slashpoundbang.com>2015-05-21 15:12:57 -0400
commitb90a5f5df568dc68e971a7d43532b5163f6cd08e (patch)
treee23905770c2efff46f879ae4b569fbaca086e106
parentdd289908964c8d60e33ce71724dc9e36c3beb765 (diff)
Declare class methods the idiomatic Ruby way
-rw-r--r--app/mailers/outgoing_mailer.rb12
-rw-r--r--app/models/incoming_message.rb4
-rw-r--r--app/models/info_request.rb42
-rw-r--r--app/models/info_request_batch.rb4
-rw-r--r--app/models/mail_server_log.rb20
-rw-r--r--app/models/public_body.rb6
-rw-r--r--app/models/request_classification.rb2
-rw-r--r--lib/acts_as_xapian/acts_as_xapian.rb46
-rw-r--r--lib/configuration.rb2
-rw-r--r--lib/has_tag_string/has_tag_string.rb2
-rw-r--r--lib/mail_handler/backends/mail_extensions.rb8
11 files changed, 74 insertions, 74 deletions
diff --git a/app/mailers/outgoing_mailer.rb b/app/mailers/outgoing_mailer.rb
index 0a1b0aee3..78041d04b 100644
--- a/app/mailers/outgoing_mailer.rb
+++ b/app/mailers/outgoing_mailer.rb
@@ -41,7 +41,7 @@ class OutgoingMailer < ApplicationMailer
# TODO: also OutgoingMessage.get_salutation
# TODO: these look like they should be members of IncomingMessage, but logically they
# need to work even when IncomingMessage is nil
- def OutgoingMailer.name_and_email_for_followup(info_request, incoming_message_followup)
+ def self.name_and_email_for_followup(info_request, incoming_message_followup)
if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to?
return info_request.recipient_name_and_email
else
@@ -51,7 +51,7 @@ class OutgoingMailer < ApplicationMailer
end
end
# Used in the preview of followup
- def OutgoingMailer.name_for_followup(info_request, incoming_message_followup)
+ def self.name_for_followup(info_request, incoming_message_followup)
if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to?
return info_request.public_body.name
else
@@ -60,7 +60,7 @@ class OutgoingMailer < ApplicationMailer
end
end
# Used when making list of followup places to remove duplicates
- def OutgoingMailer.email_for_followup(info_request, incoming_message_followup)
+ def self.email_for_followup(info_request, incoming_message_followup)
if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to?
return info_request.recipient_email
else
@@ -68,7 +68,7 @@ class OutgoingMailer < ApplicationMailer
end
end
# Subject to use for followup
- def OutgoingMailer.subject_for_followup(info_request, outgoing_message, options = {})
+ def self.subject_for_followup(info_request, outgoing_message, options = {})
if outgoing_message.what_doing == 'internal_review'
return "Internal review of " + info_request.email_subject_request(:html => options[:html])
else
@@ -77,7 +77,7 @@ class OutgoingMailer < ApplicationMailer
end
end
# Whether we have a valid email address for a followup
- def OutgoingMailer.is_followupable?(info_request, incoming_message_followup)
+ def self.is_followupable?(info_request, incoming_message_followup)
if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to?
return info_request.recipient_email_valid_for_followup?
else
@@ -86,7 +86,7 @@ class OutgoingMailer < ApplicationMailer
end
end
# Message-ID to use
- def OutgoingMailer.id_for_message(outgoing_message)
+ def self.id_for_message(outgoing_message)
message_id = "ogm-" + outgoing_message.id.to_s
t = Time.now
message_id += "+" + '%08x%05x-%04x' % [t.to_i, t.tv_usec, rand(0xffff)]
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 986eb19f5..dff516f0e 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -726,7 +726,7 @@ class IncomingMessage < ActiveRecord::Base
end
# Search all info requests for
- def IncomingMessage.find_all_unknown_mime_types
+ def self.find_all_unknown_mime_types
for incoming_message in IncomingMessage.find(:all)
for attachment in incoming_message.get_attachments_for_display
raise "internal error incoming_message " + incoming_message.id.to_s if attachment.content_type.nil?
@@ -752,7 +752,7 @@ class IncomingMessage < ActiveRecord::Base
return ret.keys.join(" ")
end
# Return space separated list of all file extensions known
- def IncomingMessage.get_all_file_extensions
+ def self.get_all_file_extensions
return AlaveteliFileTypes.all_extensions.join(" ")
end
end
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 38627df50..2a004980c 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -349,7 +349,7 @@ public
# only they are sent the email address with the has in it. (We don't check
# the prefix and domain, as sometimes those change, or might be elided by
# copying an email, and that doesn't matter)
- def InfoRequest.find_by_incoming_email(incoming_email)
+ def self.find_by_incoming_email(incoming_email)
id, hash = InfoRequest._extract_id_hash_from_email(incoming_email)
if hash_from_id(id) == hash
# Not using find(id) because we don't exception raised if nothing found
@@ -359,7 +359,7 @@ public
# Return list of info requests which *might* be right given email address
# e.g. For the id-hash email addresses, don't match the hash.
- def InfoRequest.guess_by_incoming_email(incoming_message)
+ def self.guess_by_incoming_email(incoming_message)
guesses = []
# 1. Try to guess based on the email address(es)
incoming_message.addresses.each do |address|
@@ -371,7 +371,7 @@ public
end
# Internal function used by find_by_magic_email and guess_by_incoming_email
- def InfoRequest._extract_id_hash_from_email(incoming_email)
+ def self._extract_id_hash_from_email(incoming_email)
# Match case insensitively, FOI officers often write Request with capital R.
incoming_email = incoming_email.downcase
@@ -398,7 +398,7 @@ public
# repeated requests, say once a quarter for time information, then might need to do that.
# TODO: this *should* also check outgoing message joined to is an initial
# request (rather than follow up)
- def InfoRequest.find_existing(title, public_body_id, body)
+ def self.find_existing(title, public_body_id, body)
return InfoRequest.find(:first, :conditions => [ "title = ? and public_body_id = ? and outgoing_messages.body = ?", title, public_body_id, body ], :include => [ :outgoing_messages ] )
end
@@ -538,7 +538,7 @@ public
# The "holding pen" is a special request which stores incoming emails whose
# destination request is unknown.
- def InfoRequest.holding_pen_request
+ def self.holding_pen_request
ir = InfoRequest.find_by_url_title("holding_pen")
if ir.nil?
ir = InfoRequest.new(
@@ -568,7 +568,7 @@ public
# states which require administrator action (hence email administrators
# when they are entered, and offer state change dialog to them)
- def InfoRequest.requires_admin_states
+ def self.requires_admin_states
return ['requires_admin', 'error_message', 'attention_requested']
end
@@ -885,7 +885,7 @@ public
# Display version of status
- def InfoRequest.get_status_description(status)
+ def self.get_status_description(status)
descriptions = {
'waiting_classification' => _("Awaiting classification."),
'waiting_response' => _("Awaiting response."),
@@ -947,7 +947,7 @@ public
return InfoRequest.magic_email_for_id(prefix_part, self.id)
end
- def InfoRequest.magic_email_for_id(prefix_part, id)
+ def self.magic_email_for_id(prefix_part, id)
magic_email = AlaveteliConfiguration::incoming_email_prefix
magic_email += prefix_part + id.to_s
magic_email += "-" + InfoRequest.hash_from_id(id)
@@ -961,7 +961,7 @@ public
self.idhash = InfoRequest.hash_from_id(self.id)
end
- def InfoRequest.create_from_attributes(info_request_atts, outgoing_message_atts, user=nil)
+ def self.create_from_attributes(info_request_atts, outgoing_message_atts, user=nil)
info_request = new(info_request_atts)
default_message_params = {
:status => 'ready',
@@ -975,12 +975,12 @@ public
info_request
end
- def InfoRequest.hash_from_id(id)
+ def self.hash_from_id(id)
return Digest::SHA1.hexdigest(id.to_s + AlaveteliConfiguration::incoming_email_secret)[0,8]
end
# Used to find when event last changed
- def InfoRequest.last_event_time_clause(event_type=nil, join_table=nil, join_clause=nil)
+ def self.last_event_time_clause(event_type=nil, join_table=nil, join_clause=nil)
event_type_clause = ''
event_type_clause = " AND info_request_events.event_type = '#{event_type}'" if event_type
tables = ['info_request_events']
@@ -995,13 +995,13 @@ public
LIMIT 1)"
end
- def InfoRequest.last_public_response_clause()
+ def self.last_public_response_clause()
join_clause = "incoming_messages.id = info_request_events.incoming_message_id
AND incoming_messages.prominence = 'normal'"
last_event_time_clause('response', 'incoming_messages', join_clause)
end
- def InfoRequest.old_unclassified_params(extra_params, include_last_response_time=false)
+ def self.old_unclassified_params(extra_params, include_last_response_time=false)
last_response_created_at = last_public_response_clause()
age = extra_params[:age_in_days] ? extra_params[:age_in_days].days : OLD_AGE_IN_DAYS
params = { :conditions => ["awaiting_description = ?
@@ -1016,7 +1016,7 @@ public
return params
end
- def InfoRequest.count_old_unclassified(extra_params={})
+ def self.count_old_unclassified(extra_params={})
params = old_unclassified_params(extra_params)
if extra_params[:conditions]
condition_string = extra_params[:conditions].shift
@@ -1026,7 +1026,7 @@ public
count(:all, params)
end
- def InfoRequest.get_random_old_unclassified(limit, extra_params)
+ def self.get_random_old_unclassified(limit, extra_params)
params = old_unclassified_params({})
if extra_params[:conditions]
condition_string = extra_params[:conditions].shift
@@ -1038,7 +1038,7 @@ public
find(:all, params)
end
- def InfoRequest.find_old_unclassified(extra_params={})
+ def self.find_old_unclassified(extra_params={})
params = old_unclassified_params(extra_params, include_last_response_time=true)
[:limit, :include, :offset].each do |extra|
params[extra] = extra_params[extra] if extra_params[extra]
@@ -1055,7 +1055,7 @@ public
find(:all, params)
end
- def InfoRequest.download_zip_dir()
+ def self.download_zip_dir()
File.join(Rails.root, "cache", "zips", "#{Rails.env}")
end
@@ -1206,7 +1206,7 @@ public
end
# This is called from cron regularly.
- def InfoRequest.stop_new_responses_on_old_requests
+ def self.stop_new_responses_on_old_requests
# 6 months since last change to request, only allow new incoming messages from authority domains
InfoRequest.update_all "allow_new_responses_from = 'authority_only' where updated_at < (now() - interval '6 months') and allow_new_responses_from = 'anybody' and url_title <> 'holding_pen'"
# 1 year since last change requests, don't allow any new incoming messages
@@ -1300,7 +1300,7 @@ public
return [xapian_similar, xapian_similar_more]
end
- def InfoRequest.request_list(filters, page, per_page, max_results)
+ def self.request_list(filters, page, per_page, max_results)
xapian_object = ActsAsXapian::Search.new([InfoRequestEvent],
InfoRequestEvent.make_query_from_params(filters),
:offset => (page - 1) * per_page,
@@ -1317,7 +1317,7 @@ public
:show_no_more_than => show_no_more_than }
end
- def InfoRequest.recent_requests
+ def self.recent_requests
request_events = []
request_events_all_successful = false
# Get some successful requests
@@ -1364,7 +1364,7 @@ public
return [request_events, request_events_all_successful]
end
- def InfoRequest.find_in_state(state)
+ def self.find_in_state(state)
select("*, #{ last_event_time_clause } as last_event_time").
where(:described_state => state).
order('last_event_time')
diff --git a/app/models/info_request_batch.rb b/app/models/info_request_batch.rb
index 5a20edce8..2847c8134 100644
--- a/app/models/info_request_batch.rb
+++ b/app/models/info_request_batch.rb
@@ -22,7 +22,7 @@ class InfoRequestBatch < ActiveRecord::Base
validates_presence_of :body
# When constructing a new batch, use this to check user hasn't double submitted.
- def InfoRequestBatch.find_existing(user, title, body, public_body_ids)
+ def self.find_existing(user, title, body, public_body_ids)
find(:first, :conditions => ['user_id = ?
AND title = ?
AND body = ?
@@ -70,7 +70,7 @@ class InfoRequestBatch < ActiveRecord::Base
info_request
end
- def InfoRequestBatch.send_batches()
+ def self.send_batches()
find_each(:conditions => "sent_at IS NULL") do |info_request_batch|
unrequestable = info_request_batch.create_batch!
mail_message = InfoRequestBatchMailer.batch_sent(info_request_batch,
diff --git a/app/models/mail_server_log.rb b/app/models/mail_server_log.rb
index 1c69635f3..5fd0f2547 100644
--- a/app/models/mail_server_log.rb
+++ b/app/models/mail_server_log.rb
@@ -26,7 +26,7 @@ class MailServerLog < ActiveRecord::Base
# Doesn't do anything if file hasn't been modified since it was last loaded.
# Note: If you do use rotated log files (rather than files named by date), at some
# point old loaded log lines will get deleted in the database.
- def MailServerLog.load_file(file_name)
+ def self.load_file(file_name)
is_gz = file_name.include?(".gz")
file_name_db = is_gz ? file_name.gsub(".gz", "") : file_name
@@ -63,7 +63,7 @@ class MailServerLog < ActiveRecord::Base
end
# Scan the file
- def MailServerLog.load_exim_log_data(f, done)
+ def self.load_exim_log_data(f, done)
order = 0
f.each do |line|
order = order + 1
@@ -79,7 +79,7 @@ class MailServerLog < ActiveRecord::Base
end
end
- def MailServerLog.load_postfix_log_data(f, done)
+ def self.load_postfix_log_data(f, done)
order = 0
emails = scan_for_postfix_queue_ids(f)
# Go back to the beginning of the file
@@ -100,7 +100,7 @@ class MailServerLog < ActiveRecord::Base
end
end
- def MailServerLog.scan_for_postfix_queue_ids(f)
+ def self.scan_for_postfix_queue_ids(f)
result = {}
f.each do |line|
emails = email_addresses_on_line(line)
@@ -112,7 +112,7 @@ class MailServerLog < ActiveRecord::Base
end
# Retuns nil if there is no queue id
- def MailServerLog.extract_postfix_queue_id_from_syslog_line(line)
+ def self.extract_postfix_queue_id_from_syslog_line(line)
# Assume the log file was written using syslog and parse accordingly
m = SyslogProtocol.parse("<13>" + line).content.match(/^\S+: (\S+):/)
m[1] if m
@@ -120,13 +120,13 @@ class MailServerLog < ActiveRecord::Base
# We also check the email prefix so that we could, for instance, separately handle a staging and production
# instance running on the same server with different email prefixes.
- def MailServerLog.email_addresses_on_line(line)
+ def self.email_addresses_on_line(line)
prefix = Regexp::quote(AlaveteliConfiguration::incoming_email_prefix)
domain = Regexp::quote(AlaveteliConfiguration::incoming_email_domain)
line.scan(/#{prefix}request-[^\s]+@#{domain}/).sort.uniq
end
- def MailServerLog.request_sent?(ir)
+ def self.request_sent?(ir)
case(AlaveteliConfiguration::mta_log_type.to_sym)
when :exim
request_exim_sent?(ir)
@@ -138,7 +138,7 @@ class MailServerLog < ActiveRecord::Base
end
# Look at the log for a request and check that an email was delivered
- def MailServerLog.request_exim_sent?(ir)
+ def self.request_exim_sent?(ir)
# Look for line showing request was sent
found = false
ir.mail_server_logs.each do |mail_server_log|
@@ -157,7 +157,7 @@ class MailServerLog < ActiveRecord::Base
found
end
- def MailServerLog.request_postfix_sent?(ir)
+ def self.request_postfix_sent?(ir)
# dsn=2.0.0 is the magic word that says that postfix delivered the email
# See http://tools.ietf.org/html/rfc3464
ir.mail_server_logs.any? { |l| l.line.include?("dsn=2.0.0") }
@@ -174,7 +174,7 @@ class MailServerLog < ActiveRecord::Base
# NB: There can be several emails involved in a request. This just checks that
# at least one of them has been succesfully sent.
#
- def MailServerLog.check_recent_requests_have_been_sent
+ def self.check_recent_requests_have_been_sent
# Get all requests sent for from 2 to 10 days ago. The 2 day gap is
# because we load mail server log lines via cron at best an hour after they
# are made)
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index feec7cdd5..f0d19139b 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -138,7 +138,7 @@ class PublicBody < ActiveRecord::Base
end
# Set the first letter on a public body or translation
- def PublicBody.set_first_letter(instance)
+ def self.set_first_letter(instance)
unless instance.name.nil? or instance.name.empty?
# we use a regex to ensure it works with utf-8/multi-byte
first_letter = Unicode.upcase instance.name.scan(/^./mu)[0]
@@ -334,7 +334,7 @@ class PublicBody < ActiveRecord::Base
end
# The "internal admin" is a special body for internal use.
- def PublicBody.internal_admin_body
+ def self.internal_admin_body
# Use find_by_sql to avoid the search being specific to a
# locale, since url_name is a translated field:
sql = "SELECT * FROM public_bodies WHERE url_name = 'internal_admin_authority'"
@@ -567,7 +567,7 @@ class PublicBody < ActiveRecord::Base
# Return the domain part of an email address, canonicalised and with common
# extra UK Government server name parts removed.
- def PublicBody.extract_domain_from_email(email)
+ def self.extract_domain_from_email(email)
email =~ /@(.*)/
if $1.nil?
return nil
diff --git a/app/models/request_classification.rb b/app/models/request_classification.rb
index eccf610d7..ab0cd1f21 100644
--- a/app/models/request_classification.rb
+++ b/app/models/request_classification.rb
@@ -16,7 +16,7 @@ class RequestClassification < ActiveRecord::Base
# return classification instances representing the top n
# users, with a 'cnt' attribute representing the number
# of classifications the user has made.
- def RequestClassification.league_table(size, conditions=[])
+ def self.league_table(size, conditions=[])
find(:all, :select => 'user_id, count(*) as cnt',
:conditions => conditions,
:group => 'user_id',
diff --git a/lib/acts_as_xapian/acts_as_xapian.rb b/lib/acts_as_xapian/acts_as_xapian.rb
index 7076fc586..6d65b4586 100644
--- a/lib/acts_as_xapian/acts_as_xapian.rb
+++ b/lib/acts_as_xapian/acts_as_xapian.rb
@@ -39,7 +39,7 @@ module ActsAsXapian
######################################################################
# Module level variables
# TODO: must be some kind of cattr_accessor that can do this better
- def ActsAsXapian.bindings_available
+ def self.bindings_available
$acts_as_xapian_bindings_available
end
class NoXapianRubyBindingsError < StandardError
@@ -58,40 +58,40 @@ module ActsAsXapian
$acts_as_xapian_class_var_init = true
end
- def ActsAsXapian.db
+ def self.db
@@db
end
- def ActsAsXapian.db_path=(db_path)
+ def self.db_path=(db_path)
@@db_path = db_path
end
- def ActsAsXapian.db_path
+ def self.db_path
@@db_path
end
- def ActsAsXapian.writable_db
+ def self.writable_db
@@writable_db
end
- def ActsAsXapian.stemmer
+ def self.stemmer
@@stemmer
end
- def ActsAsXapian.term_generator
+ def self.term_generator
@@term_generator
end
- def ActsAsXapian.enquire
+ def self.enquire
@@enquire
end
- def ActsAsXapian.query_parser
+ def self.query_parser
@@query_parser
end
- def ActsAsXapian.values_by_prefix
+ def self.values_by_prefix
@@values_by_prefix
end
- def ActsAsXapian.config
+ def self.config
@@config
end
######################################################################
# Initialisation
- def ActsAsXapian.init(classname = nil, options = nil)
+ def self.init(classname = nil, options = nil)
if not classname.nil?
# store class and options for use later, when we open the db in readable_init
@@init_values.push([classname,options])
@@ -99,7 +99,7 @@ module ActsAsXapian
end
# Reads the config file (if any) and sets up the path to the database we'll be using
- def ActsAsXapian.prepare_environment
+ def self.prepare_environment
return unless @@db_path.nil?
# barf if we can't figure out the environment
@@ -130,7 +130,7 @@ module ActsAsXapian
# Opens / reopens the db for reading
# TODO: we perhaps don't need to rebuild database and enquire and queryparser -
# but db.reopen wasn't enough by itself, so just do everything it's easier.
- def ActsAsXapian.readable_init
+ def self.readable_init
raise NoXapianRubyBindingsError.new("Xapian Ruby bindings not installed") unless ActsAsXapian.bindings_available
raise "acts_as_xapian hasn't been called in any models" if @@init_values.empty?
@@ -157,7 +157,7 @@ module ActsAsXapian
end
# Make a new query parser
- def ActsAsXapian.init_query_parser
+ def self.init_query_parser
# for queries
@@query_parser = Xapian::QueryParser.new
@@query_parser.stemmer = @@stemmer
@@ -193,7 +193,7 @@ module ActsAsXapian
end
end
- def ActsAsXapian.init_values(values)
+ def self.init_values(values)
values.each do |method, index, prefix, value_type|
raise "Value index '#{index}' must be an Integer, is #{index.class}" unless index.is_a? Integer
if @@values_by_number.include?(index) && @@values_by_number[index] != prefix
@@ -225,7 +225,7 @@ module ActsAsXapian
end
end
- def ActsAsXapian.init_terms(terms)
+ def self.init_terms(terms)
terms.each do |method, term_code, prefix|
raise "Use a single capital letter for term code" if not term_code.match(/^[A-Z]$/)
raise "M and I are reserved for use as the model/id term" if term_code == "M" || term_code == "I"
@@ -244,7 +244,7 @@ module ActsAsXapian
end
end
- def ActsAsXapian.writable_init(suffix = "")
+ def self.writable_init(suffix = "")
raise NoXapianRubyBindingsError.new("Xapian Ruby bindings not installed") unless ActsAsXapian.bindings_available
raise "acts_as_xapian hasn't been called in any models" if @@init_values.empty?
@@ -611,7 +611,7 @@ module ActsAsXapian
# flush your changes. Specifying flush will reduce performance, but make
# sure that each index update is definitely saved to disk before
# logging in the database that it has been.
- def ActsAsXapian.update_index(flush = false, verbose = false)
+ def self.update_index(flush = false, verbose = false)
# STDOUT.puts("start of ActsAsXapian.update_index") if verbose
# Before calling writable_init we have to make sure every model class has been initialized.
@@ -655,7 +655,7 @@ module ActsAsXapian
ActsAsXapian.writable_db.close
end
- def ActsAsXapian.run_job(job, flush, verbose)
+ def self.run_job(job, flush, verbose)
STDOUT.puts("ActsAsXapian.update_index #{job.action} #{job.model} #{job.model_id.to_s} #{Time.now.to_s}") if verbose
begin
@@ -682,7 +682,7 @@ module ActsAsXapian
job.destroy
end
- def ActsAsXapian._is_xapian_db(path)
+ def self._is_xapian_db(path)
is_db = File.exist?(File.join(path, "iamflint")) || File.exist?(File.join(path, "iamchert"))
return is_db
end
@@ -694,7 +694,7 @@ module ActsAsXapian
# happens (i.e. while the .new database is there) - any index update jobs
# are left in the database, and will run after the rebuild has finished.
- def ActsAsXapian.rebuild_index(model_classes, verbose = false, terms = true, values = true, texts = true, safe_rebuild = true)
+ def self.rebuild_index(model_classes, verbose = false, terms = true, values = true, texts = true, safe_rebuild = true)
#raise "when rebuilding all, please call as first and only thing done in process / task" if not ActsAsXapian.writable_db.nil?
prepare_environment
@@ -755,7 +755,7 @@ module ActsAsXapian
@@db_path = old_path
end
- def ActsAsXapian._rebuild_index_safely(model_classes, verbose, terms, values, texts)
+ def self._rebuild_index_safely(model_classes, verbose, terms, values, texts)
batch_size = 1000
for model_class in model_classes
model_class_count = model_class.count
diff --git a/lib/configuration.rb b/lib/configuration.rb
index 30c1286da..ab7d1a65c 100644
--- a/lib/configuration.rb
+++ b/lib/configuration.rb
@@ -92,7 +92,7 @@ module AlaveteliConfiguration
}
end
- def AlaveteliConfiguration.method_missing(name)
+ def self.method_missing(name)
key = name.to_s.upcase
if DEFAULTS.has_key?(key.to_sym)
MySociety::Config.get(key, DEFAULTS[key.to_sym])
diff --git a/lib/has_tag_string/has_tag_string.rb b/lib/has_tag_string/has_tag_string.rb
index a1af8c597..b055afb0a 100644
--- a/lib/has_tag_string/has_tag_string.rb
+++ b/lib/has_tag_string/has_tag_string.rb
@@ -32,7 +32,7 @@ module HasTagString
# Parses a text version of one single tag, such as "a:b" and returns
# the name and value, with nil for value if there isn't one.
- def HasTagStringTag.split_tag_into_name_value(tag)
+ def self.split_tag_into_name_value(tag)
sections = tag.split(/:/)
name = sections[0]
if sections[1]
diff --git a/lib/mail_handler/backends/mail_extensions.rb b/lib/mail_handler/backends/mail_extensions.rb
index 38997861c..b39e54d08 100644
--- a/lib/mail_handler/backends/mail_extensions.rb
+++ b/lib/mail_handler/backends/mail_extensions.rb
@@ -38,7 +38,7 @@ module Mail
# Can be removed when we no longer support Ruby 1.8
class Ruby18
- def Ruby18.b_value_decode(str)
+ def self.b_value_decode(str)
match = str.match(/\=\?(.+)?\?[Bb]\?(.+)?\?\=/m)
if match
encoding = match[1]
@@ -56,7 +56,7 @@ module Mail
str
end
- def Ruby18.q_value_decode(str)
+ def self.q_value_decode(str)
match = str.match(/\=\?(.+)?\?[Qq]\?(.+)?\?\=/m)
if match
encoding = match[1]
@@ -76,7 +76,7 @@ module Mail
private
- def Ruby18.fix_encoding(encoding)
+ def self.fix_encoding(encoding)
case encoding.upcase
when 'UTF8'
'UTF-8'
@@ -87,7 +87,7 @@ module Mail
end
class Ruby19
- def Ruby19.b_value_decode(str)
+ def self.b_value_decode(str)
match = str.match(/\=\?(.+)?\?[Bb]\?(.+)?\?\=/m)
if match
charset = match[1]