votd 3.0.2 → 4.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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/LICENSE +1 -1
  4. data/README.md +24 -22
  5. data/exe/votd +7 -0
  6. data/lib/votd/base.rb +37 -22
  7. data/lib/votd/bible_gateway.rb +80 -72
  8. data/lib/votd/cli.rb +117 -0
  9. data/lib/votd/esvbible.rb +13 -49
  10. data/lib/votd/fetch_error.rb +8 -0
  11. data/lib/votd/helper/command_line.rb +9 -9
  12. data/lib/votd/helper/text.rb +9 -7
  13. data/lib/votd/netbible.rb +33 -29
  14. data/lib/votd/ourmanna.rb +45 -0
  15. data/lib/votd/version.rb +3 -1
  16. data/lib/votd/votd_error.rb +4 -0
  17. data/lib/votd.rb +42 -0
  18. metadata +37 -197
  19. data/.github/workflows/ruby.yml +0 -20
  20. data/.gitignore +0 -19
  21. data/.rspec +0 -2
  22. data/.ruby-version +0 -1
  23. data/.travis.yml +0 -11
  24. data/.yardopts +0 -7
  25. data/CONTRIBUTING.md +0 -46
  26. data/Gemfile +0 -4
  27. data/Guardfile +0 -10
  28. data/Rakefile +0 -13
  29. data/TODO.md +0 -5
  30. data/bin/votd +0 -25
  31. data/lib/votd/helper/helper.rb +0 -6
  32. data/spec/fixtures/base/base.html +0 -5
  33. data/spec/fixtures/base/base.txt +0 -1
  34. data/spec/fixtures/base/base_custom.html +0 -1
  35. data/spec/fixtures/base/base_custom.txt +0 -1
  36. data/spec/fixtures/bible_gateway/bible_gateway.html +0 -5
  37. data/spec/fixtures/bible_gateway/bible_gateway.rss +0 -33
  38. data/spec/fixtures/bible_gateway/bible_gateway.txt +0 -1
  39. data/spec/fixtures/bible_gateway/bible_gateway_custom.html +0 -1
  40. data/spec/fixtures/bible_gateway/bible_gateway_custom.txt +0 -1
  41. data/spec/fixtures/bible_gateway/bible_gateway_nlt.rss +0 -34
  42. data/spec/fixtures/bible_gateway/bible_gateway_with_partial.rss +0 -32
  43. data/spec/fixtures/esvbible/esvbible.html +0 -5
  44. data/spec/fixtures/esvbible/esvbible.rss +0 -19
  45. data/spec/fixtures/esvbible/esvbible.txt +0 -1
  46. data/spec/fixtures/esvbible/esvbible_custom.html +0 -1
  47. data/spec/fixtures/esvbible/esvbible_custom.txt +0 -1
  48. data/spec/fixtures/esvbible/esvbible_with_partial.rss +0 -19
  49. data/spec/fixtures/netbible/netbible.html +0 -5
  50. data/spec/fixtures/netbible/netbible.json +0 -14
  51. data/spec/fixtures/netbible/netbible.txt +0 -1
  52. data/spec/fixtures/netbible/netbible_custom.html +0 -1
  53. data/spec/fixtures/netbible/netbible_custom.txt +0 -1
  54. data/spec/fixtures/netbible/netbible_with_html.json +0 -1
  55. data/spec/fixtures/netbible/netbible_with_partial.json +0 -8
  56. data/spec/lib/votd/base_spec.rb +0 -96
  57. data/spec/lib/votd/bible_gateway_spec.rb +0 -161
  58. data/spec/lib/votd/esvbible_spec.rb +0 -127
  59. data/spec/lib/votd/helper/command_line_spec.rb +0 -21
  60. data/spec/lib/votd/helper/helper_spec.rb +0 -3
  61. data/spec/lib/votd/helper/text_spec.rb +0 -32
  62. data/spec/lib/votd/netbible_spec.rb +0 -135
  63. data/spec/lib/votd/version_spec.rb +0 -7
  64. data/spec/lib/votd/votd_error_spec.rb +0 -5
  65. data/spec/lib/votd_spec.rb +0 -4
  66. data/spec/spec_helper.rb +0 -26
  67. data/votd.gemspec +0 -29
