summaryrefslogtreecommitdiffstats
path: root/app/models/mail_handler.rb
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2019-10-19 13:34:05 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2019-10-19 13:34:05 +0000
commitf2b274476ae775a147df8a44ea0c3fdbd184c6ff (patch)
tree32b924883249e54bcabcaad79ce3536cd904e69e /app/models/mail_handler.rb
parentd836d9cc6944c19176769ecfa8bececb84cd08bf (diff)
downloadredmine-f2b274476ae775a147df8a44ea0c3fdbd184c6ff.tar.gz
redmine-f2b274476ae775a147df8a44ea0c3fdbd184c6ff.zip
code cleanup: rubocop: fix Lint/IneffectiveAccessModifier in app/models/mail_handler.rb
git-svn-id: http://svn.redmine.org/redmine/trunk@18782 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/mail_handler.rb')
-rw-r--r--app/models/mail_handler.rb64
1 files changed, 33 insertions, 31 deletions
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index 3e7b02b90..7f03591e2 100644
--- a/app/models/mail_handler.rb
+++ b/app/models/mail_handler.rb
@@ -523,18 +523,6 @@ class MailHandler < ActionMailer::Base
subject.strip[0,255]
end
- # Converts a HTML email body to text
- def self.html_body_to_text(html)
- Redmine::WikiFormatting.html_parser.to_text(html)
- end
-
- # Converts a plain/text email body to text
- def self.plain_text_body_to_text(text)
- # Removes leading spaces that would cause the line to be rendered as
- # preformatted text with textile
- text.gsub(/^ +(?![*#])/, '')
- end
-
def self.assign_string_attribute_with_limit(object, attribute, value, limit=nil)
limit ||= object.class.columns_hash[attribute.to_s].limit || 255
value = value.to_s.slice(0, limit)
@@ -542,29 +530,43 @@ class MailHandler < ActionMailer::Base
end
private_class_method :assign_string_attribute_with_limit
- # Returns a User from an email address and a full name
- def self.new_user_from_attributes(email_address, fullname=nil)
- user = User.new
+ # Singleton class method is public
+ class << self
+ # Converts a HTML email body to text
+ def html_body_to_text(html)
+ Redmine::WikiFormatting.html_parser.to_text(html)
+ end
+
+ # Converts a plain/text email body to text
+ def plain_text_body_to_text(text)
+ # Removes leading spaces that would cause the line to be rendered as
+ # preformatted text with textile
+ text.gsub(/^ +(?![*#])/, '')
+ end
- # Truncating the email address would result in an invalid format
- user.mail = email_address
- assign_string_attribute_with_limit(user, 'login', email_address, User::LOGIN_LENGTH_LIMIT)
+ # Returns a User from an email address and a full name
+ def new_user_from_attributes(email_address, fullname=nil)
+ user = User.new
- names = fullname.blank? ? email_address.gsub(/@.*$/, '').split('.') : fullname.split
- assign_string_attribute_with_limit(user, 'firstname', names.shift, 30)
- assign_string_attribute_with_limit(user, 'lastname', names.join(' '), 30)
- user.lastname = '-' if user.lastname.blank?
- user.language = Setting.default_language
- user.generate_password = true
- user.mail_notification = 'only_my_events'
+ # Truncating the email address would result in an invalid format
+ user.mail = email_address
+ assign_string_attribute_with_limit(user, 'login', email_address, User::LOGIN_LENGTH_LIMIT)
- unless user.valid?
- user.login = "user#{Redmine::Utils.random_hex(6)}" unless user.errors[:login].blank?
- user.firstname = "-" unless user.errors[:firstname].blank?
- (puts user.errors[:lastname]; user.lastname = "-") unless user.errors[:lastname].blank?
- end
+ names = fullname.blank? ? email_address.gsub(/@.*$/, '').split('.') : fullname.split
+ assign_string_attribute_with_limit(user, 'firstname', names.shift, 30)
+ assign_string_attribute_with_limit(user, 'lastname', names.join(' '), 30)
+ user.lastname = '-' if user.lastname.blank?
+ user.language = Setting.default_language
+ user.generate_password = true
+ user.mail_notification = 'only_my_events'
- user
+ unless user.valid?
+ user.login = "user#{Redmine::Utils.random_hex(6)}" unless user.errors[:login].blank?
+ user.firstname = "-" unless user.errors[:firstname].blank?
+ (puts user.errors[:lastname]; user.lastname = "-") unless user.errors[:lastname].blank?
+ end
+ user
+ end
end
# Creates a User for the +email+ sender