Bible::OBML::Gateway - Bible Gateway content conversion to Open Bible Markup Language
version 2.05
use Bible::OBML::Gateway; my $bg = Bible::OBML::Gateway->new; $bg->translation('NIV'); my $obml_obj = $bg->get( 'Romans 12' ); print $bg->get( 'Romans 12', 'NASB' )->obml, "\n"; my $translations = $bg->translations; my $structure = $bg->structure('NASB');
This module consumes Bible Gateway content and returns useful data-bearing objects or data structures. In the common case, it will accept a Bible reference and return a Bible::OBML object loaded with parsed content.
The following methods are supported.
Instantiates a new gateway object. You can optionally pass a translation acronym to be used on subsequent requests.
my $bg = Bible::OBML::Gateway->new( translation => 'NIV' );
This method requires a text input containing a Bible reference that can be understood as a single chapter or single, unbroken run of verses. For example, "Romans 12" or "Ro 12:13-17" are acceptable, but "Romans 12:13-17, 19" is not.
You can optionally also provide an overriding translation. If not specified, the object's translation (set via the translation attribute) will be used.
translation
The method will get the raw HTML content from Bible Gateway, parse it, and return a Bible::OBML object loaded with the data.
my $obml_obj = $bg->get( 'Romans 12' ); print $bg->get( 'Romans 12', 'NASB' )->obml, "\n";
Internally, all this method does is call fetch, pass that output to parse, and then load output that into a new Bible::OBML object.
fetch
parse
If all you want to do is fetch the HTML from Bible Gateway, you can use this method. It uses the same signature as get and returns the returned raw HTML.
get
This method requires source HTML like what you might get from a fetch call, which it will then parse and return a special sort of HTML that can be loaded directly into a Bible::OBML object via it's html method. (See Bible::OBML for more information.)
html
This method will return a data structure consisting of data describing available translations on Bible Gateway per spoken language. It returns an arrayref containing a hashref per language. Each hashref contains an arrayref of translations, each represented by a hashref.
my $translations = $bg->translations;
This a simplified example of the data structure:
[ { acronym => 'EN', language => 'English', translations => [ { acronym => 'NIV', translation => 'New International Version', }, ], }, ]
This method will return a data structure consisting of data describing the structure of a given translation of the Bible from Bible Gateway. It can optionally be provided an overriding translation. If not specified, the object's translation (set via the translation attribute) will be used. The data structure returned is an arrayref of hashrefs, each representing a book.
my $structure = $bg->structure('NASB');
[ { testament => 'NT', display => '2 John', osis => '2John', intro => 0, num_chapters => 1, chapters => [ { chapter => 1, type => 'heading', content => [ "Walk According to His Commandments", ], }, ], } ]
Attributes can be set in a call to new or explicitly as a get/set method.
new
my $bg = Bible::OBML::Gateway->new( translation => 'NIV' ); $bg->translation('NIV'); say $bg->translation;
Get or set the current translation acronym. The default if not explicitly set will be "NIV".
say $bg->translation; $bg->translation('NIV');
This provides access to the base URL, contained within a Mojo::URL object.
$bg->url( Mojo::URL->new('https://www.biblegateway.com/passage/') );
This provides access to the Mojo::UserAgent user agent.
$bg->ua->transactor->name("Your Application's Name");
This provides access to the Bible::Reference object used to parse and canonicalize Bible references.
$bg->reference->bible('Catholic');
Depending on which translation you get from Bible Gateway, you may need to alter the bible setting of reference, as in the example immediately above. By default, bible is set to "Protestant".
bible
reference
Bible::OBML, Bible::Reference, Mojo::URL, Mojo::UserAgent.
You can also look for additional information at:
GitHub
MetaCPAN
GitHub Actions
Codecov
CPANTS
CPAN Testers
Gryphon Shafer <gryphon@cpan.org>
This software is Copyright (c) 2017-2050 by Gryphon Shafer.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install Bible::OBML::Gateway, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bible::OBML::Gateway
CPAN shell
perl -MCPAN -e shell install Bible::OBML::Gateway
For more information on module installation, please visit the detailed CPAN module installation guide.