votd 1.0.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/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
19
+ .idea/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.yardopts ADDED
@@ -0,0 +1,6 @@
1
+ --title "VotD - (Bible) Verse of the Day"
2
+ lib/**/*
3
+ -
4
+ LICENSE
5
+ CONTRIBUTING.md
6
+ TODO.md
data/CHANGELOG.md ADDED
File without changes
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,20 @@
1
+ Inside of VotD's source is a module with classes and files referring
2
+ to various Bible web APIs. By contributing to VotD with plugins you
3
+ can help keep the gem fresh with new versions.
4
+
5
+ The most basic way to get the code is to simply fork the code base on
6
+ GitHub. This will hand over a copy of the code to you so that you can
7
+ really do whatever you want.
8
+
9
+ To create a plugin, you must find an API and wrap it in a module
10
+ located in `lib/votd`. Once this is complete, you can start by
11
+ creating a new file in `spec` to test your plugin before your pull
12
+ request. VotD uses the testing framework [Rspec](http://rspec.info/)
13
+ to manage testing, so use the Rspec syntax enhancements rather than
14
+ another framework.
15
+
16
+ Once your tests are done, work on the parsing system with your code,
17
+ and you're ready to go!
18
+
19
+ Just pop us a [Pull Request](https://github.com/doctorbh/votd/pulls)
20
+ and you're code will be overviewed and ready to go soon.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in votd.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,6 @@
1
+ guard 'rspec', version: 2, cli: "--color --format documentation" do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
6
+
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Christopher Clarke, Stephen Clarke
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,97 @@
1
+ # VotD - (Bible) Verse of the Day
2
+
3
+ VotD (Verse of the Day) is a Ruby Gem that wraps various web services that generate
4
+ daily Bible Verses.
5
+
6
+ Currently the gem supports one VotD web service:
7
+
8
+ * [Bible.org](http://labs.bible.org) - NETBible Translation
9
+
10
+ Other services are are planned:
11
+
12
+ * [Bible Gateway](http://www.biblegateway.com) - Multiple Translations
13
+ * [ESV Bible Web Service](http://www.esvapi.org/) - ESV Translation
14
+
15
+ If you are able to contribute modules for any of these, please see our [CONTRIBUTING](CONTRIBUTING.md) file. Let us know before you begin work in case someone else has a module in-progress.
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ gem 'votd'
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install votd
30
+
31
+ ## Usage
32
+
33
+ To use VotD in our code:
34
+
35
+ require 'votd'
36
+
37
+ votd = Votd.NetBible.new
38
+
39
+ votd.reference # Ephesians 2:8-9
40
+ votd.text # For by grace you are saved through faith...
41
+ votd.date # 2012-03-24
42
+ votd.version # NETBible
43
+
44
+ votd.to_html # <p class="votd-text">For by grace you are saved through faith...
45
+
46
+ Full text of HTML formatted VotD looks like the following
47
+
48
+ <p class="votd-text">For by grace you are saved through faith... it is not from works, so that no one can boast.</p>
49
+ <p>
50
+ <span class="votd-reference"><strong>Ephesians 2:8-9</strong></span>
51
+ <span class="votd-version"><em>(NETBible)</em></span>
52
+ </p>
53
+
54
+ You can then use the provided CSS classes to style the VotD.
55
+
56
+ For command-line usage see [here](https://github.com/doctorbh/votd/wiki/Shell-Tool)
57
+
58
+ ## Documentation
59
+
60
+ Documentation may be found [here](http://rubydoc.info/gems/votd/file/README.md)
61
+
62
+ ## Source Code
63
+
64
+ Source code is available in our [GitHub repository](https://github.com/doctorbh/votd).
65
+
66
+ ## Authors
67
+
68
+ Christopher Clarke <beakr@ninjanizr.com>
69
+
70
+ Stephen Clarke <doctorbh@ninjanizr.com>
71
+
72
+ ## Changelog
73
+
74
+ See our [CHANGELOG](CHANGELOG.md) file.
75
+
76
+ ## TODO
77
+
78
+ See our [TODO](TODO.md) file.
79
+
80
+ ## Requests
81
+
82
+ To submit bug, feature requests, patches see our [Issues List](https://github.com/doctorbh/votd/issues) on GitHub.
83
+
84
+ ## Contributing
85
+
86
+ 1. Fork it
87
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
88
+ 3. Write passing tests/specs (we use [RSpec](http://rspec.info))
89
+ 4. Commit your changes (`git commit -am 'Added some feature'`)
90
+ 5. Push to the branch (`git push origin my-new-feature`)
91
+ 6. Create new Pull Request
92
+
93
+ See more on [CONTRIBUTING](CONTRIBUTING.md).
94
+
95
+ ## Copyright
96
+
97
+ &copy; 2012 Christopher Clarke, Stephen Clarke. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+ require "yard"
5
+
6
+ task :default => :spec
7
+
8
+ desc "Run RSpec tests [default]"
9
+ RSpec::Core::RakeTask.new do |task|
10
+ end
11
+
12
+ desc "Generate YARD docs"
13
+ YARD::Rake::YardocTask.new do |task|
14
+ end
15
+
data/TODO.md ADDED
@@ -0,0 +1,11 @@
1
+ ## Todo
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
+ * Update `votd` command-line version.
6
+
7
+ * Integrate [ESV VOTD service](http://www.esvapi.org/api)
8
+
9
+ * Integrate [Bible Gateway](http://www.biblegateway.com/)
10
+
11
+ * Make compatible with Ruby < 1.9
data/bin/votd ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'votd'
4
+
5
+ votd = Votd::NetBible.new
6
+
7
+ puts "===================================================="
8
+ puts " VERSE OF THE DAY for #{votd.date.to_s}"
9
+ puts "===================================================="
10
+ puts votd.text
11
+ puts "#{votd.reference} (#{votd.version})"
12
+
@@ -0,0 +1,94 @@
1
+ module Votd
2
+ # Retrieves a Verse of the Day from bible.org using the NETBible
3
+ # translation.
4
+ class NetBible
5
+ # The name of the Bible Translation that this module generates
6
+ BIBLE_VERSION = "NETBible"
7
+
8
+ # Initializes the NetBible class
9
+ def initialize
10
+ @reference = ""
11
+ @text = ""
12
+ get_verse
13
+ end
14
+
15
+ # The scripture reference. e.g.
16
+ # "Ephesians 2:8-9"
17
+ #
18
+ # @return [String]
19
+ def reference
20
+ @reference
21
+ end
22
+
23
+ # The full bible passage. e.g.
24
+ # "For by grace you are saved through faith..."
25
+ # @return [String]
26
+ def text
27
+ @text
28
+ end
29
+
30
+ # The date the Verse was retrieved. e.g.
31
+ # "2012-03-24"
32
+ #
33
+ # @return [String]
34
+ def date
35
+ Date.today
36
+ end
37
+
38
+ # The bible translation used for this VotD. For this module this
39
+ # will always be.
40
+ # NETBible
41
+ #
42
+ # @return [String]
43
+ def version
44
+ BIBLE_VERSION
45
+ end
46
+
47
+ # Returns the Verse of the Day formatted as HTML.
48
+ # e.g.
49
+ # <p class="votd-text">For by grace you are saved through faith...</p>
50
+ # <p>
51
+ # <span class="votd-reference"><strong>Ephesians 2:8-9</strong></span>
52
+ # <span class="votd-version"><em>(NETBible)</em></span>
53
+ # </p>
54
+ #
55
+ # This should provide sufficient hooks to style the CSS. If this is not
56
+ # sufficient, you can build the HTML by hand using the individual data.
57
+ #
58
+ # @return [String] the VotD formatted as HTML
59
+ def to_html
60
+ html = "<p class=\"votd-text\">#{self.text}</p>\n"
61
+ html << "<p>\n"
62
+ html << "<span class=\"votd-reference\"><strong>#{self.reference}</strong></span>\n"
63
+ html << "<span class=\"votd-version\"><em>(#{self.version})</em></span>\n"
64
+ html << "</p>\n"
65
+ html
66
+ end
67
+
68
+ private
69
+ # Gets the verse in JSON format from bible.org
70
+ def get_verse
71
+ netbible_data = JSON.parse(HTTParty.get("http://labs.bible.org/api/?passage=votd&type=json"))
72
+
73
+ # use bookname from first verse -- assume votd won't span books
74
+ bookname = netbible_data[0]["bookname"]
75
+
76
+ # use chapter from first verse -- assume votd won't span chapters
77
+ chapter = netbible_data[0]["chapter"]
78
+
79
+ # loop through each verse to get the verse numbers and verse text
80
+ verse_numbers = Array.new
81
+ verses = Array.new
82
+ netbible_data.each do |verse|
83
+ verse_numbers << verse["verse"]
84
+ verses << verse["text"]
85
+ end
86
+
87
+ # now build the reference
88
+ @reference = "#{bookname} #{chapter}:#{verse_numbers.join("-")}"
89
+
90
+ # build the text
91
+ @text = verses.join(" ")
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,4 @@
1
+ module Votd
2
+ # Gem version number
3
+ VERSION = "1.0.0"
4
+ end
data/lib/votd.rb ADDED
@@ -0,0 +1,14 @@
1
+ require "votd/version"
2
+ require "votd/netbible"
3
+ require "time"
4
+ require "json"
5
+ require "httparty"
6
+
7
+ # 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.
12
+ module Votd
13
+ include HTTParty
14
+ end
@@ -0,0 +1,5 @@
1
+ <p class="votd-text">For by grace you are saved through faith... it is not from works, so that no one can boast.</p>
2
+ <p>
3
+ <span class="votd-reference"><strong>Ephesians 2:8-9</strong></span>
4
+ <span class="votd-version"><em>(NETBible)</em></span>
5
+ </p>
@@ -0,0 +1,14 @@
1
+ [
2
+ {
3
+ "bookname": "Ephesians",
4
+ "chapter": "2",
5
+ "verse": "8",
6
+ "text": "For by grace you are saved through faith..."
7
+ },
8
+ {
9
+ "bookname": "Ephesians",
10
+ "chapter": "2",
11
+ "verse": "9",
12
+ "text": "it is not from works, so that no one can boast."
13
+ }
14
+ ]
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+
4
+ describe "Votd::NETBible" do
5
+ let(:votd) { Votd::NetBible.new }
6
+
7
+ it "is a type of NETBible" do
8
+ votd.should be_a(Votd::NetBible)
9
+ end
10
+
11
+ it "has a .date" do
12
+ votd.date.should == Date.today
13
+ end
14
+
15
+ it "has a .reference" do
16
+ votd.reference.should == "Ephesians 2:8-9"
17
+ end
18
+
19
+ it "has a .text" do
20
+ votd.text.should == "For by grace you are saved through faith... it is not from works, so that no one can boast."
21
+ end
22
+
23
+ it "has a .version" do
24
+ votd.version.should == "NETBible"
25
+ end
26
+
27
+ it "returns a HTML version" do
28
+ votd.to_html.should == File.read(fixture("netbible.html"))
29
+ end
30
+
31
+ end
@@ -0,0 +1,16 @@
1
+ require 'rspec'
2
+ require 'votd'
3
+ require 'fake_web'
4
+
5
+ FakeWeb.allow_net_connect = false
6
+
7
+ RSpec.configure do |config|
8
+ config.mock_with :rspec
9
+
10
+ def fixture(filename)
11
+ File.join(File.dirname(__FILE__), 'fixtures', filename)
12
+ end
13
+
14
+ FakeWeb.register_uri(:get, "http://labs.bible.org/api/?passage=votd&type=json",
15
+ body: open(fixture("netbible.json")))
16
+ end
data/spec/votd_spec.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Votd do
4
+ it "has a VERSION number" do
5
+ Votd::VERSION.should be
6
+ end
7
+ end
data/votd.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/votd/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Steve Clarke", "Chris Clarke"]
6
+ gem.email = ["doctorbh@ninjanizr.com", "beakr@ninjanizr.com"]
7
+ gem.summary = %q{Generate a (Bible) Verse of the Day using various Web-API wrappers}
8
+ gem.homepage = "https://github.com/doctorbh/votd"
9
+
10
+ gem.files = `git ls-files`.split($\)
11
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
12
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
+ gem.name = "votd"
14
+ gem.require_paths = ["lib"]
15
+ gem.version = Votd::VERSION
16
+ gem.license = "MIT"
17
+
18
+ gem.required_ruby_version = ">= 1.9.1"
19
+
20
+ gem.add_runtime_dependency "httparty"
21
+
22
+ gem.add_development_dependency "fakeweb"
23
+ gem.add_development_dependency "rspec"
24
+ gem.add_development_dependency "guard-rspec"
25
+ gem.add_development_dependency "yard"
26
+ gem.add_development_dependency "redcarpet"
27
+ end
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: votd
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Steve Clarke
9
+ - Chris Clarke
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-03-25 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: httparty
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: fakeweb
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: guard-rspec
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ - !ruby/object:Gem::Dependency
80
+ name: yard
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: redcarpet
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description:
112
+ email:
113
+ - doctorbh@ninjanizr.com
114
+ - beakr@ninjanizr.com
115
+ executables:
116
+ - votd
117
+ extensions: []
118
+ extra_rdoc_files: []
119
+ files:
120
+ - .gitignore
121
+ - .rspec
122
+ - .yardopts
123
+ - CHANGELOG.md
124
+ - CONTRIBUTING.md
125
+ - Gemfile
126
+ - Guardfile
127
+ - LICENSE
128
+ - README.md
129
+ - Rakefile
130
+ - TODO.md
131
+ - bin/votd
132
+ - lib/votd.rb
133
+ - lib/votd/netbible.rb
134
+ - lib/votd/version.rb
135
+ - spec/fixtures/netbible.html
136
+ - spec/fixtures/netbible.json
137
+ - spec/netbible_spec.rb
138
+ - spec/spec_helper.rb
139
+ - spec/votd_spec.rb
140
+ - votd.gemspec
141
+ homepage: https://github.com/doctorbh/votd
142
+ licenses:
143
+ - MIT
144
+ post_install_message:
145
+ rdoc_options: []
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: 1.9.1
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ! '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ requirements: []
161
+ rubyforge_project:
162
+ rubygems_version: 1.8.21
163
+ signing_key:
164
+ specification_version: 3
165
+ summary: Generate a (Bible) Verse of the Day using various Web-API wrappers
166
+ test_files:
167
+ - spec/fixtures/netbible.html
168
+ - spec/fixtures/netbible.json
169
+ - spec/netbible_spec.rb
170
+ - spec/spec_helper.rb
171
+ - spec/votd_spec.rb
172
+ has_rdoc: