bible_parser 1.0.0 → 1.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
- SHA1:
3
- metadata.gz: 81b20722da2fe055932ce55362c9b9856b1b8263
4
- data.tar.gz: 9c7c29b4fd023897ddc4d0263113bedef3cabe19
2
+ SHA256:
3
+ metadata.gz: 303f4b032cdffa6028a7a23be365cdb0e9db69565340758c74e3ac42b45b12b3
4
+ data.tar.gz: 2366b6b3f08eb0ecfcaeebd06f2bf9cf9d5975360515c5b17d6b141e4b8b6427
5
5
  SHA512:
6
- metadata.gz: b0e8c2264b7ea234ea116c46e0090b67915e28b9a596ae80517cc6725b2bd06c0d24e1411768449f8b2ece2bc97e373cb2ecd6fde7b49ddf1b717a3a212323aa
7
- data.tar.gz: eaa58f82526d4a717c77ec58e8b2ce0f3c4b4d200d402839a899dfda0bdf769c2201205f960dc66c411391c861eb871ebb73903fae976a16bc6b9e8b54464efb
6
+ metadata.gz: c0feb3be0d7eb1f36859cc62ddfac585e90fd158b1e7151e55b6445f779a519e8514de60fe869bebe2e424b65a08e1d52f5e2e4d40fb7d49d1a1d030b554d3c9
7
+ data.tar.gz: 58f73c55c3d700f1cbac8cda5bd5f8c8e61eb16524953c18d4ed37313d7a2ba47de9367a1cf71e6492c1dc3795799d9f8e9d55a4599150e0096ae56b3ec9a029
data/README.md CHANGED
@@ -4,7 +4,11 @@
4
4
 
5
5
  This is a Ruby library for parsing different bible XML formats.
6
6
 
7
- For now, it only supports USFX and OSIS, but I hope to add support for other formats also.
7
+ We currently support:
8
+
9
+ - USFX (for USFM, see 'Other Tools' below)
10
+ - OSIS
11
+ - Zefania
8
12
 
9
13
  ## Install
10
14
 
@@ -14,7 +18,7 @@ gem install bible_parser
14
18
 
15
19
  ## Use
16
20
 
