votd 1.2.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,12 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- # - 1.8.7
4
3
  - 1.9.2
5
4
  - 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
5
+ #- jruby-19mode # JRuby in 1.9 mode
6
+ - rbx-19mode
10
7
  notifications:
11
8
  email:
12
9
  recipients:
data/CHANGELOG.md CHANGED
@@ -1,4 +1,12 @@
1
1
  # Changelog
2
+ * March 30, 2010 2.0.0 release
3
+ * New `copyright` attribute containing any copyright information provided
4
+ by the VotD service. This may will cause any existing use of
5
+ `Votd.BibleGateway.text` to lose copyright data unless you add it.
6
+ (Previously, we were just using the copyright data that Bible Gateway
7
+ appended to the end of the Bible text.)
8
+ Bible Gateway requires that you add this copyright data.
9
+ * Remove any reference to Ruby 1.8.7. Will not be supporting.
2
10
 
3
11
  * March 26, 2012 1.2.0 release
4
12
  * Refactored shared code from BibleGateway and NetBible into a Base class
data/Guardfile CHANGED
@@ -1,8 +1,10 @@
1
- guard 'rspec', version: 2, cli: "--color --format documentation" do
1
+ guard 'bundler' do
2
+ watch('Gemfile')
3
+ watch(%r{^.+\.gemspec})
4
+ end
5
+
6
+ guard 'rspec', :version => 2, :cli => "--color --format documentation" do
2
7
  watch(%r{^spec/.+_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
- }
8
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
9
  watch('spec/spec_helper.rb') { "spec" }
8
10
  end
data/README.md CHANGED
@@ -46,7 +46,8 @@ To use VotD in your code:
46
46
  votd.reference # Ephesians 2:8-9
47
47
  votd.text # For by grace you are saved through faith...
48
48
  votd.date # 2012-03-24
49
- votd.version # NETBible
49
+ votd.version # NIV
50
+ votd.copyright # Copyright © ...
50
51
 
51
52
  votd.to_html # <p class="votd-text">For by grace you are saved through faith...
52
53
 
data/Rakefile CHANGED
@@ -6,10 +6,8 @@ require "yard"
6
6
  task :default => :spec
7
7
 
8
8
  desc "Run RSpec tests [default]"
9
- RSpec::Core::RakeTask.new do |task|
10
- end
9
+ RSpec::Core::RakeTask.new
11
10
 
12
11
  desc "Generate YARD docs"
13
- YARD::Rake::YardocTask.new do |task|
14
- end
12
+ YARD::Rake::YardocTask.new
15
13
 
data/TODO.md CHANGED
@@ -1,6 +1,6 @@
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)
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
5
  * Update `votd` command-line version. Currently only a bare stub of an app.
6
6
 
@@ -8,6 +8,4 @@
8
8
 
