replace-downcase-with-casecmp.diff

Go MAEDA, 2015-07-19 06:36

Download (4.57 KB)

View differences:

app/controllers/account_controller.rb (working copy)
102 102
        token = Token.new(:user => user, :action => "recovery")
103 103
        if token.save
104 104
          # Don't use the param to send the email
105
          recipent = user.mails.detect {|e| e.downcase == email.downcase} || user.mail
105
          recipent = user.mails.detect {|e| email.casecmp(e) == 0} || user.mail
106 106
          Mailer.lost_password(token, recipent).deliver
107 107
          flash[:notice] = l(:notice_account_lost_email_sent)
108 108
          redirect_to signin_path
app/helpers/application_helper.rb (working copy)
609 609
      parsed << text
610 610
      if tag
611 611
        if closing
612
          if tags.last == tag.downcase
612
          if tags.last.casecmp(tag) == 0
613 613
            tags.pop
614 614
          end
615 615
        else
app/models/attachment.rb (working copy)
294 294

  
295 295
  def self.latest_attach(attachments, filename)
296 296
    attachments.sort_by(&:created_on).reverse.detect do |att|
297
      att.filename.downcase == filename.downcase
297
      filename.casecmp(att.filename) == 0
298 298
    end
299 299
  end
300 300

  
app/models/custom_field.rb (working copy)
144 144
    possible_values_options = possible_values_options(customized)
145 145
    if possible_values_options.present?
146 146
      keyword = keyword.to_s.downcase
147
      if v = possible_values_options.detect {|text, id| text.downcase == keyword}
147
      if v = possible_values_options.detect {|text, id| keyword.casecmp(text)  == 0}
148 148
        if v.is_a?(Array)
149 149
          v.last
150 150
        else
app/models/mail_handler.rb (working copy)
92 92
    @handler_options = options
93 93
    sender_email = email.from.to_a.first.to_s.strip
94 94
    # Ignore emails received from the application emission address to avoid hell cycles
95
    if sender_email.downcase == Setting.mail_from.to_s.strip.downcase
95
    if sender_email.casecmp(Setting.mail_from.to_s.strip) == 0
96 96
      if logger
97 97
        logger.info  "MailHandler: ignoring email from Redmine emission address [#{sender_email}]"
98 98
      end
......
547 547
    assignable = issue.assignable_users
548 548
    assignee = nil
549 549
    assignee ||= assignable.detect {|a|
550
                   a.mail.to_s.downcase == keyword ||
551
                     a.login.to_s.downcase == keyword
550
                   keyword.casecmp(a.mail.to_s) == 0 ||
551
                     keyword.casecmp(a.login.to_s) == 0
552 552
                 }
553 553
    if assignee.nil? && keyword.match(/ /)
554 554
      firstname, lastname = *(keyword.split) # "First Last Throwaway"
555 555
      assignee ||= assignable.detect {|a|
556
                     a.is_a?(User) && a.firstname.to_s.downcase == firstname &&
557
                       a.lastname.to_s.downcase == lastname
556
                     a.is_a?(User) &&
557
                       firstname.casecmp(a.firstname.to_s) == 0 &&
558
                       lastname.casecmp(a.lastname.to_s) == 0
558 559
                   }
559 560
    end
560 561
    if assignee.nil?
561
      assignee ||= assignable.detect {|a| a.name.downcase == keyword}
562
      assignee ||= assignable.detect {|a| keyword.casecmp(a.name) == 0}
562 563
    end
563 564
    assignee
564 565
  end
app/models/principal.rb (working copy)
130 130
    if principal.nil?
131 131
      -1
132 132
    elsif self.class.name == principal.class.name
133
      self.to_s.downcase <=> principal.to_s.downcase
133
      self.to_s.casecmp(principal.to_s)
134 134
    else
135 135
      # groups after users
136 136
      principal.class.name <=> self.class.name
app/models/project.rb (working copy)
527 527
  end
528 528

  
529 529
  def <=>(project)
530
    name.downcase <=> project.name.downcase
530
    name.casecmp(project.name)
531 531
  end
532 532

  
533 533
  def to_s