Module: RequestsHelper

Defined in:
public/app/helpers/requests_helper.rb

Constant Summary collapse

VALID_EMAIL_REGEX =

https://stackoverflow.com/questions/22993545/ruby-email-validation-with-regex

/\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i

Instance Method Summary collapse

Instance Method Details

#pass_email_requirements?(result) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
# File 'public/app/helpers/requests_helper.rb', line 6

def pass_email_requirements?(result)
  email_enabled  = AppConfig[:pui_email_enabled]
  use_repo_email = AppConfig[:pui_request_use_repo_email]
  return true unless email_enabled and use_repo_email
  repo_has_valid_email?(result.repository_information)
end

#repo_has_valid_email?(repo) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'public/app/helpers/requests_helper.rb', line 13

def repo_has_valid_email?(repo)
  repo && repo.has_key?('email') && repo['email'] =~ VALID_EMAIL_REGEX
end