class OpenGraphReader::Configuration
The behavior of this library can be tweaked with some parameters. Note that configuration is global, changing it at runtime is not thread safe.
@example
OpenGraphReader.configure do |config| config.strict = true end
Attributes
Discard invalid optional properties (default: false
).
Instead of rendering the entire object invalid, discard invalid optional properties.
@return [Bool]
Parse non ISO8601 datetimes (default: false
).
The standard clearly requires ISO8601 as format for datetime properties. However other formats are seen in the wild. With this setting enabled, the format is guessed.
@return [Bool]
Strict mode (default: false
).
In strict mode, if the fetched site defines an unknown type or property, {InvalidObjectError} is thrown instead of just ignoring those.
@return [Bool]
Guess object URL when it looks like a path (default: false
).
The standard requires the url type to point to a full http or https URL. However it's common practice to put a path relative to the domain URL. When enabled, the library tries to guess the full URL from such a path. Note the object can still turn invalid if it fails to do so.
@return [Bool]
Guess image URL when it looks like a path (default: false
).
See {#synthesize_full_url}
@return [Bool]
Fallback to the title tag if og:title is missing (default: false
).
The standard makes defining og:title required, but it's a common practice to rely on the parser falling back to synthesize it from the title tag. This option enables this feature.
@return [Bool]
Return request URL if og:url is missing (default: false
).
The standard makes defining og:url required, but it's often missing. This enables a fallback that sets the URL to the request URL if none was found.
@return [Bool]
Validate references (default: true
).
If an object should be a reference to another object, validate that it contains an URL. Be careful in turning this off, an attacker could place things like javascript:
links there.
@return [Bool]
Validate required (default: true
).
Validate that required properties exist. If this is enabled and they do not, {InvalidObjectError} is thrown.
@return [Bool]
Public Class Methods
@private
# File lib/open_graph_reader/configuration.rb, line 95 def initialize reset_to_defaults! end
Public Instance Methods
Reset configuration to their defaults
# File lib/open_graph_reader/configuration.rb, line 100 def reset_to_defaults! @strict = false @validate_required = true @validate_references = true @discard_invalid_optional_properties = false @synthesize_title = false @synthesize_url = false @synthesize_full_url = false @synthesize_image_url = false @guess_datetime_format = false end