Support gravatar avatar rating configuration

Change-Id: Iab8ddbff61b03645347ad124f9e1c76cb7a21af5
diff --git a/src/main/java/com/googlesource/gerrit/plugins/avatars/gravatar/GravatarAvatarProvider.java b/src/main/java/com/googlesource/gerrit/plugins/avatars/gravatar/GravatarAvatarProvider.java
index 29f9ac8..cc6d69f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/avatars/gravatar/GravatarAvatarProvider.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/avatars/gravatar/GravatarAvatarProvider.java
@@ -44,6 +44,7 @@
 
   private final boolean ssl;
   private final String avatarType;
+  private final String avatarRating;
   private final String gravatarUrl;
   private final String changeAvatarUrl;
 
@@ -54,6 +55,8 @@
     ssl = canonicalUrl.startsWith("https://");
     this.avatarType = cfgFactory.getFromGerritConfig(pluginName)
                                 .getString("type", "identicon");
+    this.avatarRating = cfgFactory.getFromGerritConfig(pluginName)
+                                .getString("rating", "pg");
     this.gravatarUrl = cfgFactory.getFromGerritConfig(pluginName)
                                  .getString("gravatarUrl", "www.gravatar.com/avatar/");
     this.changeAvatarUrl = cfgFactory.getFromGerritConfig(pluginName)
@@ -86,9 +89,7 @@
     url.append(gravatarUrl);
     url.append(hex(emailMd5));
     url.append(".jpg");
-    // TODO: currently we force the default icon to identicon and the rating
-    // to PG. It'd be nice to have these be admin-configurable.
-    url.append("?d=" + avatarType + "&r=pg");
+    url.append("?d=" + avatarType + "&r=" + avatarRating);
     if (imageSize > 0) {
       url.append("&s=").append(imageSize);
     }
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
index 3768093..465ae8d 100644
--- a/src/main/resources/Documentation/config.md
+++ b/src/main/resources/Documentation/config.md
@@ -14,10 +14,19 @@
 :	Avatar type in www.gravatar.com service.
 
 	Can be any type supported by the service
-	(404, mm, identicon, monsterid, wavatar, retro, blank, ...).
+	(404, mm, identicon, monsterid, wavatar, retro, robohash, blank, ...).
 
 	Default: identicon
 
+<a id="rating">
+`plugin.@PLUGIN@.rating`
+:	Avatar rating in www.gravatar.com service.
+
+	Can be any rating supported by the service
+	(g, pg, r, x, ...).
+
+	Default: pg
+
 <a id="gravatarUrl">
 `plugin.@PLUGIN@.gravatarUrl`
 :	URL that provides the Gravatar API.