17
- You can get the a bible in XML format [here](https://github.com/seven1m/open-bibles).
21
+ You can get a bible version in XML format [here](https://github.com/seven1m/open-bibles).
18
22
 
19
23
  ```ruby
20
24
  require 'bible_parser'
@@ -28,4 +32,8 @@ verse.text
28
32
 
29
33
  ## License
30
34
 
31
- Copyright (c) 2015 Tim Morgan. Licensed MIT. See LICENSE file.
35
+ Copyright (c) Tim Morgan. Licensed MIT. See LICENSE file.
36
+
37
+ ## Other Tools
38
+
39
+ - [u2o](https://github.com/adyeths/u2o) - Python script to convert from USFM (a format our library does not support) to OSIS (an XML format we do support)
@@ -1,10 +1,12 @@
1
1
  require_relative 'parsers/base'
2
2
  require_relative 'parsers/usfx'
3
3
  require_relative 'parsers/osis'
4
+ require_relative 'parsers/zxbml'
4
5
 
5
6
  class BibleParser
6
7
  PARSERS = {
7
8
  'USFX' => Parsers::USFX::Parser,
8
- 'OSIS' => Parsers::OSIS::Parser
9
+ 'OSIS' => Parsers::OSIS::Parser,
10
+ 'ZXBML' => Parsers::ZXBML::Parser
9
11
  }
10
12
  end
@@ -0,0 +1,2 @@
1
+ require_relative 'zxbml/parser'
2
+ require_relative 'zxbml/document'
@@ -0,0 +1,76 @@
1
+ class BibleParser
2
+ module Parsers
3
+ module ZXBML
4
+ module BookIDs
5
+ BOOK_IDS = {
6
+ 1 => 'GEN',
7
+ 2 => 'EXO',
8
+ 3 => 'LEV',
9
+ 4 => 'NUM',
10
+ 5 => 'DEU',
11
+ 6 => 'JOS',
12
+ 7 => 'JDG',
13
+ 8 => 'RUT',
14
+ 9 => '1SA',
15
+ 10 => '2SA',
16
+ 11 => '1KI',
17
+ 12 => '2KI',
18
+ 13 => '1CH',
19
+ 14 => '2CH',
20
+ 15 => 'EZR',
21
+ 16 => 'NEH',
22
+ 17 => 'EST',
23
+ 18 => 'JOB',
24
+ 19 => 'PSA',
25
+ 20 => 'PRO',
26
+ 21 => 'ECC',
27
+ 22 => 'SNG',
28
+ 23 => 'ISA',
29
+ 24 => 'JER',
30
+ 25 => 'LAM',
31
+ 26 => 'EZK',
32
+ 27 => 'DAN',
33
+ 28 => 'HOS',
34
+ 29 => 'JOL',
35
+ 30 => 'AMO',
36
+ 31 => 'OBA',
37
+ 32 => 'JON',
38
+ 33 => 'MIC',
39
+ 34 => 'NAM',
40
+ 35 => 'HAB',
41
+ 36 => 'ZEP',
42
+ 37 => 'HAG',
43
+ 38 => 'ZEC',
44
+ 39 => 'MAL',
45
+ 40 => 'MAT',
46
+ 41 => 'MRK',
47
+ 42 => 'LUK',
48
+ 43 => 'JHN',
49
+ 44 => 'ACT',
50
+ 45 => 'ROM',
51
+ 46 => '1CO',
52
+ 47 => '2CO',
53
+ 48 => 'GAL',
54
+ 49 => 'EPH',
55
+ 50 => 'PHP',
56
+ 51 => 'COL',
57
+ 52 => '1TH',
58
+ 53 => '2TH',
59
+ 54 => '1TI',
60
+ 55 => '2TI',
61
+ 56 => 'TIT',
62
+ 57 => 'PHM',
63
+ 58 => 'HEB',
64
+ 59 => 'JAS',
65
+ 60 => '1PE',
66
+ 61 => '2PE',
67
+ 62 => '1JN',
68
+ 63 => '2JN',
69
+ 64 => '3JN',
70
+ 65 => 'JUD',
71
+ 66 => 'REV'
72
+ }
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,62 @@
1
+ require_relative 'book_ids'
2
+
3
+ class BibleParser
4
+ module Parsers
5
+ module ZXBML
6
+ class Document < Base::Document
7
+ include BookIDs
8
+
9
+ def start_element(name, attributes)
10
+ case name
11
+ when 'BIBLEBOOK'
12
+ start_book(attributes)
13
+ when 'CHAPTER'
14
+ start_chapter(attributes)
15
+ when 'VERS'
16
+ start_verse(attributes)
17
+ end
18
+ end
19
+
20
+ def end_element(name)
21
+ case name
22
+ when 'BIBLEBOOK'
23
+ end_book
24
+ end_verse if @mode == 'verse'
25
+ when 'CHAPTER'
26
+ end_chapter
27
+ end_verse if @mode == 'verse'
28
+ when 'VERS'
29
+ end_verse
30
+ end
31
+ end
32
+
33
+ def start_book(attributes)
34
+ bnumber = Hash[attributes]['bnumber'].to_i
35
+ @book_num += 1
36
+ @book_id = BOOK_IDS[bnumber]
37
+ @mode = 'book'
38
+ @book_title = Hash[attributes]['bname']
39
+ end
40
+
41
+ def start_chapter(attributes)
42
+ @chapter = Hash[attributes]['cnumber'].to_i
43
+ end
44
+
45
+ def start_verse(attributes)
46
+ @verse = Hash[attributes]['vnumber'].to_i
47
+ @text = ''
48
+ @mode = 'verse'
49
+ end
50
+
51
+ def characters(string)
52
+ case @mode
53
+ when 'book-title'
54
+ @book_title << string.gsub(/\n/, '')
55
+ when 'verse'
56
+ @text << string
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,13 @@
1
+ class BibleParser
2
+ module Parsers
3
+ module ZXBML
4
+ class Parser < Base::Parser
5
+ def valid?
6
+ (@io.read =~ /<format>Zefania XML Bible Markup Language<\/format>/i).tap do
7
+ @io.rewind
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bible_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Morgan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-10 00:00:00.000000000 Z
11
+ date: 2021-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -74,6 +74,10 @@ files:
74
74
  - lib/bible_parser/parsers/usfx.rb
75
75
  - lib/bible_parser/parsers/usfx/document.rb
76
76
  - lib/bible_parser/parsers/usfx/parser.rb
77
+ - lib/bible_parser/parsers/zxbml.rb
78
+ - lib/bible_parser/parsers/zxbml/book_ids.rb
79
+ - lib/bible_parser/parsers/zxbml/document.rb
80
+ - lib/bible_parser/parsers/zxbml/parser.rb
77
81
  - lib/bible_parser/verse.rb
78
82
  homepage: https://github.com/seven1m/bible_parser
79
83
  licenses: []
@@ -93,8 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
97
  - !ruby/object:Gem::Version
94
98
  version: '0'
95
99
  requirements: []
96
- rubyforge_project:
97
- rubygems_version: 2.4.3
100
+ rubygems_version: 3.0.3
98
101
  signing_key:
99
102
  specification_version: 4
100
103
  summary: Library for parsing the bible in various formats