Class: OpenGraphReader::Configuration
- Inherits:
-
Object
- Object
- OpenGraphReader::Configuration
- Includes:
- Singleton
- Defined in:
- lib/open_graph_reader/configuration.rb
Overview
The behavior of this library can be tweaked with some parameters. Note that configuration is global, changing it at runtime is not thread safe.
Instance Attribute Summary collapse
-
#strict ⇒ Bool
Strict mode (default:
false). -
#synthesize_image_url ⇒ Bool
Guess image URL when it looks like a path (default:
false). -
#synthesize_title ⇒ Bool
Fallback to the title tag if og:title is missing (default:
false). -
#validate_references ⇒ Bool
Validate references (default:
true). -
#validate_required ⇒ Bool
Validate required (default:
true).
Instance Method Summary collapse
-
#reset_to_defaults! ⇒ Object
Reset configuration to their defaults.
Instance Attribute Details
#strict ⇒ 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.
22 23 24 |
# File 'lib/open_graph_reader/configuration.rb', line 22 def strict @strict end |
#synthesize_image_url ⇒ Bool
Guess image URL when it looks like a path (default: false).
The standard requires og:image, og:image:url and og:image:secure_url to be a full 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.
60 61 62 |
# File 'lib/open_graph_reader/configuration.rb', line 60 def synthesize_image_url @synthesize_image_url end |
#synthesize_title ⇒ 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.
48 49 50 |
# File 'lib/open_graph_reader/configuration.rb', line 48 def synthesize_title @synthesize_title end |
#validate_references ⇒ 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.
39 40 41 |
# File 'lib/open_graph_reader/configuration.rb', line 39 def validate_references @validate_references end |
#validate_required ⇒ Bool
Validate required (default: true).
Validate that required properties exist. If this is enabled and they do not, InvalidObjectError is thrown.
30 31 32 |
# File 'lib/open_graph_reader/configuration.rb', line 30 def validate_required @validate_required end |
Instance Method Details
#reset_to_defaults! ⇒ Object
Reset configuration to their defaults
68 69 70 71 72 73 74 |
# File 'lib/open_graph_reader/configuration.rb', line 68 def reset_to_defaults! @strict = false @validate_required = true @validate_references = true @synthesize_title = false @synthesize_image_url = false end |