bible_bot 2.0.1 → 2.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9916c2ab85ce75d756b6afb51d332cda0a13b8b5d4c578e377777ed99d3689e8
4
- data.tar.gz: 69b16b95ac47ee4184ddc010360ca0432b8b36b46b6a727ce29440286f4f1892
3
+ metadata.gz: 3077a1bf879fa300507e04dc57a24f8c64175a2c5145246b0d48801b96e24294
4
+ data.tar.gz: 711d60b4e2be2e930e0cad39c718c1473c643277ec13291264befe3dacb067a6
5
5
  SHA512:
6
- metadata.gz: 4962346de98f90e84907ef1beedb903cd192e4e27534ebfb6223056651c3cc3712a1b7d3302eb4f812ae7484cbe9829cdec64ccaaf862a2db3d2f537e3daa01f
7
- data.tar.gz: a6394ed4251f8730a031a8a53b8387b9e36319259bc3070a4204d9ed0d3aed3b2c6284c2605d15ccc451b6604af896fef39c5010e52ec23adae907c9326af118
6
+ metadata.gz: 4ed4b1cbbe420259d00a6e417243385245645268f01061b4081c8de668a1cb9eba0e9d32be58265971c62dda3f3f5ad4bbc52ec12c8a757dd13a343c22161c9e
7
+ data.tar.gz: e47c5b22bae6077562d8aa31781ec2d997c1b3f8c2b0aa052f34fc66c5afa8e5c88255564f944863c8e72a8cf6b2f77825ea454ad5247876aebe678c2b03a3bf
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  .git
2
2
  .yardoc
