sqlbible 1.3.1 → 1.3.3
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 +4 -4
- data/bin/sqlbible +55 -50
- data/lib/sqlbible/version.rb +1 -1
- data/lib/sqlbible.rb +16 -7
- metadata +17 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9766fb43d793d07864c2de0ddbc6df73883f6d606498776e0f4c323e75440618
|
|
4
|
+
data.tar.gz: 906e690a19110464e8e2a42511eadc1e29eefc7b0fcd216e8fc7d999f2fa1706
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ace4dd9751b380f6b61f95ad16b9929f6a0f88e141ebd6c3c19e35a2b8e0b4d8720383a79048c70c2de6b4a8f2fe9c109e090ba5d9c4fccaebe3afc101d3c9e4
|
|
7
|
+
data.tar.gz: 4fed2ba4ad46cd2bc47a017c2a1b8c6c13b086cf77c8467f16cbcbd0551a652f21b0e68252913d647a6a1e943de34d6cef0c96df47b0e6f268b950d3839bd19e
|
data/bin/sqlbible
CHANGED
|
@@ -7,7 +7,7 @@ require 'scripref'
|
|
|
7
7
|
require 'sqlbible'
|
|
8
8
|
|
|
9
9
|
result = OptimistXL.options do
|
|
10
|
-
synopsis 'Usage: sqlbible
|
|
10
|
+
synopsis 'Usage: sqlbible <command> [options] [filename]?'
|
|
11
11
|
subcmd :convert, 'Convert a bible from OSIS-XML to Sqlbible format' do
|
|
12
12
|
opt :bible, 'Name of the converted bible module or output filename of the generated .sqlbible file', type: String, required: true
|
|
13
13
|
opt :overwrite, 'Overwrite existing module or output file if exist', type: :Boolean, default: false
|
|
@@ -54,55 +54,60 @@ end
|
|
|
54
54
|
|
|
55
55
|
subopts = result.subcommand_options
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
57
|
+
begin
|
|
58
|
+
case result.subcommand
|
|
59
|
+
when 'convert'
|
|
60
|
+
require 'fileutils'
|
|
61
|
+
require 'sqlbible/convert'
|
|
62
|
+
unless osis_fn = result.leftovers.first
|
|
63
|
+
$stderr.puts 'no filename given'
|
|
64
|
+
exit 1
|
|
65
|
+
end
|
|
66
|
+
sqlbible_fn = Sqlbible.resolve_db_filename(subopts[:bible])
|
|
67
|
+
if !subopts[:overwrite] && File.exist?(sqlbible_fn)
|
|
68
|
+
$stderr.puts format('file %s exist, conversion aborted', sqlbible_fn)
|
|
69
|
+
exit 1
|
|
70
|
+
end
|
|
71
|
+
unless File.exist?(dir = Sqlbible.bibles_dir)
|
|
72
|
+
puts format('create directory %s', dir)
|
|
73
|
+
FileUtils.mkdir_p dir
|
|
74
|
+
end
|
|
75
|
+
if $stdout.tty?
|
|
76
|
+
puts "convert #{osis_fn} to #{sqlbible_fn} ..."
|
|
77
|
+
end
|
|
78
|
+
Sqlbible.convert osis_fn, sqlbible_fn
|
|
79
|
+
exit
|
|
80
|
+
when 'list'
|
|
81
|
+
puts 'Available bible names:'
|
|
82
|
+
puts Sqlbible.bible_names.join("\n")
|
|
83
|
+
when 'search'
|
|
84
|
+
searches = subopts[:search]
|
|
85
|
+
lang_mod = determine_lang_mod(subopts)
|
|
86
|
+
if r = subopts[:range]
|
|
87
|
+
p = Scripref::Parser.new(lang_mod)
|
|
88
|
+
range = p.parse(r)
|
|
89
|
+
else
|
|
90
|
+
range = nil
|
|
91
|
+
end
|
|
92
|
+
out = determine_out(subopts)
|
|
93
|
+
bible = Sqlbible.new(subopts[:bible])
|
|
94
|
+
regexes = searches.map {|s| Regexp.new(s)}
|
|
95
|
+
f = Scripref::Formatter.new(lang_mod, bookformat: :abbrev)
|
|
96
|
+
bible.search(regexes, range: range).each do |v|
|
|
97
|
+
out.puts format_verse(f, v)
|
|
98
|
+
end
|
|
99
|
+
when 'text'
|
|
100
|
+
lang_mod = determine_lang_mod(subopts)
|
|
86
101
|
p = Scripref::Parser.new(lang_mod)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
f = Scripref::Formatter.new(lang_mod, bookformat: :abbrev)
|
|
95
|
-
bible.search(regexes, range: range).each do |v|
|
|
96
|
-
out.puts format_verse(f, v)
|
|
97
|
-
end
|
|
98
|
-
when 'text'
|
|
99
|
-
lang_mod = determine_lang_mod(subopts)
|
|
100
|
-
p = Scripref::Parser.new(lang_mod)
|
|
101
|
-
f = Scripref::Formatter.new(lang_mod, bookformat: :abbrev)
|
|
102
|
-
ref = p.parse(subopts[:reference])
|
|
103
|
-
bible = Sqlbible.new(subopts[:bible])
|
|
104
|
-
out = determine_out subopts
|
|
105
|
-
bible.reference(ref).flatten.each do |v|
|
|
106
|
-
out.puts format_verse(f, v)
|
|
102
|
+
f = Scripref::Formatter.new(lang_mod, bookformat: :abbrev)
|
|
103
|
+
ref = p.parse(subopts[:reference])
|
|
104
|
+
bible = Sqlbible.new(subopts[:bible])
|
|
105
|
+
out = determine_out subopts
|
|
106
|
+
bible.reference(ref).flatten.each do |v|
|
|
107
|
+
out.puts format_verse(f, v)
|
|
108
|
+
end
|
|
107
109
|
end
|
|
110
|
+
rescue Exception => e
|
|
111
|
+
$stderr.puts e.message
|
|
112
|
+
exit 1
|
|
108
113
|
end
|
data/lib/sqlbible/version.rb
CHANGED
data/lib/sqlbible.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
+
require 'did_you_mean'
|
|
4
5
|
require 'scripref'
|
|
5
6
|
require 'sqlite3'
|
|
6
7
|
|
|
@@ -85,9 +86,7 @@ class Sqlbible
|
|
|
85
86
|
|
|
86
87
|
# Get a list of the names of the bibles in bibles_dir
|
|
87
88
|
def bible_names
|
|
88
|
-
Dir.
|
|
89
|
-
Dir['*.sqlbible'].map {|fn| fn.sub(/\.sqlbible$/, '')}.sort
|
|
90
|
-
end
|
|
89
|
+
Dir[File.join(bibles_dir, '*.sqlbible')].map {|fn| File.basename(fn, '.sqlbible')}.sort
|
|
91
90
|
end
|
|
92
91
|
|
|
93
92
|
# Get an array of the major and minor version of the database schema of the
|
|
@@ -114,11 +113,21 @@ class Sqlbible
|
|
|
114
113
|
end
|
|
115
114
|
|
|
116
115
|
def resolve_db_filename db_name
|
|
117
|
-
|
|
118
|
-
if File.basename(
|
|
119
|
-
File.join(bibles_dir, format('%s.sqlbible',
|
|
120
|
-
|
|
116
|
+
db_name = db_name.to_s
|
|
117
|
+
if File.basename(db_name, '.sqlbible') == db_name
|
|
118
|
+
fn = File.join(bibles_dir, format('%s.sqlbible', db_name))
|
|
119
|
+
unless bible_names.include?(db_name)
|
|
120
|
+
msg = format('database %s not found, file %s does not exist', db_name, fn)
|
|
121
|
+
sc = DidYouMean::SpellChecker.new(dictionary: bible_names)
|
|
122
|
+
res = sc.correct(db_name)
|
|
123
|
+
unless res.empty?
|
|
124
|
+
msg = format("%s\ndid you mean %s", msg, res.join(', '))
|
|
125
|
+
end
|
|
126
|
+
fail ArgumentError, msg
|
|
127
|
+
end
|
|
121
128
|
fn
|
|
129
|
+
else
|
|
130
|
+
db_name
|
|
122
131
|
end
|
|
123
132
|
end
|
|
124
133
|
|
metadata
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sqlbible
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.3
|
|
5
5
|
platform: ruby
|
|
6
|
-
original_platform: ''
|
|
7
6
|
authors:
|
|
8
7
|
- Jan Friedrich
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date: 2024-12-
|
|
10
|
+
date: 2024-12-20 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: did_you_mean
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '2.0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '2.0'
|
|
13
26
|
- !ruby/object:Gem::Dependency
|
|
14
27
|
name: nokogiri
|
|
15
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -111,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
111
124
|
- !ruby/object:Gem::Version
|
|
112
125
|
version: '0'
|
|
113
126
|
requirements: []
|
|
114
|
-
rubygems_version: 3.6.
|
|
127
|
+
rubygems_version: 3.6.1
|
|
115
128
|
specification_version: 4
|
|
116
129
|
summary: Library for bibles as SQLite databases
|
|
117
130
|
test_files: []
|