Skip to content

kobsy/pericope

This branch is 1 commit ahead of, 6 commits behind boblail/pericope:master.

Folders and files

NameName
Last commit message
Last commit date
Oct 17, 2016
Dec 9, 2016
Nov 20, 2019
Nov 20, 2019
Sep 11, 2018
Oct 17, 2016
May 11, 2013
Oct 11, 2010
Jul 29, 2016
Dec 9, 2016
Sep 13, 2018

Repository files navigation

Pericope

Gem Version Code Climate Build Status

Pericope is a gem for parsing Bible references.

It recognizes common abbreviations and misspellings for names of the books of the Bible and a variety of ways of denoting ranges of chapters and verses. It can parse pericopes singly or out of a block of text. It's useful for comparing two pericopes for intersection and normalizing them into a well-formatted string.

Examples

Recognize common abbreviations and misspellings for names of the books of the Bible
  Pericope.new("ps 118:17").to_s # => Psalm 118:17
  Pericope.new("jas 3:1-5").to_s # => James 3:1-5
  Pericope.new("1 jn 4:4").to_s  # => 1 John 4:4
Compare two pericopes to see if they intersect
  a = Pericope.new("Mark 13:1-6")
  b = Pericope.new("Mark 13:5")
  c = Pericope.new("Mark 13:6, 7")
  
  a.intersects?(b) # => true
  a.intersects?(c) # => true
  b.intersects?(c) # => false
Parse pericopes out of a block of text
  text = <<-TEXT
  If then, the Word is so significant, great important attaches to its exact form. It has the form of a promise as in Isaiah 43:1: "Do not fear, for I have redeemed you; I have called you by name, you are mine," or as in Luke 2:10-11, "Do not be afraid..to you is born this day...a Savior." (Bayer, p51)
  TEXT
  
  Pericope.parse(text) # => [Isaiah 43:1, Luke 2:10-11]
  
  Pericope.split(text) # => ["  If then, the Word is so significant, great important attaches to its exact form. It has the form of a promise as in ", Isaiah 43:1, ": \"Do not fear, for I have redeemed you; I have called you by name, you are mine,\" or as in ", Luke 2:10-11, ", \"Do not be afraid..to you is born this day...a Savior.\" (Bayer, p51)\n"]
Converts pericopes into arrays of verses and reconstructs them from arrays of verses
  array = Pericope.new("gen 1:1-3").to_a # => [1001001, 1001002, 1001003]
  Pericope.new(array) # => Genesis 1:1-3

History

0.6.1
  • Deprecated the report and extract methods (they will be removed in 0.7.0)
0.6.0
  • Removed the index attribute
  • Deprecated the pattern argument to the method Pericope.split(text, pattern=nil) (it will be removed in 0.7.0)
  • Improved performance by 2x
  • Added this README
  • Fixed a bug with parsing inverted [invalid] ranges (e.g. Mark 3-1)

License

Copyright (c) 2012 Bob Lail, released under the MIT license

About

A simple Bible reference parser

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%