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 CHANGED
@@ -1,5 +1,4 @@
1
1
  --title "VotD - (Bible) Verse of the Day"
2
- --protected
3
2
  lib/**/*
4
3
  -
5
4
  CONTRIBUTING.md
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
@@ -1,7 +1,5 @@
1
1
  ## Todo
2
2
 
3
- * Generate an appropriate VotD from a static file if there's any error communicating with the VotD API. (e.g. John 3:16)
4
-
5
3
  * Update `votd` command-line version. Currently only a bare stub of an app.
6
4
 
7
5
  * Integrate [ESV API](http://www.esvapi.org/api)
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
- @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."
124
- @reference = "John 3:16"
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
@@ -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
@@ -43,6 +43,11 @@ module Votd
43
43
  @text = verses.join(" ")
44
44
 
45
45
  @version = BIBLE_VERSION
46
+
47
+ rescue
48
+ # use default info for VotD
49
+ set_defaults
50
+ # @todo Add logging
46
51
  end
47
52
  end
48
53
  end
data/lib/votd/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Votd
2
2
  # Gem version number
3
- VERSION = "2.1.0"
3
+ VERSION = "2.1.1"
4
4
  end
@@ -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
- :body => open(fixture("bible_gateway/bible_gateway.rss")))
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
- :body => open(fixture("netbible/netbible.json")))
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: votd
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: