Skip to content

Instantly share code, notes, and snippets.

@gaganawhad
Created December 1, 2012 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaganawhad/4185221 to your computer and use it in GitHub Desktop.
Save gaganawhad/4185221 to your computer and use it in GitHub Desktop.
def do_this
new_array = []
[{"id" => 1,"abbrev" => "GEN","name" => "Genesis","chapters" => 50},{"id" => 2,"abbrev" => "EXO","name" => "Exodus","chapters" => 40},{"id" => 3,"abbrev" => "LEV","name" => "Leviticus","chapters" => 27},{"id" => 4,"abbrev" => "NUM","name" => "Numbers","chapters" => 36},{"id" => 5,"abbrev" => "DEU","name" => "Deuteronomy","chapters" => 34},{"id" => 6,"abbrev" => "JOS","name" => "Joshua","chapters" => 24},{"id" => 7,"abbrev" => "JDG","name" => "Judges","chapters" => 21},{"id" => 8,"abbrev" => "RUT","name" => "Ruth","chapters" => 4},{"id" => 9,"abbrev" => "1SA","name" => "1 Samuel","chapters" => 31},{"id" => 10,"abbrev" => "2SA","name" => "2 Samuel","chapters" => 24},{"id" => 11,"abbrev" => "1KG","name" => "1 Kings","chapters" => 22},{"id" => 12,"abbrev" => "2KG","name" => "2 Kings","chapters" => 25},{"id" => 13,"abbrev" => "1KR","name" => "1 Chronicles","chapters" => 29},{"id" => 14,"abbrev" => "2KR","name" => "2 Chronicles","chapters" => 36},{"id" => 15,"abbrev" => "EZR","name" => "Ezra","chapters" => 10},{"id" => 16,"abbrev" => "NEH","name" => "Nehemiah","chapters" => 13},{"id" => 17,"abbrev" => "EST","name" => "Esther","chapters" => 10},{"id" => 18,"abbrev" => "JOB","name" => "Job","chapters" => 42},{"id" => 19,"abbrev" => "PSA","name" => "Psalms","chapters" => 150},{"id" => 20,"abbrev" => "PRO","name" => "Proverbs","chapters" => 31},{"id" => 21,"abbrev" => "ECC","name" => "Ecclesiastes","chapters" => 12},{"id" => 22,"abbrev" => "SO","name" => "Song","chapters" => 8},{"id" => 23,"abbrev" => "ISA","name" => "Isaiah","chapters" => 66},{"id" => 24,"abbrev" => "JER","name" => "Jeremiah","chapters" => 52},{"id" => 25,"abbrev" => "LAM","name" => "Lamentations","chapters" => 5},{"id" => 26,"abbrev" => "EZE","name" => "Ezekiel","chapters" => 48},{"id" => 27,"abbrev" => "DAN","name" => "Daniel","chapters" => 12},{"id" => 28,"abbrev" => "HOS","name" => "Hosea","chapters" => 14},{"id" => 29,"abbrev" => "JOE","name" => "Joel","chapters" => 3},{"id" => 30,"abbrev" => "AMO","name" => "Amos","chapters" => 9},{"id" => 31,"abbrev" => "OBA","name" => "Obadiah","chapters" => 1},{"id" => 32,"abbrev" => "JON","name" => "Jonah","chapters" => 4},{"id" => 33,"abbrev" => "MIC","name" => "Micah","chapters" => 7},{"id" => 34,"abbrev" => "NAH","name" => "Nahum","chapters" => 3},{"id" => 35,"abbrev" => "HAB","name" => "Habakkuk","chapters" => 3},{"id" => 36,"abbrev" => "ZEP","name" => "Zephaniah","chapters" => 3},{"id" => 37,"abbrev" => "HAG","name" => "Haggai","chapters" => 2},{"id" => 38,"abbrev" => "ZEC","name" => "Zechariah","chapters" => 14},{"id" => 39,"abbrev" => "MAL","name" => "Malachi","chapters" => 4},{"id" => 40,"abbrev" => "MAT","name" => "Matthew","chapters" => 28},{"id" => 41,"abbrev" => "MAR","name" => "Mark","chapters" => 16},{"id" => 42,"abbrev" => "LUK","name" => "Luke","chapters" => 24},{"id" => 43,"abbrev" => "JOH","name" => "John","chapters" => 21},{"id" => 44,"abbrev" => "ACT","name" => "Acts","chapters" => 28},
{"id" => 45,"abbrev" => "ROM","name" => "Romans","chapters" => 16},{"id" => 46,"abbrev" => "1CO","name" => "1 Corinthians","chapters" => 16},{"id" => 47,"abbrev" => "2CO","name" => "2 Corinthians","chapters" => 13},{"id" => 48,"abbrev" => "GAL","name" => "Galatians","chapters" => 6},{"id" => 49,"abbrev" => "EPH","name" => "Ephesians","chapters" => 6},{"id" => 50,"abbrev" => "PHI","name" => "Philippians","chapters" => 4},{"id" => 51,"abbrev" => "COL","name" => "Colossians","chapters" => 4},{"id" => 52,"abbrev" => "1TH","name" => "1 Thessalonians","chapters" => 5},{"id" => 53,"abbrev" => "2TH","name" => "2 Thessalonians","chapters" => 3},{"id" => 54,"abbrev" => "1TI","name" => "1 Timothy","chapters" => 6},{"id" => 55,"abbrev" => "2TI","name" => "2 Timothy","chapters" => 4},{"id" => 56,"abbrev" => "TIT","name" => "Titus","chapters" => 3},{"id" => 57,"abbrev" => "PHM","name" => "Philemon","chapters" => 1},{"id" => 58,"abbrev" => "HEB","name" => "Hebrews","chapters" => 13},{"id" => 59,"abbrev" => "JAM","name" => "James","chapters" => 5},{"id" => 60,"abbrev" => "1PE","name" => "1 Peter","chapters" => 5},{"id" => 61,"abbrev" => "2PE","name" => "2 Peter","chapters" => 3},{"id" => 62,"abbrev" => "1JO","name" => "1 John","chapters" => 5},{"id" => 63,"abbrev" => "2JO","name" => "2 John","chapters" => 1},{"id" => 64,"abbrev" => "3JO","name" => "3 John","chapters" => 1},{"id" => 65,"abbrev" => "JUD","name" => "Jude","chapters" => 1},{"id" => 66,"abbrev" => "REV","name" => "Revelation","chapters" => 22}].each do |book|
puts "Current book: #{book['name']}"
new_book = book.clone
new_book['chapters'] = []
(1..book['chapters']).each do |chapter|
#get verse count
verse_count = Net::HTTP.get('www.esvapi.org', URI.escape("/v2/rest/queryInfo?key=IP&q=#{book["name"]} #{chapter}")).scan(/<verse-count>(?<verse_count>.*)<\/verse-count>/)
new_book['chapters'] << {'id' => chapter, 'verse_count' => Regexp.last_match[:verse_count] }
end
new_array << new_book
end
new_array
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment