bible_robot 0.11
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/.document +5 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +33 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +20 -0
- data/Rakefile +44 -0
- data/bible_robot.gemspec +76 -0
- data/lib/bibleRobot/book.rb +30 -0
- data/lib/bibleRobot/chapter.rb +31 -0
- data/lib/bibleRobot/robot.rb +27 -0
- data/lib/bibleRobot/watchtower.rb +115 -0
- data/lib/bibleRobot.rb +4 -0
- data/spec/book_spec.rb +25 -0
- data/spec/chapter_spec.rb +25 -0
- data/spec/fixtures/index.htm +55 -0
- data/spec/fixtures/jude_chapter_001.htm +111 -0
- data/spec/fixtures/lu_chapters.htm +54 -0
- data/spec/fixtures/mt_chapter_001.htm +234 -0
- data/spec/fixtures/mt_chapters.htm +54 -0
- data/spec/fixtures/ob_chapter_001.htm +103 -0
- data/spec/robot_spec.rb +26 -0
- data/spec/watchtower_spec.rb +146 -0
- metadata +175 -0
@@ -0,0 +1,146 @@
|
|
1
|
+
require "bibleRobot"
|
2
|
+
require 'hpricot'
|
3
|
+
|
4
|
+
describe "Watchtower" do
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
@index = Hpricot(File.new('spec/fixtures/index.htm').read)
|
8
|
+
@mateus = Hpricot(File.new('spec/fixtures/mt_chapters.htm').read)
|
9
|
+
@mateus1 = Hpricot(File.new('spec/fixtures/mt_chapter_001.htm').read)
|
10
|
+
@lucas = Hpricot(File.new('spec/fixtures/lu_chapters.htm').read)
|
11
|
+
@obadias = Hpricot(File.new('spec/fixtures/ob_chapter_001.htm').read)
|
12
|
+
@jude = Hpricot(File.new('spec/fixtures/jude_chapter_001.htm').read)
|
13
|
+
@mateus_verses_1_to_3 = "O livro da história de Jesus Cristo, filho de Davi, filho de Abraão: Abraão tornou-se pai de Isaque;\nIsaque tornou-se pai de Jacó;\nJacó tornou-se pai de Judá e seus irmãos; Judá tornou-se pai de Peres e de Zerá por meio de Tamar;\nPeres tornou-se pai de Esrom;\nEsrom tornou-se pai de Rão;"
|
14
|
+
end
|
15
|
+
|
16
|
+
before :each do
|
17
|
+
@robot = Robot.new
|
18
|
+
@robot.stub!(:doc).\
|
19
|
+
with("http://www.watchtower.org/t/biblia/").\
|
20
|
+
and_return(@index)
|
21
|
+
|
22
|
+
@robot.stub!(:doc).\
|
23
|
+
with("http://www.watchtower.org/t/biblia/mt/chapters.htm").\
|
24
|
+
and_return(@mateus)
|
25
|
+
|
26
|
+
@robot.stub!(:doc).\
|
27
|
+
with("http://www.watchtower.org/t/biblia/lu/chapters.htm").\
|
28
|
+
and_return(@lucas)
|
29
|
+
|
30
|
+
@robot.stub!(:doc).\
|
31
|
+
with("http://www.watchtower.org/t/biblia/mt/chapter_001.htm").\
|
32
|
+
and_return(@mateus1)
|
33
|
+
|
34
|
+
@robot.stub!(:doc).\
|
35
|
+
with("http://www.watchtower.org/t/biblia/ob/chapter_001.htm").\
|
36
|
+
and_return(@obadias)
|
37
|
+
|
38
|
+
@robot.stub!(:doc).\
|
39
|
+
with("http://www.watchtower.org/t/biblia/jude/chapter_001.htm").\
|
40
|
+
and_return(@jude)
|
41
|
+
|
42
|
+
@watch = Watchtower.new @robot
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
describe "Book" do
|
47
|
+
it "should return an array of bible books" do
|
48
|
+
@watch.book_list.class.should == Array
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should return an array with all 66 bible books" do
|
52
|
+
@watch.book_list.size.should == 66
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should include Jeremias as book" do
|
56
|
+
@watch.book_list.include?("Jeremias").should == true
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should return the url to Rute book" do
|
60
|
+
@watch.book_url("Rute").should match /ru\/chapters.htm/
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should return the url to Mateus book" do
|
64
|
+
@watch.book_url("Mateus").should match /mt\/chapters.htm/
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should return nil if a wrong book name have been passed as argument" do
|
68
|
+
@watch.book_url("Goa").should == nil
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "Chapters" do
|
74
|
+
|
75
|
+
it "should return the number of chapters for Mateus" do
|
76
|
+
@watch.chapters("Mateus").should == 28
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should return the number of chapters for Lucas" do
|
80
|
+
@watch.chapters("Lucas").should == 24
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should return the number of chapters for Obadias" do
|
84
|
+
@watch.chapters("Obadias").should == 1
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should return nil if the book doesnt exists" do
|
88
|
+
@watch.chapters("Helena").should == nil
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should return the chapter url for Mateus book" do
|
92
|
+
@watch.chapter_url("Mateus","1").should == "http://www.watchtower.org/t/biblia/mt/chapter_001.htm"
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
describe "verse" do
|
99
|
+
|
100
|
+
it "should return the number of verses for Mateus chapter one" do
|
101
|
+
@watch.verses("Mateus","1").should == 25
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should return nil if the book is invalid" do
|
105
|
+
@watch.verses("Mataus","1").should == nil
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should return nil if the chapter is invalid" do
|
109
|
+
@watch.verses("Mateus","29").should == nil
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should return the verse for Mateus chapter 1 verse 1" do
|
113
|
+
@watch.verse("Mateus","1","1").should == "O livro da história de Jesus Cristo, filho de Davi, filho de Abraão:"
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should return the verse for Mateus chapter 1 verse 15" do
|
117
|
+
@watch.verse("Mateus","1","15").should == "Eliúde tornou-se pai de Eleazar;\nEleazar tornou-se pai de Matã;\nMatã tornou-se pai de Jacó;"
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should not return Mateus chapter 1 verse 30" do
|
121
|
+
lambda {@watch.verse("Mateus","1","30")}.should raise_error "invalid verse(s)"
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should return Obadias chapter 1 verse 6" do
|
125
|
+
@watch.verse("Obadias","1","6").should == "Até que ponto foram devassados os de Esaú! [Como] foram vasculhados os seus tesouros escondidos!"
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should return Jude chapter 1 verse 10" do
|
129
|
+
@watch.verse("Judas","1","10").should == "Contudo, estes [homens] estão falando de modo ultrajante de todas as coisas que realmente não conhecem; mas, em todas as coisas que eles entendem naturalmente, como os animais irracionais, nestas coisas prosseguem em corromper-se."
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "Multiple verses" do
|
133
|
+
|
134
|
+
it "should return Mateus chapter 1 verses 1, 2 and 3" do
|
135
|
+
@watch.verse("Mateus","1","1","3").should == @mateus_verses_1_to_3
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should return empty string if the verses range is invalid" do
|
139
|
+
lambda {@watch.verse("Mateus","1","1","100")}.should raise_error "invalid verse(s)"
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
metadata
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bible_robot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 11
|
9
|
+
version: "0.11"
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Rubem Nakamura
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-05-13 00:00:00 -03:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
24
|
+
- - ">"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
hash: 3
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
requirement: *id001
|
31
|
+
prerelease: false
|
32
|
+
name: nokogiri
|
33
|
+
type: :development
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
hash: 23
|
41
|
+
segments:
|
42
|
+
- 1
|
43
|
+
- 0
|
44
|
+
- 0
|
45
|
+
version: 1.0.0
|
46
|
+
requirement: *id002
|
47
|
+
prerelease: false
|
48
|
+
name: bundler
|
49
|
+
type: :development
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 15
|
57
|
+
segments:
|
58
|
+
- 1
|
59
|
+
- 6
|
60
|
+
- 0
|
61
|
+
version: 1.6.0
|
62
|
+
requirement: *id003
|
63
|
+
prerelease: false
|
64
|
+
name: jeweler
|
65
|
+
type: :development
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
requirement: *id004
|
77
|
+
prerelease: false
|
78
|
+
name: rspec
|
79
|
+
type: :development
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
version: "0"
|
90
|
+
requirement: *id005
|
91
|
+
prerelease: false
|
92
|
+
name: hpricot
|
93
|
+
type: :development
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
hash: 3
|
101
|
+
segments:
|
102
|
+
- 0
|
103
|
+
version: "0"
|
104
|
+
requirement: *id006
|
105
|
+
prerelease: false
|
106
|
+
name: sanitize
|
107
|
+
type: :development
|
108
|
+
description: Aims to provide an easy way to get and parse the Bible from diffent sites. Actually, parsing it from watchtower.org
|
109
|
+
email: rubem.nakamura@gmail.com
|
110
|
+
executables: []
|
111
|
+
|
112
|
+
extensions: []
|
113
|
+
|
114
|
+
extra_rdoc_files:
|
115
|
+
- LICENSE.txt
|
116
|
+
- README.rdoc
|
117
|
+
files:
|
118
|
+
- .document
|
119
|
+
- Gemfile
|
120
|
+
- Gemfile.lock
|
121
|
+
- LICENSE.txt
|
122
|
+
- README.rdoc
|
123
|
+
- Rakefile
|
124
|
+
- bible_robot.gemspec
|
125
|
+
- lib/bibleRobot.rb
|
126
|
+
- lib/bibleRobot/book.rb
|
127
|
+
- lib/bibleRobot/chapter.rb
|
128
|
+
- lib/bibleRobot/robot.rb
|
129
|
+
- lib/bibleRobot/watchtower.rb
|
130
|
+
- spec/book_spec.rb
|
131
|
+
- spec/chapter_spec.rb
|
132
|
+
- spec/fixtures/index.htm
|
133
|
+
- spec/fixtures/jude_chapter_001.htm
|
134
|
+
- spec/fixtures/lu_chapters.htm
|
135
|
+
- spec/fixtures/mt_chapter_001.htm
|
136
|
+
- spec/fixtures/mt_chapters.htm
|
137
|
+
- spec/fixtures/ob_chapter_001.htm
|
138
|
+
- spec/robot_spec.rb
|
139
|
+
- spec/watchtower_spec.rb
|
140
|
+
has_rdoc: true
|
141
|
+
homepage: http://github.com/rubemz/bibleRobot
|
142
|
+
licenses:
|
143
|
+
- MIT
|
144
|
+
post_install_message:
|
145
|
+
rdoc_options: []
|
146
|
+
|
147
|
+
require_paths:
|
148
|
+
- lib
|
149
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
150
|
+
none: false
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
hash: 3
|
155
|
+
segments:
|
156
|
+
- 0
|
157
|
+
version: "0"
|
158
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
|
+
none: false
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
hash: 3
|
164
|
+
segments:
|
165
|
+
- 0
|
166
|
+
version: "0"
|
167
|
+
requirements: []
|
168
|
+
|
169
|
+
rubyforge_project:
|
170
|
+
rubygems_version: 1.4.1
|
171
|
+
signing_key:
|
172
|
+
specification_version: 3
|
173
|
+
summary: ""
|
174
|
+
test_files: []
|
175
|
+
|