lib/bible_gateway.rb in bible_gateway-0.0.6 vs lib/bible_gateway.rb in bible_gateway-0.0.7
- old
+ new
@@ -1,37 +1,40 @@
# coding: utf-8
require 'bible_gateway/version'
require 'nokogiri'
require 'typhoeus'
+require 'uri'
class BibleGatewayError < StandardError; end
class BibleGateway
GATEWAY_URL = "http://www.biblegateway.com"
VERSIONS = {
- :new_international_version => "NIV",
- :new_american_standard_bible => "NASB",
- :the_message => "MSG",
+ :american_standard_version => "ASV",
:amplified_bible => "AMP",
- :new_living_translation => "NLT",
- :king_james_version => "KJV",
- :english_standard_version => "ESV",
+ :common_english_bible => "CEB",
:contemporary_english_version => "CEV",
- :new_king_james_version => "NKJV",
- :new_century_version => "NCV",
- :king_james_version_21st_century => "KJ21",
- :american_standard_version => "ASV",
- :youngs_literal_translation => "YLT",
:darby_translation => "DARBY",
+ :english_standard_version => "ESV",
:holman_christian_standard_bible => "HCSB",
+ :king_james_version => "KJV",
+ :king_james_version_21st_century => "KJ21",
+ :new_american_standard_bible => "NASB",
+ :new_century_version => "NCV",
:new_international_readers_version => "NIRV",
- :wycliffe_new_testament => "WYC",
- :worldwide_english_new_testament => "WE",
+ :new_international_version => "NIV",
:new_international_version_uk => "NIVUK",
+ :new_king_james_version => "NKJV",
+ :new_living_translation => "NLT",
+ :new_revised_standard_version => "NRSV",
+ :the_message => "MSG",
:todays_new_international_version => "TNIV",
:world_english_bible => "WEB",
+ :worldwide_english_new_testament => "WE",
+ :wycliffe_new_testament => "WYC",
+ :youngs_literal_translation => "YLT",
}
def self.versions
VERSIONS.keys
end
@@ -57,12 +60,12 @@
def passage_url(passage)
URI.escape "#{GATEWAY_URL}/passage/?search=#{passage}&version=#{VERSIONS[version]}"
end
def scrape_passage(doc)
- container = doc.css('div#content')
- title = container.css('h1')[0].content
- segment = doc.at('div.result-text-style-normal')
+ container = doc.css('div.container')
+ title = container.css('div.passage-details h1')[0].content.strip
+ segment = doc.at('div.passage-wrap')
segment.search('sup.crossreference').remove # remove cross reference links
segment.search('sup.footnote').remove # remove footnote links
segment.search("div.crossrefs").remove # remove cross references
segment.search("div.footnotes").remove # remove footnotes
segment.search("span.text").each do |span|