votd 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.yardopts CHANGED
@@ -1,6 +1,7 @@
1
1
  --title "VotD - (Bible) Verse of the Day"
2
2
  lib/**/*
3
3
  -
4
- LICENSE
5
4
  CONTRIBUTING.md
6
- TODO.md
5
+ CHANGELOG.md
6
+ LICENSE
7
+ TODO.md
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ * March 25, 2012 1.1.0 release
4
+ * Add support for [Bible Gateway](www.biblegateway.com)
5
+ * only supporting the default NIV translation for now, but
6
+ planning to implement other translations
7
+ * Update votd command line tool to load from Bible Gateway
8
+ * Move more code toward compatibility with Ruby 1.8
9
+
10
+ * March 25, 2012 1.0.1 release
11
+ * Updated documentation links
12
+
3
13
  * March 24, 2012 1.0.0 release
4
- * Initial release with support for Bible.org's NETBible
14
+ * Initial release with support for Bible.org's [NETBible](http://labs.bible.org/)
5
15
  * YARD documentation added
data/Guardfile CHANGED
@@ -1,6 +1,8 @@
1
1
  guard 'rspec', version: 2, cli: "--color --format documentation" do
2
2
  watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
3
+ watch(%r{^lib/(.+)\.rb$}) { |m|
4
+ puts "running spec/lib/#{m[1]}_spec.rb"
5
+ "spec/lib/#{m[1]}_spec.rb"
6
+ }
4
7
  watch('spec/spec_helper.rb') { "spec" }
5
- end
6
-
8
+ end
data/README.md CHANGED
@@ -3,13 +3,15 @@
3
3
  VotD (Verse of the Day) is a Ruby Gem that wraps various web services that generate
4
4
  daily Bible Verses.
5
5
 
6
- Currently the gem supports one VotD web service:
6
+ Currently the gem supports two VotD web services:
7
7
 
