Class: GravatarService

Inherits:
Object
  • Object
show all
Includes:
Gitlab::CurrentSettings
Defined in:
app/services/gravatar_service.rb

Instance Method Summary collapse

Methods included from Gitlab::CurrentSettings

#current_application_settings, #fake_application_settings

Instance Method Details

#execute(email, size = nil, scale = 2) ⇒ Object


4
5
6
7
8
9
10
11
12
13
# File 'app/services/gravatar_service.rb', line 4

def execute(email, size = nil, scale = 2)
  if current_application_settings.gravatar_enabled? && email.present?
    size = 40 if size.nil? || size <= 0

    sprintf gravatar_url,
      hash: Digest::MD5.hexdigest(email.strip.downcase),
      size: size * scale,
      email: email.strip
  end
end

#gitlab_configObject


15
16
17
# File 'app/services/gravatar_service.rb', line 15

def gitlab_config
  Gitlab.config.gitlab
end

#gravatar_configObject


19
20
21
# File 'app/services/gravatar_service.rb', line 19

def gravatar_config
  Gitlab.config.gravatar
end

#gravatar_urlObject


23
24
25
26
27
28
29
# File 'app/services/gravatar_service.rb', line 23

def gravatar_url
  if gitlab_config.https
    gravatar_config.ssl_url
  else
    gravatar_config.plain_url
  end
end