votd 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +16 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +9 -3
- data/CONTRIBUTING.md +17 -2
- data/README.md +9 -6
- data/TODO.md +2 -2
- data/lib/votd/base.rb +72 -0
- data/lib/votd/bible_gateway.rb +7 -38
- data/lib/votd/netbible.rb +9 -60
- data/lib/votd/version.rb +1 -1
- data/lib/votd.rb +1 -0
- data/spec/lib/votd/base_spec.rb +29 -0
- metadata +6 -2
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
# - 1.8.7
|
4
|
+
- 1.9.2
|
5
|
+
- 1.9.3
|
6
|
+
# - jruby-18mode # JRuby in 1.8 mode
|
7
|
+
# - jruby-19mode # JRuby in 1.9 mode
|
8
|
+
# - rbx-18mode
|
9
|
+
# - rbx-19mode
|
10
|
+
notifications:
|
11
|
+
email:
|
12
|
+
recipients:
|
13
|
+
- beakr@ninjanizr.com
|
14
|
+
- doctorbh@ninjanizr.com
|
15
|
+
on_success: always
|
16
|
+
on_failure: always
|
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
* March 26, 2012 1.2.0 release
|
4
|
+
* Refactored shared code from BibleGateway and NetBible into a Base class
|
5
|
+
and inherited from this. This makes the code base easier to manage and
|
6
|
+
extend. See the [CONTRIBUTING](https://github.com/doctorbh/votd/blob/master/CONTRIBUTING.md) page for more info on how to make use of the Base class.
|
7
|
+
* Updated docs
|
8
|
+
|
3
9
|
* March 25, 2012 1.1.0 release
|
4
|
-
*
|
10
|
+
* Added support for [Bible Gateway](www.biblegateway.com)
|
5
11
|
* only supporting the default NIV translation for now, but
|
6
12
|
planning to implement other translations
|
7
|
-
*
|
8
|
-
*
|
13
|
+
* Updated votd command line tool to load from Bible Gateway
|
14
|
+
* Moved more code toward compatibility with Ruby 1.8
|
9
15
|
|
10
16
|
* March 25, 2012 1.0.1 release
|
11
17
|
* Updated documentation links
|
data/CONTRIBUTING.md
CHANGED
@@ -9,8 +9,23 @@ GitHub. This will hand over a copy of the code to you so that you can
|
|
9
9
|
really do whatever you want.
|
10
10
|
|
11
11
|
To create a plugin, you must find an API and wrap it in a module
|
12
|
-
located in `lib/votd`.
|
13
|
-
|
12
|
+
located in `lib/votd`.
|
13
|
+
|
14
|
+
* Your class must inherit from {Votd::Base} and
|
15
|
+
needs to override the {Votd::Base#get_votd} method.
|
16
|
+
|
17
|
+
* Your class must supply the `BIBLE_VERSION` constant, or set `@version` inside the class somewhere.
|
18
|
+
|
19
|
+
* Your initializer must consist of at least the following:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
# Initializes the MyBible class
|
23
|
+
def initialize
|
24
|
+
super
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
Creating a new file in `spec` to test your plugin before your pull
|
14
29
|
request. VotD uses the testing framework [Rspec](http://rspec.info/)
|
15
30
|
to manage testing, so use the Rspec syntax enhancements rather than
|
16
31
|
another framework.
|
data/README.md
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
# VotD - (Bible) Verse of the Day
|
2
2
|
|
3
|
+
[](http://travis-ci.org/doctorbh/votd)
|
4
|
+
|
3
5
|
VotD (Verse of the Day) is a Ruby Gem that wraps various web services that generate
|
4
6
|
daily Bible Verses.
|
5
7
|
|
8
|
+
|
6
9
|
Currently the gem supports two VotD web services:
|
7
10
|
|
8
11
|
* [Bible.org](http://labs.bible.org) - NETBible Translation
|
@@ -14,7 +17,7 @@ Other services are are planned:
|
|
14
17
|
|
15
18
|
* [ESV Bible Web Service](http://www.esvapi.org/) - ESV Translation
|
16
19
|
|
17
|
-
If you are able to contribute modules for any of these, please see our [CONTRIBUTING](
|
20
|
+
If you are able to contribute modules for any of these, please see our [CONTRIBUTING](https://github.com/doctorbh/votd/blob/master/CONTRIBUTING.md) file. Let us know before you begin work in case someone else has a module in-progress.
|
18
21
|
|
19
22
|
## Installation
|
20
23
|
|
@@ -32,7 +35,7 @@ Or install it yourself as:
|
|
32
35
|
|
33
36
|
## Usage
|
34
37
|
|
35
|
-
To use VotD in
|
38
|
+
To use VotD in your code:
|
36
39
|
|
37
40
|
require 'votd'
|
38
41
|
|
@@ -80,15 +83,15 @@ To submit bug, feature requests, patches see our [Issues List](https://github.co
|
|
80
83
|
5. Push to the branch (`git push origin my-new-feature`)
|
81
84
|
6. Create new Pull Request
|
82
85
|
|
83
|
-
See more on [CONTRIBUTING](
|
86
|
+
See more on [CONTRIBUTING](https://github.com/doctorbh/votd/blob/master/CONTRIBUTING.md).
|
84
87
|
|
85
88
|
## Changelog
|
86
89
|
|
87
|
-
See our [CHANGELOG](
|
90
|
+
See our [CHANGELOG](https://github.com/doctorbh/votd/blob/master/CHANGELOG.md) file.
|
88
91
|
|
89
92
|
## TODO
|
90
93
|
|
91
|
-
See our [TODO](
|
94
|
+
See our [TODO](https://github.com/doctorbh/votd/blob/master/TODO.md) file.
|
92
95
|
|
93
96
|
## Authors
|
94
97
|
|
@@ -100,4 +103,4 @@ Stephen Clarke <doctorbh@ninjanizr.com>
|
|
100
103
|
|
101
104
|
(The MIT License)
|
102
105
|
|
103
|
-
© 2012 Christopher Clarke, Stephen Clarke. See [LICENSE](
|
106
|
+
© 2012 Christopher Clarke, Stephen Clarke. See [LICENSE](https://github.com/doctorbh/votd/blob/master/LICENSE) for details.
|
data/TODO.md
CHANGED
@@ -8,6 +8,6 @@
|
|
8
8
|
|
9
9
|
* Enable support for more translations from [Bible Gateway](http://www.biblegateway.com/usage/votd/docs/)
|
10
10
|
|
11
|
-
* Ensure Ruby
|
11
|
+
* Ensure Ruby 1.8.7 compatibility.
|
12
12
|
|
13
|
-
*
|
13
|
+
* Add some kind of simple caching
|
data/lib/votd/base.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
module Votd
|
2
|
+
# This is the base class that all Votd lookup modules inherit from.
|
3
|
+
# It provides default values for the Votd in the event of lookup failure.
|
4
|
+
# Child classes should override the {#get_votd} method to implement their
|
5
|
+
# specific lookup function.
|
6
|
+
class Base
|
7
|
+
# @example
|
8
|
+
# votd.text # "For by grace you are saved through faith..."
|
9
|
+
# @return [String] the full bible passage
|
10
|
+
attr_reader :text
|
11
|
+
|
12
|
+
# @example
|
13
|
+
# votd.reference # "Ephesians 2:8-9"
|
14
|
+
#
|
15
|
+
# @return [String] the scripture reference.
|
16
|
+
attr_reader :reference
|
17
|
+
|
18
|
+
# @example
|
19
|
+
# votd.date # "2012-03-24"
|
20
|
+
#
|
21
|
+
# @return [String] the date the Verse was retrieved
|
22
|
+
attr_reader :date
|
23
|
+
|
24
|
+
# @example
|
25
|
+
# votd.version # "NIV"
|
26
|
+
# @return [String] the bible translation used for this VotD
|
27
|
+
attr_reader :version
|
28
|
+
|
29
|
+
# The default Bible version to use if none is given and no other default
|
30
|
+
# is provided
|
31
|
+
DEFAULT_BIBLE_VERSION = "KJV"
|
32
|
+
|
33
|
+
# Initializes the class and retrieves the verse of the day.
|
34
|
+
def initialize
|
35
|
+
@text = ""
|
36
|
+
@reference = ""
|
37
|
+
@date = Date.today
|
38
|
+
get_votd
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns the Verse of the Day formatted as HTML. e.g.
|
42
|
+
# <p class="votd-text">For by grace you are saved through faith...</p>
|
43
|
+
# <p>
|
44
|
+
# <span class="votd-reference"><strong>Ephesians 2:8-9</strong></span>
|
45
|
+
# <span class="votd-version"><em>(NETBible)</em></span>
|
46
|
+
# </p>
|
47
|
+
#
|
48
|
+
# This should provide sufficient hooks to style the CSS. If this is not
|
49
|
+
# sufficient, you can build the HTML by hand using the individual data.
|
50
|
+
#
|
51
|
+
# @return [String] the VotD formatted as HTML
|
52
|
+
def to_html
|
53
|
+
html = "<p class=\"votd-text\">#{@text}</p>\n"
|
54
|
+
html << "<p>\n"
|
55
|
+
html << "<span class=\"votd-reference\"><strong>#{@reference}</strong></span>\n"
|
56
|
+
html << "<span class=\"votd-version\"><em>(#{@version})</em></span>\n"
|
57
|
+
html << "</p>\n"
|
58
|
+
html
|
59
|
+
end
|
60
|
+
|
61
|
+
protected
|
62
|
+
# Gets the VotD. For {Votd::Base} this will return default values and can be
|
63
|
+
# used in the event of an exception thrown when getting data from live web
|
64
|
+
# services in subclasses of {Votd::Base}
|
65
|
+
def get_votd
|
66
|
+
@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."
|
67
|
+
@reference = "John 3:16"
|
68
|
+
@version = DEFAULT_BIBLE_VERSION
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
data/lib/votd/bible_gateway.rb
CHANGED
@@ -10,7 +10,7 @@ module Votd
|
|
10
10
|
# @todo Extend this to allow requesting any of the supported Bible translations that
|
11
11
|
# Bible Gateway supports for VotD
|
12
12
|
#
|
13
|
-
class BibleGateway
|
13
|
+
class BibleGateway < Votd::Base
|
14
14
|
# The name of the Bible Translation that this module generates
|
15
15
|
BIBLE_VERSION = "NIV"
|
16
16
|
|
@@ -19,49 +19,18 @@ module Votd
|
|
19
19
|
|
20
20
|
# Initializes the BibleGateway class
|
21
21
|
def initialize
|
22
|
-
|
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
|
22
|
+
super
|
55
23
|
end
|
56
24
|
|
57
25
|
private
|
26
|
+
# @todo Generate default VotD from Votd::Base if there's a problem getting feed
|
58
27
|
# Gets the votd from the Bible Gateway RSS feed
|
59
|
-
def
|
60
|
-
feed
|
61
|
-
entry
|
28
|
+
def get_votd
|
29
|
+
feed = Feedzirra::Feed.parse(HTTParty.get(URI).body)
|
30
|
+
entry = feed.entries.first
|
62
31
|
@reference = entry.title
|
63
32
|
@text = entry.content.strip
|
33
|
+
@version = BIBLE_VERSION
|
64
34
|
end
|
65
|
-
|
66
35
|
end
|
67
36
|
end
|
data/lib/votd/netbible.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
module Votd
|
2
|
-
#
|
2
|
+
# @todo Clean up generated verse when it has trailing punctuation
|
3
|
+
# and/or begins with lower-case. Substitute "..."
|
4
|
+
# Retrieves a Verse of the Day from http://bible.org using the NETBible
|
3
5
|
# translation.
|
4
|
-
class NetBible
|
6
|
+
class NetBible < Votd::Base
|
5
7
|
# The name of the Bible Translation that this module generates
|
6
8
|
BIBLE_VERSION = "NETBible"
|
7
9
|
|
@@ -10,68 +12,13 @@ module Votd
|
|
10
12
|
|
11
13
|
# Initializes the NetBible class
|
12
14
|
def initialize
|
13
|
-
|
14
|
-
get_verse
|
15
|
-
end
|
16
|
-
|
17
|
-
# @macro [new] votd.reference
|
18
|
-
# @example
|
19
|
-
# votd.reference # "Ephesians 2:8-9"
|
20
|
-
#
|
21
|
-
# @return [String] the scripture reference.
|
22
|
-
def reference
|
23
|
-
@reference
|
24
|
-
end
|
25
|
-
|
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
|
30
|
-
def text
|
31
|
-
@text
|
32
|
-
end
|
33
|
-
|
34
|
-
# @macro [new] votd.date
|
35
|
-
# @example
|
36
|
-
# votd.date # "2012-03-24"
|
37
|
-
#
|
38
|
-
# @return [String] the date the Verse was retrieved
|
39
|
-
def date
|
40
|
-
Date.today
|
41
|
-
end
|
42
|
-
|
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
|
47
|
-
def version
|
48
|
-
BIBLE_VERSION
|
49
|
-
end
|
50
|
-
|
51
|
-
# @macro [new] votd.to_html
|
52
|
-
# Returns the Verse of the Day formatted as HTML. e.g.
|
53
|
-
# <p class="votd-text">For by grace you are saved through faith...</p>
|
54
|
-
# <p>
|
55
|
-
# <span class="votd-reference"><strong>Ephesians 2:8-9</strong></span>
|
56
|
-
# <span class="votd-version"><em>(NETBible)</em></span>
|
57
|
-
# </p>
|
58
|
-
#
|
59
|
-
# This should provide sufficient hooks to style the CSS. If this is not
|
60
|
-
# sufficient, you can build the HTML by hand using the individual data.
|
61
|
-
#
|
62
|
-
# @return [String] the VotD formatted as HTML
|
63
|
-
def to_html
|
64
|
-
html = "<p class=\"votd-text\">#{self.text}</p>\n"
|
65
|
-
html << "<p>\n"
|
66
|
-
html << "<span class=\"votd-reference\"><strong>#{self.reference}</strong></span>\n"
|
67
|
-
html << "<span class=\"votd-version\"><em>(#{self.version})</em></span>\n"
|
68
|
-
html << "</p>\n"
|
69
|
-
html
|
15
|
+
super
|
70
16
|
end
|
71
17
|
|
72
18
|
private
|
19
|
+
# @todo Generate default VotD from Votd::Base if there's a problem getting feed
|
73
20
|
# Gets the verse in JSON format from bible.org
|
74
|
-
def
|
21
|
+
def get_votd
|
75
22
|
netbible_data = JSON.parse(HTTParty.get(URI))
|
76
23
|
|
77
24
|
# use bookname from first verse -- assume votd won't span books
|
@@ -93,6 +40,8 @@ module Votd
|
|
93
40
|
|
94
41
|
# build the text
|
95
42
|
@text = verses.join(" ")
|
43
|
+
|
44
|
+
@version = BIBLE_VERSION
|
96
45
|
end
|
97
46
|
end
|
98
47
|
end
|
data/lib/votd/version.rb
CHANGED
data/lib/votd.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Votd::Base" do
|
4
|
+
let(:votd) { Votd::Base.new }
|
5
|
+
|
6
|
+
describe ".text" do
|
7
|
+
it "returns the default scripture verse" do
|
8
|
+
votd.text.should == "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."
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe ".reference" do
|
13
|
+
it "returns the default scripture reference" do
|
14
|
+
votd.reference.should == "John 3:16"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe ".version" do
|
19
|
+
it "returns the default bible version" do
|
20
|
+
votd.version.should == "KJV"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe ".date" do
|
25
|
+
it "returns the default date" do
|
26
|
+
votd.date.should == Date.today
|
27
|
+
end
|
28
|
+
end
|
29
|
+
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: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-03-
|
13
|
+
date: 2012-03-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|
@@ -151,6 +151,7 @@ extra_rdoc_files: []
|
|
151
151
|
files:
|
152
152
|
- .gitignore
|
153
153
|
- .rspec
|
154
|
+
- .travis.yml
|
154
155
|
- .yardopts
|
155
156
|
- CHANGELOG.md
|
156
157
|
- CONTRIBUTING.md
|
@@ -162,6 +163,7 @@ files:
|
|
162
163
|
- TODO.md
|
163
164
|
- bin/votd
|
164
165
|
- lib/votd.rb
|
166
|
+
- lib/votd/base.rb
|
165
167
|
- lib/votd/bible_gateway.rb
|
166
168
|
- lib/votd/netbible.rb
|
167
169
|
- lib/votd/version.rb
|
@@ -169,6 +171,7 @@ files:
|
|
169
171
|
- spec/fixtures/bible_gateway.rss
|
170
172
|
- spec/fixtures/netbible.html
|
171
173
|
- spec/fixtures/netbible.json
|
174
|
+
- spec/lib/votd/base_spec.rb
|
172
175
|
- spec/lib/votd/bible_gateway_spec.rb
|
173
176
|
- spec/lib/votd/netbible_spec.rb
|
174
177
|
- spec/lib/votd_spec.rb
|
@@ -204,6 +207,7 @@ test_files:
|
|
204
207
|
- spec/fixtures/bible_gateway.rss
|
205
208
|
- spec/fixtures/netbible.html
|
206
209
|
- spec/fixtures/netbible.json
|
210
|
+
- spec/lib/votd/base_spec.rb
|
207
211
|
- spec/lib/votd/bible_gateway_spec.rb
|
208
212
|
- spec/lib/votd/netbible_spec.rb
|
209
213
|
- spec/lib/votd_spec.rb
|