3
+ .idea
data/Gemfile.lock CHANGED
@@ -1,17 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bible_bot (1.4.4)
4
+ bible_bot (2.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  coderay (1.1.2)
10
10
  diff-lcs (1.3)
11
+ io-console (0.5.9)
12
+ irb (1.3.7)
13
+ reline (>= 0.2.7)
11
14
  method_source (1.0.0)
12
15
  pry (0.13.1)
13
16
  coderay (~> 1.1)
14
17
  method_source (~> 1.0)
18
+ reline (0.2.7)
19
+ io-console (~> 0.5)
15
20
  rspec (3.5.0)
16
21
  rspec-core (~> 3.5.0)
17
22
  rspec-expectations (~> 3.5.0)
@@ -31,8 +36,9 @@ PLATFORMS
31
36
 
32
37
  DEPENDENCIES
33
38
  bible_bot!
39
+ irb
34
40
  pry
35
41
  rspec (~> 3.5.0)
36
42
 
37
43
  BUNDLED WITH
38
- 1.17.2
44
+ 1.17.3
data/README.md CHANGED
@@ -138,6 +138,19 @@ verse == other_verse
138
138
  verse > other_verse
139
139
  ```
140
140
 
141
+ ## Deuterocanonical References
142
+
143
+ If you want to match deuterocanonical references in your strings, you can enable a collection of matchers like this:
144
+
145
+ ```ruby
146
+ BibleBot.include_deuterocanonical_content = true
147
+
148
+ ReferenceMatch.scan( "Tob 1:1" ).first.reference.formatted
149
+
150
+ # > "Tobit 1:1"
151
+ ```
152
+
153
+ You can see the supported deuterocanonical works in [bible.rb](https://github.com/LittleLea/bible_bot/blob/b94fe9b3948ceb23d39961ffdc4bdf7ffe23eff3/lib/bible_bot/bible.rb#L537)
141
154
 
142
155
  ## History
143
156
 
data/bible_bot.gemspec CHANGED
@@ -19,4 +19,5 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_development_dependency 'rspec', '~> 3.5.0'
21
21
  spec.add_development_dependency 'pry'
22
+ spec.add_development_dependency 'irb'
22
23
  end
@@ -534,8 +534,176 @@ module BibleBot
534
534
  )
535
535
  ]
536
536
 
537
+ @@deuterocanonical_books = [
538
+ Book.new(
539
+ id: 101,
540
+ name: "Tobit",
541
+ abbreviation: "Tob",
542
+ regex: "Tob(?:it)?",
543
+ testament: "",
544
+ chapters: [22, 14, 17, 21, 22, 18, 17, 21, 6, 14, 18, 22, 18, 15],
545
+ ),
546
+ Book.new(
547
+ id: 102,
548
+ name: "Judith",
549
+ abbreviation: "Jth",
550
+ regex: "(?:Ju?d?i?th?)",
551
+ testament: "",
552
+ chapters: [16, 28, 10, 15, 24, 21, 32, 36, 14, 23, 23, 20, 20, 19, 14, 25],
553
+ ),
554
+ Book.new(
555
+ id: 103,
556
+ name: "Additions to Esther",
557
+ abbreviation: "Add Esth",
558
+ regex: "(?:((Add\s?|(The\s)?Rest\sof\s|A))Est?h?e?r?)",
559
+ testament: "",
560
+ chapters: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 8, 30, 16, 24, 10],
561
+ ),
562
+ Book.new(
563
+ id: 104,
564
+ name: "Wisdom of Solomon",
565
+ abbreviation: "Wis",
566
+ regex: "(?:(Wi?sd?\.?(\sof\s)?(Sol|om)?))",
567
+ testament: "",
568
+ chapters: [16, 24, 19, 20, 23, 25, 30, 21, 18, 21, 26, 27, 19, 31, 19, 29, 21, 25, 22],
569
+ ),
570
+ Book.new(
571
+ id: 105,
572
+ name: "Sirach", # a.k.a. Ecclesiasticus
573
+ abbreviation: "Sir",
574
+ regex: "Sir(?:ach)?",
575
+ testament: "",
576
+ chapters: [29, 18, 30, 31, 17, 37, 36, 19, 18, 30, 34, 18, 25, 27, 20, 28, 27, 33, 26, 30, 28, 27, 27, 31, 25, 20, 30, 26, 28, 25, 31, 24, 33, 26, 24, 27, 30, 34, 35, 30, 24, 25, 35, 23, 26, 20, 25, 25, 16, 29, 30],
577
+ ),
578
+ Book.new(
579
+ id: 106,
580
+ name: "Ecclesiasticus", # a.k.a. Sirach
581
+ abbreviation: "Ecclus",
582
+ regex: "(?:Ecclus|Ecclesiasticus)",
583
+ testament: "",
584
+ chapters: [29, 18, 30, 31, 17, 37, 36, 19, 18, 30, 34, 18, 25, 27, 20, 28, 27, 33, 26, 30, 28, 27, 27, 31, 25, 20, 30, 26, 28, 25, 31, 24, 33, 26, 24, 27, 30, 34, 35, 30, 24, 25, 35, 23, 26, 20, 25, 25, 16, 29, 30],
585
+ ),
586
+ Book.new(
587
+ id: 107,
588
+ name: "Baruch",
589
+ abbreviation: "Bar",
590
+ regex: "Bar(?:uch)?",
591
+ testament: "",
592
+ chapters: [22, 35, 38, 37, 9, 72],
593
+ ),
594
+ Book.new(
595
+ id: 108,
596
+ name: "Letter of Jeremiah", # Often placed as Baruch 6, but sometimes stands alone
597
+ abbreviation: "Ep Jer",
598
+ regex: "(?:((Le?t?t?e?r?|Ep)(\.\s|\sof\s)?Jer?))",
599
+ testament: "",
600
+ chapters: [73],
601
+ ),
602
+ Book.new(
603
+ id: 109,
604
+ name: "Song of Three Youths", # An extension of Daniel 3... a.k.a. Prayer of Azariah
605
+ abbreviation: "Sg of 3 Childr",
606
+ regex: "(?:(((The\s)?(So?n?g)(\.?\s?o?f?\s?)(the\s)?(3|Thr).*))|((Pr)?.*Aza?r?))",
607
+ testament: "",
608
+ chapters: [],
609
+ ),
610
+ Book.new(
611
+ id: 110,
612
+ name: "Susanna", # A book of Daniel
613
+ abbreviation: "Sus",
614
+ regex: "(?:(Sus))",
615
+ testament: "",
616
+ chapters: [64],
617
+ ),
618
+ Book.new(
619
+ id: 111,
620
+ name: "Bel and the Dragon", # A book of Daniel
621
+ abbreviation: "Bel and Dr",
622
+ regex: "(?:(Bel))",
623
+ testament: "",
624
+ chapters: [42],
625
+ ),
626
+ Book.new(
627
+ id: 112,
628
+ name: "1 Maccabees",
629
+ abbreviation: "1 Macc",
630
+ #regex: "(?:((1s?t?|^I{1}|First)\s?Ma?c?))",
631
+ regex: "(?:1|I)(?:\\s)?Macc(?:abees)?",
632
+ testament: "",
633
+ chapters: [63, 70, 59, 61, 68, 63, 50, 32, 73, 89, 74, 53, 53, 49, 41, 24],
634
+ ),
635
+ Book.new(
636
+ id: 113,
637
+ name: "2 Maccabees",
638
+ abbreviation: "2 Macc",
639
+ regex: "(?:((2n?d?|^I{2}|Second)\s?Ma?c?))",
640
+ testament: "",
641
+ chapters: [36, 32, 40, 50, 27, 31, 42, 36, 29, 38, 38, 46, 26, 46, 39],
642
+ ),
643
+ Book.new(
644
+ id: 114,
645
+ name: "3 Maccabees",
646
+ abbreviation: "3 Macc",
647
+ regex: "(?:((3r?d?|^I{3}|Third)\s?Ma?c?))",
648
+ testament: "",
649
+ chapters: [29, 33, 30, 21, 51, 41, 23],
650
+ ),
651
+ Book.new(
652
+ id: 115,
653
+ name: "4 Maccabees",
654
+ abbreviation: "4 Macc",
655
+ regex: "(?:((4t?h?|IV|Fourth)\s?Ma?c?))",
656
+ testament: "",
657
+ chapters: [35, 24, 21, 26, 38, 35, 23, 29, 32, 21, 27, 19, 27, 20, 32, 25, 24, 24],
658
+ ),
659
+ Book.new(
660
+ id: 116,
661
+ name: "1 Esdras",
662
+ abbreviation: "1 Esd",
663
+ regex: "(?:((1s?t?|^I{1}|First)\s?Esd?))",
664
+ testament: "",
665
+ chapters: [58, 30, 24, 63, 73, 34, 15, 96, 55],
666
+ ),
667
+ Book.new(
668
+ id: 117,
669
+ name: "2 Esdras",
670
+ abbreviation: "2 Esd",
671
+ regex: "(?:((2n?d?|^I{2}|Second)\s?Esd?))",
672
+ testament: "",
673
+ chapters: [40, 48, 36, 52, 56, 59, 140, 63, 47, 59, 46, 51, 58, 48, 63, 78],
674
+ ),
675
+ Book.new(
676
+ id: 118,
677
+ name: "Prayer of Manasseh",
678
+ abbreviation: "Pr of Man",
679
+ regex: "(?:(Pr?.*Man?))",
680
+ testament: "",
681
+ chapters: [15],
682
+ ),
683
+ Book.new(
684
+ id: 119,
685
+ name: "Additional Psalm",
686
+ abbreviation: "Add Ps",
687
+ regex: "(?:(Add.*Ps))",
688
+ testament: "",
689
+ chapters: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7],
690
+ ),
691
+ Book.new(
692
+ id: 120,
693
+ name: "Ode",
694
+ abbreviation: "Ode",
695
+ regex: "Ode",
696
+ testament: "",
697
+ chapters: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7],
698
+ ),
699
+ ]
700
+
537
701
  def self.books
538
- @@books
702
+ if BibleBot.include_deuterocanonical_content?
703
+ @@books + @@deuterocanonical_books
704
+ else
705
+ @@books
706
+ end
539
707
  end
540
708
 
541
709
  # assemble the book regex
@@ -556,7 +724,7 @@ module BibleBot
556
724
  '[\s\.]*' +
557
725
  '(?<ChapterNumber>\d{1,3})' +
558
726
  '(?:\s*[:\.]\s*' +
559
- '(?<VerseNumber>\d{1,3}))?' +
727
+ '(?<VerseNumber>\d{1,3})\w?)?' +
560
728
  '(?:\s*-\s*' +
561
729
  '(?<EndBookTitle>%s)?[\s\.]*' +
562
730
  '(?<EndChapterNumber>\d{1,3})?' +
@@ -564,5 +732,11 @@ module BibleBot
564
732
  '(?<EndVerseNumber>\d{1,3})?' +
565
733
  ')?', book_re_string, book_re_string), Regexp::IGNORECASE)
566
734
  end
735
+
736
+ def self.reset_regular_expressions
737
+ @@book_re_string = nil
738
+ @@book_re = nil
739
+ @@scripture_re = nil
740
+ end
567
741
  end
568
742
  end
@@ -1,3 +1,3 @@
1
1
  module BibleBot
2
- VERSION = "2.0.1"
2
+ VERSION = "2.1.0"
3
3
  end
data/lib/bible_bot.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "ostruct"
1
2
  require "bible_bot/version"
2
3
  require "bible_bot/book"
3
4
  require "bible_bot/bible"
@@ -5,3 +6,38 @@ require "bible_bot/errors"
5
6
  require "bible_bot/verse"
6
7
  require "bible_bot/reference"
7
8
  require "bible_bot/reference_match"
9
+
10
+ module BibleBot
11
+ DEFAULTS = {
12
+ include_deuterocanonical_content: false
13
+ }
14
+
15
+ def self.options
16
+ @options ||= OpenStruct.new(DEFAULTS.dup)
17
+ end
18
+
19
+ def self.options=(opts)
20
+ @options = opts
21
+ end
22
+
23
+ ##
24
+ # Configuration for BibleBot, use like:
25
+ #
26
+ # BibleBot.configure do |config|
27
+ # config.include_deuterocanonical_content = true
28
+ # end
29
+ def self.configure
30
+ yield(options)
31
+ end
32
+
33
+ def self.include_deuterocanonical_content?
34
+ !!self.options.include_deuterocanonical_content
35
+ end
36
+
37
+ def self.include_deuterocanonical_content=(inc)
38
+ self.options.include_deuterocanonical_content = (inc === true)
39
+
40
+ # We need to reset the stored regexps because they take content into account.
41
+ BibleBot::Bible.reset_regular_expressions
42
+ end
43
+ end
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ describe BibleBot do
4
+
5
+ describe "scan with deuterocanonical content enabled" do
6
+ before(:each) do
7
+ BibleBot.include_deuterocanonical_content = true
8
+ end
9
+
10
+ it "has a config" do
11
+ expect(BibleBot.include_deuterocanonical_content?).to eq true
12
+ end
13
+
14
+ test_cases = [
15
+ {ref: "Tob 1:1", expected: ["Tobit 1:1"]},
16
+ {ref: "Judith 1:2", expected: ["Judith 1:2"]},
17
+ {ref: "Ecclus 1:8", expected: ["Ecclesiasticus 1:8"]},
18
+ {ref: "Ode 151:2", expected: ["Ode 151:2"]},
19
+ ]
20
+
21
+ test_cases.each do |t|
22
+ it "Can parse \"#{t[:ref]}\"" do
23
+
24
+ expect( ReferenceMatch.scan( t[:ref] ).map {|rm| rm.reference.formatted }).to eq t[:expected]
25
+ end
26
+
27
+ it "Can parse \"giberish 84 #{t[:ref]} foo bar\"" do
28
+ BibleBot.include_deuterocanonical_content = true
29
+ expect( ReferenceMatch.scan( "giberish 84 #{t[:ref]} foo bar" ).map {|rm| rm.reference.formatted }).to eq t[:expected]
30
+ end
31
+ end
32
+ end
33
+
34
+ describe "scan with deuterocanonical content disabled" do
35
+ before(:each) do
36
+ BibleBot.include_deuterocanonical_content = false
37
+ end
38
+
39
+ it "has a config" do
40
+ expect(BibleBot.include_deuterocanonical_content?).to eq false
41
+ end
42
+
43
+ test_cases = [
44
+ {ref: "John 1:1", expected: ["John 1:1"]},
45
+ {ref: "Tob 1:1", expected: []},
46
+ {ref: "Ode 151:2", expected: []},
47
+ ]
48
+
49
+ test_cases.each do |t|
50
+ it "Can parse \"#{t[:ref]}\"" do
51
+ expect( ReferenceMatch.scan( t[:ref] ).map {|rm| rm.reference.formatted }).to eq t[:expected]
52
+ end
53
+
54
+ it "Can parse \"giberish 84 #{t[:ref]} foo bar\"" do
55
+ expect( ReferenceMatch.scan( "giberish 84 #{t[:ref]} foo bar" ).map {|rm| rm.reference.formatted }).to eq t[:expected]
56
+ end
57
+ end
58
+ end
59
+ end
@@ -154,6 +154,7 @@ describe BibleBot::ReferenceMatch do
154
154
  {ref: "Jude 5", expected: ["Jude 5"]},
155
155
  {ref: "Revelation 1:1", expected: ["Revelation 1:1"]},
156
156
  {ref: "Rev 1:1", expected: ["Revelation 1:1"]},
157
+ {ref: "Genesis 13:11b-12", expected: ["Genesis 13:11-12"]}
157
158
  ]
158
159
 
159
160
  test_cases.each do |t|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bible_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff McFadden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-12 00:00:00.000000000 Z
11
+ date: 2021-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: irb
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description:
42
56
  email:
43
57
  - jeff@littlelea.co
@@ -61,6 +75,7 @@ files:
61
75
  - lib/bible_bot/verse.rb
62
76
  - lib/bible_bot/version.rb
63
77
  - spec/lib/book_spec.rb
78
+ - spec/lib/configuration_spec.rb
64
79
  - spec/lib/reference_match_spec.rb
65
80
  - spec/lib/reference_spec.rb
66
81
  - spec/lib/verse_spec.rb
@@ -84,12 +99,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
99
  - !ruby/object:Gem::Version
85
100
  version: '0'
86
101
  requirements: []
87
- rubygems_version: 3.0.3
102
+ rubygems_version: 3.1.6
88
103
  signing_key:
89
104
  specification_version: 4
90
105
  summary: Bible Verse Parsing, etc.
91
106
  test_files:
92
107
  - spec/lib/book_spec.rb
108
+ - spec/lib/configuration_spec.rb
93
109
  - spec/lib/reference_match_spec.rb
94
110
  - spec/lib/reference_spec.rb
95
111
  - spec/lib/verse_spec.rb