9
9
  * Enable support for more translations from [Bible Gateway](http://www.biblegateway.com/usage/votd/docs/)
10
10
 
11
- * Ensure Ruby 1.8.7 compatibility.
12
-
13
11
  * Add some kind of simple caching
data/lib/votd/base.rb CHANGED
@@ -26,14 +26,21 @@ module Votd
26
26
  # @return [String] the bible translation used for this VotD
27
27
  attr_reader :version
28
28
 
29
+ # @example
30
+ # votd.copyright # "Brought to you by BibleGateway.com. Copyright (C) . All Rights Reserved."
31
+ # @return [String] any copyright information supplied by VotD provider
32
+ attr_reader :copyright
33
+
29
34
  # The default Bible version to use if none is given and no other default
30
35
  # is provided
31
36
  DEFAULT_BIBLE_VERSION = "KJV"
32
37
 
33
38
  # Initializes the class and retrieves the verse of the day.
39
+ # @return [Base]
34
40
  def initialize
35
41
  @text = ""
36
42
  @reference = ""
43
+ @copyright = nil
37
44
  @date = Date.today
38
45
  get_votd
39
46
  end
@@ -18,19 +18,66 @@ module Votd
18
18
  URI = "http://www.biblegateway.com/usage/votd/rss/votd.rdf?"
19
19
 
20
20
  # Initializes the BibleGateway class
21
+ # @return [BibleGateway]
21
22
  def initialize
23
+ # Regular expression for pulling the copyright out of the Bible text
24
+ @regex_copyright_text = /(Brought to you by BibleGateway.*$)/
22
25
  super
23
26
  end
24
27
 
25
28
  private
29
+
26
30
  # @todo Generate default VotD from Votd::Base if there's a problem getting feed
27
31
  # Gets the votd from the Bible Gateway RSS feed
32
+ # @return [String]
28
33
  def get_votd
29
- feed = Feedzirra::Feed.parse(HTTParty.get(URI).body)
30
- entry = feed.entries.first
31
- @reference = entry.title
32
- @text = entry.content.strip
33
- @version = BIBLE_VERSION
34
+ feed = Feedzirra::Feed.parse(HTTParty.get(URI).body)
35
+ entry = feed.entries.first
36
+ cleaned_text = clean_text(entry.content)
37
+
38
+ @reference = entry.title
39
+ @text = cleaned_text
40
+ @copyright = get_copyright(entry.content)
41
+ @version = BIBLE_VERSION
42
+ end
43
+
44
+ # Cleans up the text. Removes:
45
+ # - HTML quote entities
46
+ # - HTML tags
47
+ # - Copyright text
48
+ # - Extra spaces, line breaks, etc.
49
+ # @return [String]
50
+ def clean_text(text)
51
+ text = strip_html_quote_entities(text)
52
+ text = strip_html_tags(text)
53
+ text = strip_copyright_text(text)
54
+ text.strip
55
+ end
56
+
57
+ # Extracts copyright tag from the Bible text
58
+ # @return [String]
59
+ def get_copyright(text)
60
+ text = strip_html_quote_entities(text)
61
+ text = strip_html_tags(text)
62
+ text.match(@regex_copyright_text)[1]
63
+ end
64
+
65
+ # Removes HTML quote entities added by BibleGateway
66
+ # @return [String]
67
+ def strip_html_quote_entities(text)
68
+ text.gsub(/&.dquo;/, '')
69
+ end
70
+
71
+ # Removes HTML tags from the Bible text
72
+ # @return [String]
73
+ def strip_html_tags(text)
74
+ text.gsub(/<\/?[^>]*>/, '')
75
+ end
76
+
77
+ # Removes copyright text from the Bible text
78
+ # @return [String]
79
+ def strip_copyright_text(text)
80
+ text.gsub(@regex_copyright_text, '')
34
81
  end
35
82
  end
36
83
  end
data/lib/votd/netbible.rb CHANGED
@@ -11,6 +11,7 @@ module Votd
11
11
  URI = "http://labs.bible.org/api/?passage=votd&type=json"
12
12
 
13
13
  # Initializes the NetBible class
14
+ # @return [Votd::NetBible]
14
15
  def initialize
15
16
  super
16
17
  end
data/lib/votd/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Votd
2
2
  # Gem version number
3
- VERSION = "1.2.0"
3
+ VERSION = "2.0.0"
4
4
  end
@@ -0,0 +1,5 @@
1
+ <p class="votd-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.</p>
2
+ <p>
3
+ <span class="votd-reference"><strong>John 3:16</strong></span>
4
+ <span class="votd-version"><em>(KJV)</em></span>
5
+ </p>
@@ -1,4 +1,4 @@
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>
1
+ <p class="votd-text">If we confess our sins, he is faithful and just and will forgive us our sins and purify us from all unrighteousness.</p>
2
2
  <p>
3
3
  <span class="votd-reference"><strong>1 John 1:9</strong></span>
4
4
  <span class="votd-version"><em>(NIV)</em></span>
@@ -26,4 +26,16 @@ describe "Votd::Base" do
26
26
  votd.date.should == Date.today
27
27
  end
28
28
  end
29
+
30
+ describe ".copyright" do
31
+ it "returns nil copyright information" do
32
+ votd.copyright.should be_nil
33
+ end
34
+ end
35
+
36
+ describe ".to_html" do
37
+ it "returns a HTML version" do
38
+ votd.to_html.should == File.read(fixture("base.html"))
39
+ end
40
+ end
29
41
  end
@@ -7,23 +7,39 @@ describe "Votd::BibleGateway" do
7
7
  votd.should be_a(Votd::BibleGateway)
8
8
  end
9
9
 
10
- it "has a .date" do
11
- votd.date.should == Date.today
10
+ describe ".text" do
11
+ it "returns the correct scripture verse" do
12
+ votd.text.should == "If we confess our sins, he is faithful and just and will forgive us our sins and purify us from all unrighteousness."
13
+ end
12
14
  end
13
15
 
14
- it "has a .reference" do
15
- votd.reference.should == "1 John 1:9"
16
+ describe ".reference" do
17
+ it "returns the correct scripture reference" do
18
+ votd.reference.should == "1 John 1:9"
19
+ end
16
20
  end
17
21
 
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."
22
+ describe ".version" do
23
+ it "returns the correct bible version" do
24
+ votd.version.should == "NIV"
25
+ end
20
26
  end
21
27
 
22
- it "has a .version" do
23
- votd.version.should == "NIV"
28
+ describe ".date" do
29
+ it "returns the correct date" do
30
+ votd.date.should == Date.today
31
+ end
24
32
  end
25
33
 
26
- it "returns a HTML version" do
27
- votd.to_html.should == File.read(fixture("bible_gateway.html"))
34
+ describe ".copyright" do
35
+ it "returns copyright information" do
36
+ votd.copyright.should == "Brought to you by BibleGateway.com. Copyright (C) . All Rights Reserved."
37
+ end
38
+ end
39
+
40
+ describe ".to_html" do
41
+ it "returns a HTML version" do
42
+ votd.to_html.should == File.read(fixture("bible_gateway.html"))
43
+ end
28
44
  end
29
45
  end
@@ -8,24 +8,39 @@ describe "Votd::NETBible" do
8
8
  votd.should be_a(Votd::NetBible)
9
9
  end
10
10
 
11
- it "has a .date" do
12
- votd.date.should == Date.today
11
+ describe ".text" do
12
+ it "returns the correct scripture verse" do
13
+ votd.text.should == "For by grace you are saved through faith... it is not from works, so that no one can boast."
14
+ end
13
15
  end
14
16
 
15
- it "has a .reference" do
16
- votd.reference.should == "Ephesians 2:8-9"
17
+ describe ".reference" do
18
+ it "returns the correct scripture reference" do
19
+ votd.reference.should == "Ephesians 2:8-9"
20
+ end
17
21
  end
18
22
 
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."
23
+ describe ".version" do
24
+ it "returns the correct bible version" do
25
+ votd.version.should == "NETBible"
26
+ end
21
27
  end
22
28
 
23
- it "has a .version" do
24
- votd.version.should == "NETBible"
29
+ describe ".date" do
30
+ it "returns the correct date" do
31
+ votd.date.should == Date.today
32
+ end
25
33
  end
26
34
 
27
- it "returns a HTML version" do
28
- votd.to_html.should == File.read(fixture("netbible.html"))
35
+ describe ".copyright" do
36
+ it "returns nil copyright information" do
37
+ votd.copyright.should be_nil
38
+ end
29
39
  end
30
40
 
41
+ describe ".to_html" do
42
+ it "returns a HTML version" do
43
+ votd.to_html.should == File.read(fixture("netbible.html"))
44
+ end
45
+ end
31
46
  end
data/votd.gemspec CHANGED
@@ -5,7 +5,7 @@ Gem::Specification.new do |gem|
5
5
  gem.authors = ["Steve Clarke", "Chris Clarke"]
6
6
  gem.email = ["doctorbh@ninjanizr.com", "beakr@ninjanizr.com"]
7
7
  gem.summary = %q{Generate a (Bible) Verse of the Day using various web service wrappers}
8
- gem.homepage = "https://github.com/doctorbh/votd"
8
+ gem.homepage = "http://doctorbh.github.com/votd"
9
9
 
10
10
  gem.files = `git ls-files`.split($\)
11
11
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -15,15 +15,15 @@ Gem::Specification.new do |gem|
15
15
  gem.version = Votd::VERSION
16
16
  gem.license = "MIT"
17
17
 
18
- gem.required_ruby_version = ">= 1.9.1"
18
+ gem.required_ruby_version = ">= 1.9.2"
19
19
 
20
20
  gem.add_runtime_dependency "httparty"
21
- gem.add_runtime_dependency "json" if RUBY_VERSION < "1.9"
22
21
  gem.add_runtime_dependency "feedzirra"
23
22
  gem.add_development_dependency "rake"
24
23
  gem.add_development_dependency "fakeweb"
25
24
  gem.add_development_dependency "rspec"
26
25
  gem.add_development_dependency "guard-rspec"
26
+ gem.add_development_dependency "guard-bundler"
27
27
  gem.add_development_dependency "yard"
28
28
  gem.add_development_dependency "redcarpet"
29
- 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.2.0
4
+ version: 2.0.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-26 00:00:00.000000000 Z
13
+ date: 2012-03-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -108,6 +108,22 @@ dependencies:
108
108
  - - ! '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-bundler
113
+ requirement: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
111
127
  - !ruby/object:Gem::Dependency
112
128
  name: yard
113
129
  requirement: !ruby/object:Gem::Requirement
@@ -167,6 +183,7 @@ files:
167
183
  - lib/votd/bible_gateway.rb
168
184
  - lib/votd/netbible.rb
169
185
  - lib/votd/version.rb
186
+ - spec/fixtures/base.html
170
187
  - spec/fixtures/bible_gateway.html
171
188
  - spec/fixtures/bible_gateway.rss
172
189
  - spec/fixtures/netbible.html
@@ -177,7 +194,7 @@ files:
177
194
  - spec/lib/votd_spec.rb
178
195
  - spec/spec_helper.rb
179
196
  - votd.gemspec
180
- homepage: https://github.com/doctorbh/votd
197
+ homepage: http://doctorbh.github.com/votd
181
198
  licenses:
182
199
  - MIT
183
200
  post_install_message:
@@ -189,7 +206,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
189
206
  requirements:
190
207
  - - ! '>='
191
208
  - !ruby/object:Gem::Version
192
- version: 1.9.1
209
+ version: 1.9.2
193
210
  required_rubygems_version: !ruby/object:Gem::Requirement
194
211
  none: false
195
212
  requirements:
@@ -203,6 +220,7 @@ signing_key:
203
220
  specification_version: 3
204
221
  summary: Generate a (Bible) Verse of the Day using various web service wrappers
205
222
  test_files:
223
+ - spec/fixtures/base.html
206
224
  - spec/fixtures/bible_gateway.html
207
225
  - spec/fixtures/bible_gateway.rss
208
226
  - spec/fixtures/netbible.html