sqlbible 1.3.4 → 1.4.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: 21260f096b6235ac423d8406a10afe1b83f39765585bb3788489877da458c7d5
4
- data.tar.gz: 747c638f0ed836cf25995b7b58659c79501bacb0b5d1e8198e5ef29d6b1aeab1
3
+ metadata.gz: f39d010a766a67ef4574af340249107716a57be643c51cea6dbfb78c71b14682
4
+ data.tar.gz: 48861d4b399b62d0d572ec7e414eb8188f2364b0c6b3d5009fbcd37c917ecaf8
5
5
  SHA512:
6
- metadata.gz: a6ff9efb6a3d602bfde16a4824ef8b92fa4e19d6f71d7fac7c8e7d06365b66540f23026d4bd945c879563910734eb860b595ffc4e19faa0b9d7ed38f5e0658d7
7
- data.tar.gz: f46ccb07c1abad4264d31fdf5189a1e0ec60f95a3649bf7b8234733662a59a45ca6e77b743622b89a217af54e5230e95bfba32b9984ce9c2a832df2b1326c52d
6
+ metadata.gz: 4c37623b9841ecde065861f6364a6be31758d3f7c358004f32983dd96ae71870b8afa6f99682871b4e148af4cf8d9e2ad41a50157323c0aea85404477ac634d7
7
+ data.tar.gz: 31e6d182ba802cfc3f96581c239e8fc5d7039b26f1fc1476b0b0502820360d0b948fbaefd276ec035b5a24a2bbd755bea3ccd59e5e208d051ba3bd86f37fd7e7
data/bin/sqlbible CHANGED
@@ -6,6 +6,11 @@ require 'optimist_xl'
6
6
  require 'scripref'
7
7
  require 'sqlbible'
8
8
 
9
+ default_bible_param = {}
10
+ if b = Sqlbible.bible
11
+ default_bible_param[:default] = b.to_s
12
+ end
13
+
9
14
  result = OptimistXL.options do
10
15
  synopsis 'Usage: sqlbible <command> [options] [filename]?'
11
16
  subcmd :convert, 'Convert a bible from OSIS-XML to Sqlbible format' do
@@ -14,15 +19,15 @@ result = OptimistXL.options do
14
19
  end
15
20
  subcmd :list, 'Show a list of the names of the bibles in central directory'
16
21
  subcmd :search, 'Search with regular expressions' do
17
- opt :bible, 'Name of the bible module filename of an .sqlbible file', type: String
22
+ opt :bible, 'Name of the bible module filename of an .sqlbible file', type: String, **default_bible_param
18
23
  opt :search, 'Regular expression to search (multiple allowed)', type: String, multi: true, required: true
19
- opt :lang, 'Language for parsing and formatting scripture references', type: String, permitted: %w(de en), default: 'en'
24
+ opt :lang, 'Language for parsing and formatting scripture references', type: String, permitted: %w(de en), default: Sqlbible.lang.to_s
20
25
  opt :output, 'Output filename', type: String
21
26
  opt :range, 'Search range, example: "John 1-10"', type: String
22
27
  end
23
28
  subcmd :text, 'Show text of references' do
24
- opt :bible, 'Name of the bible module filename of an .sqlbible file', type: String
25
- opt :lang, 'Language for parsing and formatting scripture references', type: String, permitted: %w(de en), default: 'en'
29
+ opt :bible, 'Name of the bible module filename of an .sqlbible file', type: String, **default_bible_param
30
+ opt :lang, 'Language for parsing and formatting scripture references', type: String, permitted: %w(de en), default: Sqlbible.lang.to_s
26
31
  opt :output, 'Output filename', type: String
27
32
  opt :reference, 'Reference to show, example: "John 3:16; 10:27-30"', type: String, required: true
28
33
  end
@@ -20,6 +20,7 @@ class Sqlbible
20
20
 
21
21
  doc.css('verse').each do |v|
22
22
  osisid = v['osisID']
23
+ next unless osisid
23
24
  bookid, chapter, verse = osisid.split('.')
24
25
  unless bookid == last_bookid
25
26
  booknumber += 1
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  class Sqlbible
5
- VERSION = '1.3.4'
5
+ VERSION = '1.4.0'
6
6
  end
data/lib/sqlbible.rb CHANGED
@@ -11,7 +11,7 @@ class Sqlbible
11
11
 
12
12
  attr_reader :db_filename
13
13
 
14
- def initialize db_name
14
+ def initialize db_name=Sqlbible.bible
15
15
  @db_filename = Sqlbible.resolve_db_filename(db_name, check_existence: true)
16
16
  @db = SQLite3::Database.new(@db_filename)
17
17
  @db.enable_load_extension(true)
@@ -71,10 +71,12 @@ class Sqlbible
71
71
  end
72
72
 
73
73
  @bibles_dir = File.join(Dir.home, '.sqlbible/bibles')
74
+ @lang = :en
74
75
 
75
76
  class << self
76
77
 
77
78
  attr_reader :bibles_dir
79
+ attr_accessor :bible, :lang
78
80
 
79
81
  # Get the database schema as string
80
82
  def db_schema
@@ -131,6 +133,11 @@ class Sqlbible
131
133
  fn
132
134
  end
133
135
 
136
+ config_file = Dir[File.join(Dir.home, '.sqlbible/config{,.rb}')].first
137
+ if config_file && !ENV['NOSQLBIBLECONFIG']
138
+ load config_file
139
+ end
140
+
134
141
  end
135
142
 
136
143
  private
@@ -152,14 +159,33 @@ class Sqlbible
152
159
 
153
160
  def passage2rowids pass
154
161
  rowid1 = select_rowid(pass.b1, pass.c1, pass.v1, :asc)
162
+ unless rowid1
163
+ fail_book_chapter_verse pass.b1, pass.c1, pass.v1
164
+ end
155
165
  if rowid1 && pass.v2 == :f
156
166
  rowid2 = rowid1 + 1
157
167
  return [rowid1, rowid2]
158
168
  end
159
169
  rowid2 = select_rowid(pass.b2, pass.c2, pass.v2, :desc)
170
+ unless rowid2
171
+ fail_book_chapter_verse pass.b2, pass.c2, pass.v2
172
+ end
160
173
  [rowid1, rowid2]
161
174
  end
162
175
 
176
+ def fail_book_chapter_verse b, c, v
177
+ parts = []
178
+ parts << format('Passage for %s', b)
179
+ if c
180
+ parts << format(' chapter %d', c.to_i)
181
+ end
182
+ if v
183
+ parts << format(' verse %d', v.to_i)
184
+ end
185
+ parts << ' does not exist'
186
+ fail parts.join
187
+ end
188
+
163
189
  def select_rowid b, c, v, orderby
164
190
  cond = []
165
191
  args = []
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqlbible
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Friedrich
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2024-12-28 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: did_you_mean