Having trouble looping through an array of Regular Expressions in a Rake task

Hey guys, I was wondering if someone could give me some insight on an
issue I’m having.

I am working on a Rails app that will be a data efficient, user
friendly New King James Version of the Bible.

What I am presently doing is making a Rake task to build all the
chapters to all of the books.

So I created an array of Regex’s, to insert the expression to look
for, but when I loop through the array, I’m getting an error, and not
sure why.

This is what I have:

desc “Build All Chapters”
task :build_all_chapters => :environment do
require ‘mechanize’
agent = Mechanize.new
agent.get(“Version not found - Version Information - BibleGateway.com
Version-NKJV-Bible/#booklist”)
books = Book.all.count
i = 0
book_names = Array[/Genesis/, /Exodus/, /Leviticus/, /Numbers/, /
Deuteronomy/, /Joshua/, /Judges/, /Ruth/,
/1+Samuel/, /2+Samuel/, /1+Kings/, /2+Kings/, /1
+Chronicles/, /2+Chronicles/,
/Ezra/, /Nehemiah/, /Esther/, /Job/, /Psalm/, /
Proverbs/, /Ecclesiastes/, /Song+of+Solomon/,
/Isaiah/, /Jeremiah/, /Lamentations/, /Ezekiel/, /
Daniel/, /
Hosea/, /Joel/, /Amos/, /Obadiah/,
/Jonah/, /Micah/, /Nahum/, /Habakkuk/, /Zephaniah/, /
Haggai/, /Zechariah/, /Malachi/, /Matthew/,
/Mark/, /Luke/, /John/, /Acts/, /Romans/, /1
+Corinthians/, /2+Corinthians/, /Galatians/,
/Ephesians/, /Philippians/, /Colossians/, /1
+Thessalonians/, /2+Thessalonians/, /1+Timothy/,
/2+Timothy/, /Titus/, /Philemon/, /Hebrews/, /
search=James/, /1+Peter/, /2+Peter/, /1+John/,
/2+John/, /3+John/, /Jude/, /Revelation/]
books.times do
book_names.each do |book_title|
chapters = agent.page.links_with(book_title).count
Chapter.create!(:name => “Chapter #{i += 1}”, :book_id => i +=
1)
end
end
end

I get the error:

undefined method `all?’ for /Genesis/:Regexp

I’m not sure what this error means, and I haven’t had much luck on
Google…

Thanks in advance for your help.

On Apr 17, 8:53 pm, command0 [email protected] wrote:

I get the error:

undefined method `all?’ for /Genesis/:Regexp

I’m not sure what this error means, and I haven’t had much luck on
Google…

Looks like you’re calling links_with incorrectly - looks like
links_with is expecting a hash (eg :title => some_regex, :href =>
some_other_regex ) rather than just a bare regular expression

Fred