bible_gateway 0.0.7 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +1 -1
- data/README.md +7 -3
- data/VERSION +1 -1
- data/bible_gateway.gemspec +1 -1
- data/lib/bible_gateway.rb +30 -7
- data/lib/bible_gateway/version.rb +1 -1
- data/spec/bible_gateway_spec.rb +35 -19
- metadata +20 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 936c48f6f63535b6b45f26270bd8f736b33547ee5143361a0ead5d3c9c9ab8f8
|
4
|
+
data.tar.gz: 93042e59fe2c1a5987337bf63f47fbda4742c0f6a365d78e0e3845ee610eb1ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09d00df060704129a77c21eb1e3b1ad2d3576d61d420ab2d4adc155a19b479c0be19d4a648afc4a6cbf703a9c21a97fae21650b8f4bec13ff11fe7758b8036b3'
|
7
|
+
data.tar.gz: 66d98831f4cbb6243f10156ebe3c70894205351fbd50ef12dadf1c2bfc9c75ab1ff43828b25d321eadd4bd2301d17b9aee3e328365adec9e34c9d133189ddfbc
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# BibleGateway
|
2
2
|
|
3
3
|
Travis CI:
|
4
|
-
[![Build Status](https://travis-ci.org/
|
5
|
-
1.9.
|
4
|
+
[![Build Status](https://travis-ci.org/bibleable/bible_gateway.png?branch=master)](https://travis-ci.org/bibleable/bible_gateway)
|
5
|
+
1.9.3, 2.0.0, 2.1.1
|
6
6
|
|
7
|
-
An unofficial 'API' for BibleGateway.com.
|
7
|
+
An unofficial 'API' for BibleGateway.com.
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
@@ -44,3 +44,7 @@ Or install it yourself as:
|
|
44
44
|
|
45
45
|
See [LICENSE](License.txt) for details.
|
46
46
|
Most Bible translations are copyrighted. Please see [BibleGateway.com](http://biblegateway.com) for more information.
|
47
|
+
|
48
|
+
## Thanks
|
49
|
+
|
50
|
+
Special thanks to Geoffrey Dagley([@gdagley](http://github.com/gdagley)) - the original creator of `bible_gateway` rubygem.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.12
|
data/bible_gateway.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "bible_gateway"
|
8
8
|
spec.version = BibleGateway::VERSION
|
9
9
|
spec.authors = ["Geoffrey Dagley"]
|
10
|
-
spec.email = ["gdagley@gmail.com"]
|
10
|
+
spec.email = ["gdagley@gmail.com", "bibleableproject@gmail.com"]
|
11
11
|
spec.description = %q{An unofficial 'API' for BibleGateway.com.}
|
12
12
|
spec.summary = %q{An unofficial 'API' for BibleGateway.com.}
|
13
13
|
spec.homepage = "https://github.com/gdagley/bible_gateway"
|
data/lib/bible_gateway.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
require 'bible_gateway/version'
|
3
2
|
require 'nokogiri'
|
4
3
|
require 'typhoeus'
|
@@ -7,7 +6,7 @@ require 'uri'
|
|
7
6
|
class BibleGatewayError < StandardError; end
|
8
7
|
|
9
8
|
class BibleGateway
|
10
|
-
GATEWAY_URL = "http://
|
9
|
+
GATEWAY_URL = "http://classic.biblegateway.com"
|
11
10
|
|
12
11
|
VERSIONS = {
|
13
12
|
:american_standard_version => "ASV",
|
@@ -33,6 +32,16 @@ class BibleGateway
|
|
33
32
|
:worldwide_english_new_testament => "WE",
|
34
33
|
:wycliffe_new_testament => "WYC",
|
35
34
|
:youngs_literal_translation => "YLT",
|
35
|
+
|
36
|
+
# French
|
37
|
+
:bible_du_semeur => "BDS",
|
38
|
+
:louis_segond => "LSG",
|
39
|
+
:nouvelle_edition_de_geneve => "NEG1979",
|
40
|
+
:segond_21 => "SG21",
|
41
|
+
|
42
|
+
#Chinese
|
43
|
+
:chinese_new_version_simplified => "CNVS",
|
44
|
+
:chinese_union_version_simplified => "CUVS",
|
36
45
|
}
|
37
46
|
|
38
47
|
def self.versions
|
@@ -69,16 +78,30 @@ class BibleGateway
|
|
69
78
|
segment.search('sup.footnote').remove # remove footnote links
|
70
79
|
segment.search("div.crossrefs").remove # remove cross references
|
71
80
|
segment.search("div.footnotes").remove # remove footnotes
|
81
|
+
|
82
|
+
#scripture_text should be text
|
83
|
+
text = ""
|
72
84
|
segment.search("span.text").each do |span|
|
73
|
-
text
|
74
|
-
span.swap text
|
85
|
+
text += span.inner_text
|
75
86
|
end
|
76
87
|
|
88
|
+
# text should be html so that text can be used above.
|
89
|
+
segment.search("span.text").each do |span|
|
90
|
+
html_content = span.inner_html
|
91
|
+
span.swap html_content
|
92
|
+
end
|
93
|
+
|
94
|
+
# text should be html so that text can be used above.
|
77
95
|
segment.search('sup.versenum').each do |sup|
|
78
|
-
|
79
|
-
sup.swap "<sup>#{
|
96
|
+
html_content = sup.content
|
97
|
+
sup.swap "<sup>#{html_content}</sup>"
|
80
98
|
end
|
99
|
+
|
81
100
|
content = segment.inner_html.gsub('<p></p>', '').gsub(/<!--.*?-->/, '').strip
|
82
|
-
|
101
|
+
|
102
|
+
#scripture_text should be text
|
103
|
+
{:title => title,
|
104
|
+
:content => content,
|
105
|
+
:text => text }
|
83
106
|
end
|
84
107
|
end
|
data/spec/bible_gateway_spec.rb
CHANGED
@@ -3,77 +3,93 @@ require "spec_helper"
|
|
3
3
|
|
4
4
|
describe BibleGateway do
|
5
5
|
it "should have a list of versions" do
|
6
|
-
BibleGateway.versions.
|
6
|
+
expect(BibleGateway.versions).not_to be_empty
|
7
7
|
end
|
8
8
|
|
9
9
|
describe "setting the version" do
|
10
10
|
it "should have a default version" do
|
11
11
|
gateway = BibleGateway.new
|
12
|
-
gateway.version.
|
12
|
+
expect(gateway.version).to eq(:king_james_version)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should be able to set the version to use" do
|
16
16
|
gateway = BibleGateway.new :english_standard_version
|
17
|
-
gateway.version.
|
17
|
+
expect(gateway.version).to eq(:english_standard_version)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should raise an exception for unknown version" do
|
21
|
-
|
21
|
+
expect { BibleGateway.new :unknown_version }.to raise_error(BibleGatewayError)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should be able to change the version to use" do
|
25
25
|
gateway = BibleGateway.new
|
26
26
|
gateway.version = :english_standard_version
|
27
|
-
gateway.version.
|
27
|
+
expect(gateway.version).to eq(:english_standard_version)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should be able to set the chinese version to use" do
|
31
|
+
gateway = BibleGateway.new :chinese_new_version_simplified
|
32
|
+
expect(gateway.version).to eq(:chinese_new_version_simplified)
|
28
33
|
end
|
29
34
|
|
30
35
|
it "should raise an exception when changing to unknown version" do
|
31
36
|
gateway = BibleGateway.new
|
32
|
-
|
37
|
+
expect { gateway.version = :unknown_version }.to raise_error(BibleGatewayError)
|
33
38
|
end
|
39
|
+
|
34
40
|
end
|
35
41
|
|
36
42
|
describe "lookup" do
|
37
43
|
context "verse" do
|
38
44
|
it "should find the passage title" do
|
39
45
|
title = BibleGateway.new(:english_standard_version).lookup("John 1:1")[:title]
|
40
|
-
title.
|
46
|
+
expect(title).to eq("John 1:1")
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should find the passage title in chinese_new_version_simplified" do
|
50
|
+
title = BibleGateway.new(:chinese_new_version_simplified).lookup("John 1:1")[:title]
|
51
|
+
expect(title).to eq("约翰福音 1:1")
|
41
52
|
end
|
42
53
|
|
43
54
|
it "should find and clean the passage content" do
|
44
55
|
content = BibleGateway.new(:english_standard_version).lookup("John 1:1")[:content]
|
45
|
-
content.
|
46
|
-
content.
|
56
|
+
expect(content).to include("<h3>The Word Became Flesh</h3>")
|
57
|
+
expect(content).to include("In the beginning was the Word, and the Word was with God, and the Word was God.")
|
47
58
|
end
|
48
59
|
end
|
49
60
|
|
50
61
|
context "chapter" do
|
51
62
|
it "should find the passage title" do
|
52
63
|
title = BibleGateway.new(:english_standard_version).lookup("John 3")[:title]
|
53
|
-
title.
|
64
|
+
expect(title).to eq("John 3")
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should find the passage title in chinese_new_version_simplified" do
|
68
|
+
title = BibleGateway.new(:chinese_new_version_simplified).lookup("John 3")[:title]
|
69
|
+
expect(title).to eq("约翰福音 3")
|
54
70
|
end
|
55
71
|
|
56
72
|
it "should find and clean the passage content" do
|
57
73
|
content = BibleGateway.new(:english_standard_version).lookup("John 3")[:content]
|
58
|
-
content.
|
59
|
-
content.
|
60
|
-
content.
|
74
|
+
expect(content).to include("<h3>You Must Be Born Again</h3>")
|
75
|
+
expect(content).to include("<h3>For God So Loved the World</h3>")
|
76
|
+
expect(content).to include("For God so loved the world, that he gave his only Son, that whoever believes in him should not perish but have eternal life.")
|
61
77
|
end
|
62
78
|
end
|
63
79
|
|
64
80
|
context "multiple chapters" do
|
65
81
|
it "should find the passage title" do
|
66
82
|
title = BibleGateway.new(:english_standard_version).lookup("Psalm 1-5")[:title]
|
67
|
-
title.
|
83
|
+
expect(title).to eq("Psalm 1-5")
|
68
84
|
end
|
69
85
|
|
70
86
|
it "should find and clean the passage content" do
|
71
87
|
content = BibleGateway.new(:english_standard_version).lookup("Psalm 1-5")[:content]
|
72
|
-
content.
|
73
|
-
content.
|
74
|
-
content.
|
75
|
-
content.
|
76
|
-
content.
|
88
|
+
expect(content).to include("<h3>The Way of the Righteous and the Wicked</h3>")
|
89
|
+
expect(content).to include("<span class=\"chapternum\">1 </span>")
|
90
|
+
expect(content).to include("<h3>Save Me, O My God</h3>")
|
91
|
+
expect(content).to include("<span class=\"chapternum\">1 </span>")
|
92
|
+
expect(content).to include("For you are not a God who delights in wickedness;")
|
77
93
|
end
|
78
94
|
end
|
79
95
|
end
|
metadata
CHANGED
@@ -1,96 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bible_gateway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geoffrey Dagley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: typhoeus
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: An unofficial 'API' for BibleGateway.com.
|
84
84
|
email:
|
85
85
|
- gdagley@gmail.com
|
86
|
+
- bibleableproject@gmail.com
|
86
87
|
executables: []
|
87
88
|
extensions: []
|
88
89
|
extra_rdoc_files: []
|
89
90
|
files:
|
90
|
-
- .document
|
91
|
-
- .gitignore
|
92
|
-
- .rspec
|
93
|
-
- .travis.yml
|
91
|
+
- ".document"
|
92
|
+
- ".gitignore"
|
93
|
+
- ".rspec"
|
94
|
+
- ".travis.yml"
|
94
95
|
- Gemfile
|
95
96
|
- LICENSE.txt
|
96
97
|
- README.md
|
@@ -111,17 +112,16 @@ require_paths:
|
|
111
112
|
- lib
|
112
113
|
required_ruby_version: !ruby/object:Gem::Requirement
|
113
114
|
requirements:
|
114
|
-
- -
|
115
|
+
- - ">="
|
115
116
|
- !ruby/object:Gem::Version
|
116
117
|
version: '0'
|
117
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
119
|
requirements:
|
119
|
-
- -
|
120
|
+
- - ">="
|
120
121
|
- !ruby/object:Gem::Version
|
121
122
|
version: '0'
|
122
123
|
requirements: []
|
123
|
-
|
124
|
-
rubygems_version: 2.2.2
|
124
|
+
rubygems_version: 3.0.3
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: An unofficial 'API' for BibleGateway.com.
|