8
8
  * [Bible.org](http://labs.bible.org) - NETBible Translation
9
+ * [Bible Gateway](http://www.biblegateway.com) - NIV Translations (Currently only supporting the default NIV, but planning on adding more.)
9
10
 
10
11
  Other services are are planned:
11
12
 
12
- * [Bible Gateway](http://www.biblegateway.com) - Multiple Translations
13
+ * [Bible Gateway](http://www.biblegateway.com) - More Translations
14
+
13
15
  * [ESV Bible Web Service](http://www.esvapi.org/) - ESV Translation
14
16
 
15
17
  If you are able to contribute modules for any of these, please see our [CONTRIBUTING](http://rubydoc.info/gems/votd/file/CONTRIBUTING.md) file. Let us know before you begin work in case someone else has a module in-progress.
@@ -36,6 +38,8 @@ To use VotD in our code:
36
38
 
37
39
  votd = Votd.NetBible.new
38
40
 
41
+ # or votd = Votd.BibleGateway.new
42
+
39
43
  votd.reference # Ephesians 2:8-9
40
44
  votd.text # For by grace you are saved through faith...
41
45
  votd.date # 2012-03-24
data/TODO.md CHANGED
@@ -1,9 +1,13 @@
1
1
  ## Todo
2
2
 
3
- * Generate an appropriate VOTD from a static file if there's any error communicating with the VOTD API. (suggest something like John 3:16).
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
4
 
5
- * Update `votd` command-line version to. Currently only a bare stub of an app.
5
+ * Update `votd` command-line version. Currently only a bare stub of an app.
6
6
 
7
7
  * Integrate [ESV API](http://www.esvapi.org/api)
8
8
 
9
+ * Enable support for more translations from [Bible Gateway](http://www.biblegateway.com/usage/votd/docs/)
10
+
9
11
  * Ensure Ruby < 1.9 compatibility.
12
+
13
+ * Clean up architecture to use one base class for all modules
data/bin/votd CHANGED
@@ -1,8 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # allow this to run from development environment
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
5
+
3
6
  require 'votd'
4
7
 
5
- votd = Votd::NetBible.new
8
+ votd = Votd::BibleGateway.new
6
9
 
7
10
  puts "===================================================="
8
11
  puts " VERSE OF THE DAY for #{votd.date.to_s}"
@@ -0,0 +1,67 @@
1
+ require 'feedzirra'
2
+ module Votd
3
+ # Retrieves a Verse of the Day from biblegateway.com using a variety
4
+ # of translations.
5
+ #
6
+ # docs: http://www.biblegateway.com/usage/votd/docs/
7
+ #
8
+ # version list: http://www.biblegateway.com/usage/linking/versionslist.php
9
+ #
10
+ # @todo Extend this to allow requesting any of the supported Bible translations that
11
+ # Bible Gateway supports for VotD
12
+ #
13
+ class BibleGateway
14
+ # The name of the Bible Translation that this module generates
15
+ BIBLE_VERSION = "NIV"
16
+
17
+ # The URI of the API gateway
18
+ URI = "http://www.biblegateway.com/usage/votd/rss/votd.rdf?"
19
+
20
+ # Initializes the BibleGateway class
21
+ def initialize
22
+ @reference = ""
23
+ @text = ""
24
+ get_verse
25
+ end
26
+
27
+ # @macro votd.date
28
+ def date
29
+ Date.today
30
+ end
31
+
32
+ # @macro votd.reference
33
+ def reference
34
+ @reference
35
+ end
36
+
37
+ # @macro votd.text
38
+ def text
39
+ @text
40
+ end
41
+
42
+ # @macro votd.version
43
+ def version
44
+ BIBLE_VERSION
45
+ end
46
+
47
+ # @macro votd.to_html
48
+ def to_html
49
+ html = "<p class=\"votd-text\">#{self.text}</p>\n"
50
+ html << "<p>\n"
51
+ html << "<span class=\"votd-reference\"><strong>#{self.reference}</strong></span>\n"
52
+ html << "<span class=\"votd-version\"><em>(#{self.version})</em></span>\n"
53
+ html << "</p>\n"
54
+ html
55
+ end
56
+
57
+ private
58
+ # Gets the votd from the Bible Gateway RSS feed
59
+ def get_verse
60
+ feed = Feedzirra::Feed.parse(HTTParty.get(URI).body)
61
+ entry = feed.entries.first
62
+ @reference = entry.title
63
+ @text = entry.content.strip
64
+ end
65
+
66
+ end
67
+ end
data/lib/votd/netbible.rb CHANGED
@@ -5,47 +5,51 @@ module Votd
5
5
  # The name of the Bible Translation that this module generates
6
6
  BIBLE_VERSION = "NETBible"
7
7
 
8
+ # The URI of the API gateway
9
+ URI = "http://labs.bible.org/api/?passage=votd&type=json"
10
+
8
11
  # Initializes the NetBible class
9
12
  def initialize
10
- @reference = ""
11
- @text = ""
13
+ @reference, @text = ""
12
14
  get_verse
13
15
  end
14
16
 
15
- # The scripture reference. e.g.
16
- # "Ephesians 2:8-9"
17
+ # @macro [new] votd.reference
18
+ # @example
19
+ # votd.reference # "Ephesians 2:8-9"
17
20
  #
18
- # @return [String]
21
+ # @return [String] the scripture reference.
19
22
  def reference
20
23
  @reference
21
24
  end
22
25
 
23
- # The full bible passage. e.g.
24
- # "For by grace you are saved through faith..."
25
- # @return [String]
26
+ # @macro [new] votd.text
27
+ # @example
28
+ # votd.text # "For by grace you are saved through faith..."
29
+ # @return [String] the full bible passage
26
30
  def text
27
31
  @text
28
32
  end
29
33
 
30
- # The date the Verse was retrieved. e.g.
31
- # "2012-03-24"
34
+ # @macro [new] votd.date
35
+ # @example
36
+ # votd.date # "2012-03-24"
32
37
  #
33
- # @return [String]
38
+ # @return [String] the date the Verse was retrieved
34
39
  def date
35
40
  Date.today
36
41
  end
37
42
 
38
- # The bible translation used for this VotD. For this module this
39
- # will always be.
40
- # NETBible
41
- #
42
- # @return [String]
43
+ # For this module this will always be:
44
+ # "NETBible"
45
+ # @macro [new] votd.version
46
+ # @return [String] the bible translation used for this VotD
43
47
  def version
44
48
  BIBLE_VERSION
45
49
  end
46
50
 
47
- # Returns the Verse of the Day formatted as HTML.
48
- # e.g.
51
+ # @macro [new] votd.to_html
52
+ # Returns the Verse of the Day formatted as HTML. e.g.
49
53
  # <p class="votd-text">For by grace you are saved through faith...</p>
50
54
  # <p>
51
55
  # <span class="votd-reference"><strong>Ephesians 2:8-9</strong></span>
@@ -68,7 +72,7 @@ module Votd
68
72
  private
69
73
  # Gets the verse in JSON format from bible.org
70
74
  def get_verse
71
- netbible_data = JSON.parse(HTTParty.get("http://labs.bible.org/api/?passage=votd&type=json"))
75
+ netbible_data = JSON.parse(HTTParty.get(URI))
72
76
 
73
77
  # use bookname from first verse -- assume votd won't span books
74
78
  bookname = netbible_data[0]["bookname"]
data/lib/votd/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Votd
2
2
  # Gem version number
3
- VERSION = "1.0.1"
3
+ VERSION = "1.1.0"
4
4
  end
data/lib/votd.rb CHANGED
@@ -1,14 +1,12 @@
1
- require "votd/version"
1
+ require "votd/bible_gateway"
2
2
  require "votd/netbible"
3
+ require "votd/version"
3
4
  require "time"
4
5
  require "json"
5
6
  require "httparty"
6
7
 
7
8
  # This class acts as the entry point to all sub-modules that are used
8
- # to interact with various Verse of the Day APIs.
9
- #
10
- # Currently there is only NetBible (bible.org), but more can be accomodated
11
- # by following the established pattern.
9
+ # to interact with various Verse of the Day web services.
12
10
  module Votd
13
11
  include HTTParty
14
12
  end
@@ -0,0 +1,5 @@
1
+ <p class="votd-text">&ldquo;If we confess our sins, he is faithful and just and will forgive us our sins and purify us from all unrighteousness.&rdquo;<br/><br/> Brought to you by <a href="http://www.biblegateway.com">BibleGateway.com</a>. Copyright (C) . All Rights Reserved.</p>
2
+ <p>
3
+ <span class="votd-reference"><strong>1 John 1:9</strong></span>
4
+ <span class="votd-version"><em>(NIV)</em></span>
5
+ </p>
@@ -0,0 +1,32 @@
1
+ <?xml version="1.0" ?>
2
+ <rss version="2.0"
3
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
4
+ xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
5
+ xmlns:admin="http://webns.net/mvcb/"
6
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
7
+ xmlns:content="http://purl.org/rss/1.0/modules/content/">
8
+
9
+ <channel>
10
+ <title>Bible Gateway's Verse of the Day</title>
11
+ <link>http://www.biblegateway.com</link>
12
+ <description>A daily word of exultation.</description>
13
+ <dc:language>en-us</dc:language>
14
+ <dc:creator>BibleGateway.com</dc:creator>
15
+ <dc:rights>Copyright 2004</dc:rights>
16
+ <dc:date>2012-03-25T12:00:00Z</dc:date>
17
+ <sy:updatePeriod>daily</sy:updatePeriod>
18
+ <sy:updateFrequency>1</sy:updateFrequency>
19
+ <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
20
+
21
+ <item>
22
+ <title>1 John 1:9</title>
23
+ <description>Verse of the day</description>
24
+ <guid isPermaLink="false">http://www.biblegateway.com/passage/?search=1+John+1%3A9&amp;version=NIV</guid>
25
+ <content:encoded>
26
+ <![CDATA[&ldquo;If we confess our sins, he is faithful and just and will forgive us our sins and purify us from all unrighteousness.&rdquo;<br/><br/> Brought to you by <a href="http://www.biblegateway.com">BibleGateway.com</a>. Copyright (C) . All Rights Reserved.]]>
27
+ </content:encoded>
28
+ <dc:rights>Powered by BibleGateway.com</dc:rights>
29
+ <dc:date>2012-03-25T12:00:00Z</dc:date>
30
+ </item>
31
+ </channel>
32
+ </rss>
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Votd::BibleGateway" do
4
+ let(:votd) { Votd::BibleGateway.new }
5
+
6
+ it "is a type of BibleGateway" do
7
+ votd.should be_a(Votd::BibleGateway)
8
+ end
9
+
10
+ it "has a .date" do
11
+ votd.date.should == Date.today
12
+ end
13
+
14
+ it "has a .reference" do
15
+ votd.reference.should == "1 John 1:9"
16
+ end
17
+
18
+ it "has a .text" do
19
+ votd.text.should == "&ldquo;If we confess our sins, he is faithful and just and will forgive us our sins and purify us from all unrighteousness.&rdquo;<br/><br/> Brought to you by <a href=\"http://www.biblegateway.com\">BibleGateway.com</a>. Copyright (C) . All Rights Reserved."
20
+ end
21
+
22
+ it "has a .version" do
23
+ votd.version.should == "NIV"
24
+ end
25
+
26
+ it "returns a HTML version" do
27
+ votd.to_html.should == File.read(fixture("bible_gateway.html"))
28
+ end
29
+ end
data/spec/spec_helper.rb CHANGED
@@ -11,6 +11,12 @@ RSpec.configure do |config|
11
11
  File.join(File.dirname(__FILE__), 'fixtures', filename)
12
12
  end
13
13
 
14
- FakeWeb.register_uri(:get, "http://labs.bible.org/api/?passage=votd&type=json",
15
- body: open(fixture("netbible.json")))
14
+ # Register Bible Gateway URI
15
+ FakeWeb.register_uri(:get, Votd::BibleGateway::URI,
16
+ :body => open(fixture("bible_gateway.rss")))
17
+
18
+ # Register NETBible URI
19
+ FakeWeb.register_uri(:get, Votd::NetBible::URI,
20
+ :body => open(fixture("netbible.json")))
21
+
16
22
  end
data/votd.gemspec CHANGED
@@ -18,7 +18,8 @@ Gem::Specification.new do |gem|
18
18
  gem.required_ruby_version = ">= 1.9.1"
19
19
 
20
20
  gem.add_runtime_dependency "httparty"
21
-
21
+ gem.add_runtime_dependency "json" if RUBY_VERSION < "1.9"
22
+ gem.add_runtime_dependency "feedzirra"
22
23
  gem.add_development_dependency "rake"
23
24
  gem.add_development_dependency "fakeweb"
24
25
  gem.add_development_dependency "rspec"
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: 1.0.1
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -28,6 +28,22 @@ dependencies:
28
28
  - - ! '>='
29
29
  - !ruby/object:Gem::Version
30
30
  version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: feedzirra
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
31
47
  - !ruby/object:Gem::Dependency
32
48
  name: rake
33
49
  requirement: !ruby/object:Gem::Requirement
@@ -146,13 +162,17 @@ files:
146
162
  - TODO.md
147
163
  - bin/votd
148
164
  - lib/votd.rb
165
+ - lib/votd/bible_gateway.rb
149
166
  - lib/votd/netbible.rb
150
167
  - lib/votd/version.rb
168
+ - spec/fixtures/bible_gateway.html
169
+ - spec/fixtures/bible_gateway.rss
151
170
  - spec/fixtures/netbible.html
152
171
  - spec/fixtures/netbible.json
153
- - spec/netbible_spec.rb
172
+ - spec/lib/votd/bible_gateway_spec.rb
173
+ - spec/lib/votd/netbible_spec.rb
174
+ - spec/lib/votd_spec.rb
154
175
  - spec/spec_helper.rb
155
- - spec/votd_spec.rb
156
176
  - votd.gemspec
157
177
  homepage: https://github.com/doctorbh/votd
158
178
  licenses:
@@ -180,9 +200,12 @@ signing_key:
180
200
  specification_version: 3
181
201
  summary: Generate a (Bible) Verse of the Day using various web service wrappers
182
202
  test_files:
203
+ - spec/fixtures/bible_gateway.html
204
+ - spec/fixtures/bible_gateway.rss
183
205
  - spec/fixtures/netbible.html
184
206
  - spec/fixtures/netbible.json
185
- - spec/netbible_spec.rb
207
+ - spec/lib/votd/bible_gateway_spec.rb
208
+ - spec/lib/votd/netbible_spec.rb
209
+ - spec/lib/votd_spec.rb
186
210
  - spec/spec_helper.rb
187
- - spec/votd_spec.rb
188
211
  has_rdoc:
File without changes