Thor CLI KJV Bible Search Engine – part 3

In part 1 I created a simple CLI (command line interface) Bible Search Engine. I then built a Thor version. It’s cool. It works. But I can’t lookup verses very easily. So, I want to remedy this situation. I just add a new Thor method to my bbl Thor task:

[code]
desc "ref [bookname,verseref]", "display a particular verse"
#method_options :sort => :boolean
def ref(bookname="genesis", verseref="001:001")
inside(Bbl.source_root) {
output = search_for_phrase
shell.say pretty(output, verseref, false)
}
end
[/code]

Now I get the following:

[code]
$ thor bbl:ref john 003:013
[/code]

john 003:013 And no man hath ascended up to heaven, but he that came down from heaven, even the Son of man which is in heaven.
john_1 003:013 Marvel not, my brethren, if the world hate you.
Now, it occurred to me that we could play around with some numerals. Before proceeding, I must say I’m not one of those “Bible code” guys. I am, however, a big fan of Don Knuth, author of Things a Computer Scientist Rarely Talks About and 3:16. In 3:16, Don surveys the sixteenth verse of the third chapter of every book in the Bible with a third chapter. Who said the Bible was boring anyway?

So, with our Thor tool it turns out we can pull the long list of 3:16 verses very easily:
[code]$ thor bbl:ref . 003:016[/code]

acts 003:016 And his name through faith in his name hath made this man strong, whom ye see and know: yea, the faith which is by him hath given him this perfect soundness in the presence of you all.
chronicles_1 003:016 And the sons of Jehoiakim: Jeconiah his son, Zedekiah his son.
chronicles_2 003:016 And he made chains, as in the oracle, and put them on the heads of the pillars; and made an hundred pomegranates, and put them on the chains.
colossians 003:016 Let the word of Christ dwell in you richly in all wisdom; teaching and admonishing one another in psalms and hymns and spiritual songs, singing with grace in your hearts to the Lord.
corinthians_1 003:016 Know ye not that ye are the temple of God, and that the Spirit of God dwelleth in you?
corinthians_2 003:016 Nevertheless when it shall turn to the Lord, the vail shall be taken away.
daniel 003:016 Shadrach, Meshach, and Abednego, answered and said to the king, O Nebuchadnezzar, we are not careful to answer thee in this matter.
deuteronomy 003:016 And unto the Reubenites and unto the Gadites I gave from Gilead even unto the river Arnon half the valley, and the border even unto the river Jabbok, which is the border of the children of Ammon;
ecclesiastes 003:016 And moreover I saw under the sun the place of judgment, that wickedness was there; and the place of righteousness, that iniquity was there.
ephesians 003:016 That he would grant you, according to the riches of his glory, to be strengthened with might by his Spirit in the inner man;
exodus 003:016 Go, and gather the elders of Israel together, and say unto them, The LORD God of your fathers, the God of Abraham, of Isaac, and of Jacob, appeared unto me, saying, I have surely visited you, and seen that which is done to you in Egypt:
ezekiel 003:016 And it came to pass at the end of seven days, that the word of the LORD came unto me, saying,
galations 003:016 Now to Abraham and his seed were the promises made. He saith not, And to seeds, as of many; but as of one, And to thy seed, which is Christ.
genesis 003:016 Unto the woman he said, I will greatly multiply thy sorrow and thy conception; in sorrow thou shalt bring forth children; and thy desire shall be to thy husband, and he shall rule over thee.
habakkuk 003:016 When I heard, my belly trembled; my lips quivered at the voice: rottenness entered into my bones, and I trembled in myself, that I might rest in the day of trouble: when he cometh up unto the people, he will invade them with his troops.
hebrews 003:016 For some, when they had heard, did provoke: howbeit not all that came out of Egypt by Moses.


Crazy. In the next installment I’ll figure out a way to filter by groups of books such as Torah, NT, OT, Pauline, etc.

Thor CLI KJV Bible Search Engine – part 2

In part 1 I showed how I created a simple CLI (command line interface) Bible Search Engine. The problem is that one must always reference the path to the Bible text files. So I will create a Thor task which will eliminate this dependence on the user giving a path (or having to change to the text file directory). First, I create a directory called bbl (which means Bible) inside my _thor directory (which is just a collection of task directories) and then copy the source files there. I’ll create a bbl.rb file which holds my Ruby code creating a Thor task.
[code]
_thor/bbl$ ls
bbl.rb books

_thor/bbl$ more bbl.rb
class Bbl < Thor
...
def self.source_root
# the permanent location of the text files on my system
'~/projects/_thor/bbl/books'
end
...
end
Now we can install the Thor task so the system always knows about it:
[code]
_thor/bbl$ thor install bbl.rb
Please specify a name for bbl.rb in the system repository [bbl.rb]: bbl
Storing thor file in your system repository
[/code]

[code]
_thor/bbl$ thor installed
Modules Namespaces
------- ----------
bbl bbl

bbl
---
thor bbl:find [PHRASE] # find a phase given as list of words on param line
[/code]

Now we can search through the Bible from anywhere on the system. Here is an example from the home directory:
[code]
author@his-laptop:~$ cd ~
author@his-laptop:~$ thor bbl:find "thou art a priest"
psalms 110:004 The LORD hath sworn, and will not repent, Thou art a priest for ever after the order of Melchizedek.
hebrews 005:006 As he saith also in another place, Thou art a priest for ever after the order of Melchisedec.
hebrews 007:017 For he testifieth, Thou art a priest for ever after the order of Melchisedec.
hebrews 007:021 (For those priests were made without an oath; but this with an oath by him that said unto him, The Lord sware and will not repent, Thou art a priest for ever after the order of Melchisedec:)
[/code]

Another advantage of running output through the Thor library is that we can perform post-processing to clean up the output (notice the use of Thor's shell.set_color method):

We get a cleaner presentation:

[code]
_thor/bbl$ thor bbl:find "Thou art a priest"
[/code]

psalms 110:004 The LORD hath sworn, and will not repent, << Thou art a priest >> for ever after the order of Melchizedek.
hebrews 005:006 As he saith also in another place, << Thou art a priest >> for ever after the order of Melchisedec.
hebrews 007:017 For he testifieth, << Thou art a priest >> for ever after the order of Melchisedec.
hebrews 007:021 (For those priests were made without an oath; but this with an oath by him that said unto him, The Lord sware and will not repent, << Thou art a priest >> for ever after the order of Melchisedec:)