votd 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +0 -1
- data/CHANGELOG.md +3 -0
- data/README.md +3 -0
- data/TODO.md +0 -2
- data/lib/votd/base.rb +15 -2
- data/lib/votd/bible_gateway.rb +4 -1
- data/lib/votd/netbible.rb +5 -0
- data/lib/votd/version.rb +1 -1
- data/spec/lib/votd/bible_gateway_spec.rb +12 -0
- data/spec/lib/votd/netbible_spec.rb +13 -0
- data/spec/spec_helper.rb +8 -2
- metadata +1 -1
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
# Changelog
|
2
|
+
* Current Iteration
|
3
|
+
* VotD will now return a default scripture of John 3:16 in KJV if there's
|
4
|
+
any error enountered when accessing the VotD from the source server.
|
2
5
|
* March 31, 2012 (2.1.0)
|
3
6
|
* [Add] `.custom_html` method that takes a block of custom formatted
|
4
7
|
HTML to override the `.to_html` method.
|
data/README.md
CHANGED
@@ -48,6 +48,9 @@ To use VotD in your code:
|
|
48
48
|
votd.date # 2012-03-24
|
49
49
|
votd.version # NIV
|
50
50
|
votd.copyright # Copyright © ...
|
51
|
+
|
52
|
+
*NOTE: If there's an error encountered while accessing the VotD service a default verse of John 3:16 in the KVJ
|
53
|
+
is returned. This ensures that something is returned no matter what.*
|
51
54
|
|
52
55
|
### Outputting HTML
|
53
56
|
|
data/TODO.md
CHANGED
data/lib/votd/base.rb
CHANGED
@@ -32,6 +32,14 @@ module Votd
|
|
32
32
|
# @return [String] any copyright information supplied by VotD provider
|
33
33
|
attr_reader :copyright
|
34
34
|
|
35
|
+
# The default Bible text to use. This is used in case of an error
|
36
|
+
# retrieving the VotD from a remote server
|
37
|
+
DEFAULT_BIBLE_TEXT = "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life."
|
38
|
+
|
39
|
+
# The default Bible reference to use. This is used in case of an error
|
40
|
+
# retrieving the VotD from a remote server
|
41
|
+
DEFAULT_BIBLE_REFERENCE = "John 3:16"
|
42
|
+
|
35
43
|
# The default Bible version to use if none is given and no other default
|
36
44
|
# is provided
|
37
45
|
DEFAULT_BIBLE_VERSION = "KJV"
|
@@ -120,9 +128,14 @@ module Votd
|
|
120
128
|
# used in the event of an exception thrown when getting data from live web
|
121
129
|
# services in subclasses of {Votd::Base}
|
122
130
|
def get_votd
|
123
|
-
|
124
|
-
|
131
|
+
set_defaults
|
132
|
+
end
|
133
|
+
|
134
|
+
def set_defaults
|
135
|
+
@text = DEFAULT_BIBLE_TEXT
|
136
|
+
@reference = DEFAULT_BIBLE_REFERENCE
|
125
137
|
@version = DEFAULT_BIBLE_VERSION
|
138
|
+
@copyright = nil
|
126
139
|
end
|
127
140
|
|
128
141
|
end
|
data/lib/votd/bible_gateway.rb
CHANGED
@@ -27,7 +27,6 @@ module Votd
|
|
27
27
|
|
28
28
|
private
|
29
29
|
|
30
|
-
# @todo Generate default VotD from Votd::Base if there's a problem getting feed
|
31
30
|
# Gets the votd from the Bible Gateway RSS feed
|
32
31
|
# @return [String]
|
33
32
|
def get_votd
|
@@ -39,6 +38,10 @@ module Votd
|
|
39
38
|
@text = cleaned_text
|
40
39
|
@copyright = get_copyright(entry.content)
|
41
40
|
@version = BIBLE_VERSION
|
41
|
+
rescue
|
42
|
+
# use default info for VotD
|
43
|
+
set_defaults
|
44
|
+
# @todo Add logging
|
42
45
|
end
|
43
46
|
|
44
47
|
# Cleans up the text. Removes:
|
data/lib/votd/netbible.rb
CHANGED
data/lib/votd/version.rb
CHANGED
@@ -74,4 +74,16 @@ describe "Votd::BibleGateway" do
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
+
context "When an error occurrs" do
|
78
|
+
before do
|
79
|
+
register_broken_uri(Votd::BibleGateway::URI)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "falls back to default VotD values" do
|
83
|
+
votd.version.should == Votd::Base::DEFAULT_BIBLE_VERSION
|
84
|
+
votd.reference.should == Votd::Base::DEFAULT_BIBLE_REFERENCE
|
85
|
+
votd.text.should == Votd::Base::DEFAULT_BIBLE_TEXT
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
77
89
|
end
|
@@ -75,4 +75,17 @@ describe "Votd::NETBible" do
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
+
context "When an error occurrs" do
|
79
|
+
before do
|
80
|
+
register_broken_uri(Votd::NetBible::URI)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "falls back to default VotD values" do
|
84
|
+
votd.version.should == Votd::Base::DEFAULT_BIBLE_VERSION
|
85
|
+
votd.reference.should == Votd::Base::DEFAULT_BIBLE_REFERENCE
|
86
|
+
votd.text.should == Votd::Base::DEFAULT_BIBLE_TEXT
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
|
78
91
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -17,10 +17,16 @@ RSpec.configure do |config|
|
|
17
17
|
|
18
18
|
# Register Bible Gateway URI
|
19
19
|
FakeWeb.register_uri(:get, Votd::BibleGateway::URI,
|
20
|
-
:
|
20
|
+
body: open(fixture("bible_gateway/bible_gateway.rss")))
|
21
21
|
|
22
22
|
# Register NETBible URI
|
23
23
|
FakeWeb.register_uri(:get, Votd::NetBible::URI,
|
24
|
-
:
|
24
|
+
body: open(fixture("netbible/netbible.json")))
|
25
25
|
|
26
|
+
# Register broken uri
|
27
|
+
def register_broken_uri(uri)
|
28
|
+
FakeWeb.register_uri(:get, uri,
|
29
|
+
body: "Oopsies",
|
30
|
+
status: ["404", "Not Found"])
|
31
|
+
end
|
26
32
|
end
|