Module: Gravaty

Defined in:
lib/gravaty.rb,
lib/gravaty/parser.rb,
lib/gravaty/version.rb,
lib/gravaty/constants.rb,
lib/gravaty/application.rb,
lib/gravaty/parsers/type.rb,
lib/gravaty/parsers/force.rb,
lib/gravaty/utils/raisers.rb,
lib/gravaty/utils/rfc5322.rb,
lib/gravaty/parsers/avatar.rb,
lib/gravaty/parsers/format.rb,
lib/gravaty/parsers/rating.rb,
lib/gravaty/parsers/secure.rb,
lib/gravaty/parsers/default.rb,
lib/gravaty/parsers/callback.rb,
lib/gravaty/utils/downloader.rb,
lib/gravaty/parsers/pixelsize.rb,
lib/gravaty/utils/rpc_connector.rb

Overview

– gravaty rubocop:disable Style/AsciiComments © 2012 Jon Maken rubocop:enable Style/AsciiComments

This file is part of gravaty.

gravaty is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

gravaty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with gravaty. If not, see <www.gnu.org/licenses/>.

SPDX-FileCopyrightText: 2012 Jon Maken

SPDX-License-Identifier: BSD-3-Clause ++

Defined Under Namespace

Modules: Parsers, Utils Classes: Gravaty, Parser

Constant Summary collapse

VERSION =

Current version number for Gravaty gem.

'11.0.1'
ALLOWED_SIZES =

Allowed sizes (in pixels) for images requests. Currently a range from 1 to 2048 (included).

(1...2048)
ALLOWED_PARAMS =

Allowed parameters names. Currently: avatar, callback, default, force, format, pixelsize, rating, secure and type.

%i[avatar callback default force format
pixelsize rating secure type].freeze
AVATAR_FORMATS =

Allowed formats (extensions) for avatar requests. Currently: jp(e)g, png and gif.

%w[jpg jpeg png gif].freeze
DEFAULT_OPTIONS =

Currently allowed default builtin options. Currently: 404, mp, identicon, monsterid,wavatar, retro, robohash and blank.

%w[404 mp identicon monsterid wavatar retro robohash blank].freeze
IMAGES_FORMATS =

Allowed formats (extensions) for default own images. Currently: jp(e)g, png and gif.

%w[jpg jpeg png gif].freeze
PROFILE_FORMATS =

Allowed formats (extensions) for profile requests. Currently: json, xml, php, vcf and qr.

%w[json xml php vcf qr].freeze
PROFILES =

Formats allowing supplemental options for profile requests. Currently json and qr.

%w[json qr].freeze
RATING_OPTIONS =

Allowed rating options. Currently: g, pg, r and x.

%w[g pg r x].freeze
RPC_ERRORS =

Possible XML-RPC API errors.

[-7, -8, -9, -10, -11, -100].freeze
RPC_METHODS =

Allowed XML-RPC API methods.

%w[grav.exists grav.addresses grav.userimages grav.saveData grav.saveUrl grav.useUserimage
grav.removeImage grav.deleteUserimage grav.test].freeze
RPC_TEST_METHOD =

Default test method for XML-RPC API.

'grav.test'
RPC_URI =

Reference URI for XML-RPC API.

'secure.gravatar.com'

Class Method Summary collapse

Class Method Details

.gravatize(email_address) ⇒ Object

Creates a new Gravaty described by the user’s email. Throws a ArgumentError exception if the supplied email address is nil or not valid according to RFC5322.

Usage
  • new_gravaty = Gravaty::gravatize email

  • new_gravaty = Gravaty::gravatize(email)

Params

email_address, the user’s email address (a syntactically

valid one).

Returns

a Gravaty object for the specified email address.

Raises

ArgumentError, if the supplied email address is nil

or not valid according to RFC 5322.



63
64
65
# File 'lib/gravaty.rb', line 63

def self.gravatize(email_address)
  Gravaty.new email_address, parser
end

.parserObject

Provides the parameters’ parsers object.



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/gravaty.rb', line 70

def self.parser
  parsers = { avatar: Parsers::Avatar.new,
              callback: Parsers::Callback.new,
              default: Parsers::Default.new,
              force: Parsers::Force.new,
              format: Parsers::Format.new,
              pixelsize: Parsers::Pixelsize.new,
              rating: Parsers::Rating.new,
              secure: Parsers::Secure.new,
              type: Parsers::Type.new }

  Parser.new parsers
end