@@ -1,127 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Votd::ESVBible" do
4
- let(:votd) { Votd::ESVBible.new }
5
-
6
- before do
7
- fake_a_uri(Votd::ESVBible::URI, "esvbible/esvbible.rss")
8
- end
9
-
10
- it "is a type of ESVBible" do
11
- expect(votd).to be_a(Votd::ESVBible)
12
- end
13
-
14
- describe ".text" do
15
- it "returns the correct scripture verse" do
16
- expect(votd.text).to eq "For you did not receive the spirit of slavery to fall back into fear, but you have received the Spirit of adoption as sons, by whom we cry, \"Abba! Father!\""
17
- end
18
- end
19
-
20
- describe ".reference" do
21
- it "returns the correct scripture reference" do
22
- expect(votd.reference).to eq "Romans 8:15"
23
- end
24
- end
25
-
26
- describe ".version / .translation" do
27
- it "returns the correct bible version" do
28
- expect(votd.version).to eq "ESV"
29
- expect(votd.translation).to eq "ESV"
30
- end
31
- end
32
-
33
- describe ".version_name / .translation_name" do
34
- it "returns the correct bible version" do
35
- expect(votd.version_name).to eq "English Standard Version"
36
- expect(votd.translation_name).to eq "English Standard Version"
37
- end
38
- end
39
-
40
- describe ".date" do
41
- it "returns the correct date" do
42
- expect(votd.date).to eq Date.today
43
- end
44
- end
45
-
46
- describe ".copyright" do
47
- it "returns copyright information" do
48
- expect(votd.copyright).to eq "The Holy Bible, English Standard Version copyright 2001 by Crossway Bibles, a publishing ministry of Good News Publishers. Used by permission. All rights reserved."
49
- end
50
- end
51
-
52
- describe ".link" do
53
- it 'returns the link' do
54
- expect(votd.link).to eq 'http://www.gnpcb.org/esv/search/?passage=Romans+8%3A15&date=20131029'
55
- end
56
- end
57
-
58
- describe ".to_html" do
59
- it "returns a HTML version" do
60
- expect(votd.to_html).to eq read_fixture("esvbible/esvbible.html")
61
- end
62
- end
63
-
64
- describe ".custom_html" do
65
- it "overrides the default .to_html formatting" do
66
- votd.custom_html do |votd|
67
- "<p>#{votd.reference}|#{votd.text}|#{votd.version}</p>"
68
- end
69
- expect(votd.to_html).to eq read_fixture("esvbible/esvbible_custom.html")
70
- end
71
-
72
- it "generates a VotdError when not used with a block" do
73
- expect{ votd.custom_html }.to raise_error(Votd::VotdError)
74
- end
75
- end
76
-
77
- describe ".to_text" do
78
- it "returns a text-formatted version" do
79
- expect(votd.to_text).to eq read_fixture("esvbible/esvbible.txt")
80
- end
81
-
82
- it "is aliased to .to_s" do
83
- expect(votd.to_s).to eq read_fixture("esvbible/esvbible.txt")
84
- end
85
- end
86
-
87
- describe ".custom_text" do
88
- it "overrides the default .to_text formatting" do
89
- text_from_block = votd.custom_text do |votd|
90
- "#{votd.reference}|#{votd.text}|#{votd.version}"
91
- end
92
- desired_output = read_fixture("esvbible/esvbible_custom.txt")
93
- expect(text_from_block).to eq desired_output
94
- expect(votd.to_text).to eq desired_output
95
- end
96
-
97
- it "generates a VotdError when not used with a block" do
98
- expect{ votd.custom_text }.to raise_error(Votd::VotdError)
99
- end
100
- end
101
-
102
- context "When an error occurs" do
103
- before do
104
- fake_a_broken_uri(Votd::ESVBible::URI)
105
- end
106
-
107
- it "falls back to default VotD values" do
108
- expect(votd.version).to eq Votd::Base::DEFAULT_BIBLE_VERSION
109
- expect(votd.reference).to eq Votd::Base::DEFAULT_BIBLE_REFERENCE
110
- expect(votd.text).to eq Votd::Base::DEFAULT_BIBLE_TEXT
111
- end
112
- end
113
-
114
- context "When the text is not a proper sentence" do
115
- before do
116
- fake_a_uri(Votd::ESVBible::URI, "esvbible/esvbible_with_partial.rss")
117
- end
118
-
119
- it "prepends an ellipsis if first letter is not a capital letter" do
120
- expect(votd.text).to match /^\.{3}\w/
121
- end
122
-
123
- it "appends an ellipsis if last character is a letter, a comma or a semicolon" do
124
- expect(votd.text).to match /\w\.{3}$/
125
- end
126
- end
127
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
- require 'votd/helper/command_line'
3
-
4
- include Votd::Helper::CommandLine
5
-
6
- describe Votd::Helper::CommandLine do
7
- describe "#banner" do
8
- it "prints a banner wrapped at the correct location" do
9
- #$stdout.should_receive(:puts).with("======\n foo \n======")
10
- expect($stdout).to receive(:puts).with("======\n foo \n======")
11
- banner("foo", 6)
12
- end
13
- end
14
-
15
- describe "#word_wrap" do
16
- it "wraps text at the specified column" do
17
- text = "The quick brown fox jumps over the lazy dog."
18
- expect(word_wrap(text, 20)).to eq "The quick brown fox\njumps over the lazy\ndog."
19
- end
20
- end
21
- end
@@ -1,3 +0,0 @@
1
- require 'spec_helper'
2
- describe Votd::Helper do
3
- end
@@ -1,32 +0,0 @@
1
- require 'spec_helper'
2
-
3
- include Votd::Helper::Text
4
-
5
- describe Votd::Helper::Text do
6
- describe ".strip_html_tags" do
7
- it "removes HTML tags from a given string" do
8
- text = %q[<p>The <span name="foo">quick</span> brown fox.</p><br />]
9
- expect(strip_html_tags(text)).to eq "The quick brown fox."
10
- end
11
- end
12
-
13
- describe ".clean_verse_start" do
14
- it "prepends '...' if the first letter is not a capital letter" do
15
- text = "for God so loved"
16
- expect(clean_verse_start(text)).to eq "...for God so loved"
17
- end
18
- end
19
-
20
- describe ".clean_verse_end" do
21
- it "appends '...' if the verse ends without a period" do
22
- text = "For God so loved"
23
- expect(clean_verse_end(text)).to eq "For God so loved..."
24
- end
25
-
26
- it "appends '...' if the verse ends in a ',' or ';'" do
27
- ["loved,", "loved;"].each do |text|
28
- expect(clean_verse_end(text)).to eq "loved..."
29
- end
30
- end
31
- end
32
- end
@@ -1,135 +0,0 @@
1
- require 'spec_helper'
2
- require 'json'
3
-
4
- describe "Votd::NETBible" do
5
- let(:votd) { Votd::NetBible.new }
6
-
7
- before do
8
- fake_a_uri(Votd::NetBible::URI, "netbible/netbible.json")
9
- end
10
-
11
- it "is a type of NETBible" do
12
- expect(votd).to be_a(Votd::NetBible)
13
- end
14
-
15
- describe ".text" do
16
- it "returns the correct scripture verse" do
17
- expect(votd.text).to eq "For by grace you are saved through faith... it is not from works, so that no one can boast."
18
- end
19
-
20
- it "contains no HTML tags" do
21
- fake_a_uri(Votd::NetBible::URI, "netbible/netbible_with_html.json")
22
- expect(votd.text).to_not match /<\/?[^>]*>/
23
- end
24
- end
25
-
26
- describe ".reference" do
27
- it "returns the correct scripture reference" do
28
- expect(votd.reference).to eq "Ephesians 2:8-9"
29
- end
30
- end
31
-
32
- describe ".version / .translation" do
33
- it "returns the correct bible version" do
34
- expect(votd.version).to eq "NETBible"
35
- expect(votd.translation).to eq "NETBible"
36
- end
37
- end
38
-
39
- describe ".version_name / .translation_name" do
40
- it "returns the correct bible version" do
41
- expect(votd.version_name).to eq "NET Bible"
42
- expect(votd.translation_name).to eq "NET Bible"
43
- end
44
- end
45
-
46
- describe ".date" do
47
- it "returns the correct date" do
48
- expect(votd.date).to eq Date.today
49
- end
50
- end
51
-
52
- describe ".copyright" do
53
- it "returns nil copyright information" do
54
- expect(votd.copyright).to be_nil
55
- end
56
- end
57
-
58
- describe ".link" do
59
- it 'returns the link' do
60
- expect(votd.link).to eq 'https://netbible.org/bible/Ephesians+2:8'
61
- end
62
- end
63
-
64
- describe ".to_html" do
65
- it "returns a HTML version" do
66
- expect(votd.to_html).to eq read_fixture("netbible/netbible.html")
67
- end
68
- end
69
-
70
- describe ".custom_html" do
71
- it "overrides the default .to_html formatting" do
72
- votd.custom_html do |votd|
73
- "<p>#{votd.reference}|#{votd.text}|#{votd.version}</p>"
74
- end
75
- expect(votd.to_html).to eq read_fixture("netbible/netbible_custom.html")
76
- end
77
-
78
- it "generates a VotdError when not used with a block" do
79
- expect{ votd.custom_html }.to raise_error(Votd::VotdError)
80
- end
81
- end
82
-
83
- describe ".to_text" do
84
- it "returns a text-formatted version" do
85
- expect(votd.to_text).to eq read_fixture("netbible/netbible.txt")
86
- end
87
-
88
- it "is aliased to .to_s" do
89
- expect(votd.to_s).to eq read_fixture("netbible/netbible.txt")
90
- end
91
- end
92
-
93
- describe ".custom_text" do
94
- it "overrides the default.to_text formatting" do
95
- text_from_block = votd.custom_text do |votd|
96
- "#{votd.reference}|#{votd.text}|#{votd.version}"
97
- end
98
- desired_output = read_fixture("netbible/netbible_custom.txt")
99
- expect(text_from_block).to eq desired_output
100
- expect(votd.to_text).to eq desired_output
101
- end
102
-
103
- it "generates a VotdError when not used with a block" do
104
- expect{ votd.custom_text }.to raise_error(Votd::VotdError)
105
- end
106
- end
107
-
108
- context "When an error occurs" do
109
- before do
110
- fake_a_broken_uri(Votd::NetBible::URI)
111
- end
112
-
113
- it "falls back to default VotD values" do
114
- expect(votd.version).to eq Votd::Base::DEFAULT_BIBLE_VERSION
115
- expect(votd.reference).to eq Votd::Base::DEFAULT_BIBLE_REFERENCE
116
- expect(votd.text).to eq Votd::Base::DEFAULT_BIBLE_TEXT
117
- end
118
- end
119
-
120
- context "When the text is not a proper sentence" do
121
- before do
122
- fake_a_uri(Votd::NetBible::URI, "netbible/netbible_with_partial.json")
123
- end
124
-
125
- it "prepends an ellipsis if first letter is not a capital letter" do
126
- expect(votd.text).to match /^\.{3}\w/
127
- end
128
-
129
- it "appends an ellipsis if last character is not a period" do
130
- expect(votd.text).to match /\w\.{1,3}$/
131
- end
132
-
133
- end
134
-
135
- end
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Votd::VERSION" do
4
- it "has a VERSION number" do
5
- expect(Votd::VERSION).to be
6
- end
7
- end
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Votd::VotdError do
4
-
5
- end
@@ -1,4 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Votd do
4
- end
data/spec/spec_helper.rb DELETED
@@ -1,26 +0,0 @@
1
- require 'rspec'
2
- require 'votd'
3
- require 'webmock/rspec'
4
-
5
- RSpec.configure do |config|
6
- config.mock_with :rspec
7
- end
8
-
9
- # Fixtures
10
- def expand_fixture_path(filename)
11
- File.join(File.dirname(__FILE__), 'fixtures', filename)
12
- end
13
-
14
- def read_fixture(filename)
15
- File.read(expand_fixture_path(filename))
16
- end
17
-
18
- # Register a fake URI
19
- def fake_a_uri(uri, fixture_path)
20
- stub_request(:get, uri).to_return(body: read_fixture(fixture_path))
21
- end
22
-
23
- # Register a fake broken URI
24
- def fake_a_broken_uri(uri)
25
- stub_request(:get, uri).to_return(body: "Oopsies")
26
- end
data/votd.gemspec DELETED
@@ -1,29 +0,0 @@
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 = ["steve@sevenview.ca", "chris@seven7.ca"]
7
- gem.summary = %q{Generate a (Bible) Verse of the Day using various web service wrappers}
8
- gem.homepage = "https://github.com/sevenview/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.3"
19
-
20
- gem.add_runtime_dependency "httparty"
21
- gem.add_runtime_dependency "feedjira"
22
- gem.add_development_dependency "rake"
23
- gem.add_development_dependency "webmock"
24
- gem.add_development_dependency "rspec"
25
- gem.add_development_dependency "guard-rspec"
26
- gem.add_development_dependency "guard-bundler"
27
- gem.add_development_dependency "yard"
28
- gem.add_development_dependency "redcarpet"
29
- end