sqlbible 1.7.1 → 1.9.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 +4 -4
- data/README.md +1 -0
- data/bin/sqlbible +59 -84
- data/bin/sqlbible-convert +36 -0
- data/lib/sqlbible/version.rb +1 -1
- data/lib/sqlbible.rb +2 -1
- metadata +7 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b56764d9e3209aadc3d033fdb8870ebf7b32aeed2c036527ad0211f637890db4
|
|
4
|
+
data.tar.gz: 61562839dd855f990b6eebcafd375453e1e70e66d38574c3755cbcbb4a0c9c86
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b3b396178ca096c2d153ffb241099c0d2bfdc7981d5b4bd8a0e033fd125e1a13231c4cf1f8c85309725fcd2067e37f63f31529149b5829aadf4744d534221c6c
|
|
7
|
+
data.tar.gz: 2e5d47096a3023c4510f44359db1683ac3e4d08ba597c2178c9d04365d14f30a7158c0f292cf965b7bb73d8ccf50a32a5bf6924e473a29ccb0a437a3edcc8318
|
data/README.md
CHANGED
data/bin/sqlbible
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# encoding: utf-8
|
|
3
3
|
# frozen_string_literal: false
|
|
4
4
|
|
|
5
|
-
require '
|
|
5
|
+
require 'optimist'
|
|
6
6
|
require 'scripref'
|
|
7
7
|
require 'sqlbible'
|
|
8
8
|
require 'sqlbible/ansicolor'
|
|
@@ -12,41 +12,30 @@ if b = Sqlbible.bible
|
|
|
12
12
|
default_bible_param[:default] = b.to_s
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
Sqlbible.colorize = false
|
|
17
|
-
end
|
|
15
|
+
$explizit_opts = Set.new
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
synopsis 'Usage: sqlbible
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
end
|
|
25
|
-
subcmd :list, 'Show a list of the names of the bibles in central directory'
|
|
26
|
-
subcmd :search, 'Search with regular expressions' do
|
|
27
|
-
opt :bible, 'Name of the bible module filename of an .sqlbible file', type: String, **default_bible_param
|
|
28
|
-
opt :colorize, 'Colorize output' do |v|
|
|
29
|
-
Sqlbible.colorize = v
|
|
30
|
-
end
|
|
31
|
-
opt :search, 'Regular expression to search (multiple allowed)', type: String, multi: true, required: true
|
|
32
|
-
opt :lang, 'Language for parsing and formatting scripture references', type: String, permitted: %w(de en), default: Sqlbible.lang.to_s
|
|
33
|
-
opt :output, 'Output filename', type: String
|
|
34
|
-
opt :range, 'Search range, example: "John 1-10"', type: String
|
|
35
|
-
end
|
|
36
|
-
subcmd :text, 'Show text of references' do
|
|
37
|
-
opt :bible, 'Name of the bible module filename of an .sqlbible file', type: String, **default_bible_param
|
|
38
|
-
opt :colorize, 'Colorize output' do |v|
|
|
39
|
-
Sqlbible.colorize = v
|
|
40
|
-
end
|
|
41
|
-
opt :lang, 'Language for parsing and formatting scripture references', type: String, permitted: %w(de en), default: Sqlbible.lang.to_s
|
|
42
|
-
opt :output, 'Output filename', type: String
|
|
43
|
-
opt :reference, 'Reference to show, example: "John 3:16; 10:27-30"', type: String, required: true
|
|
17
|
+
$opts = Optimist.options do
|
|
18
|
+
synopsis 'Usage: sqlbible [options] [search regexes]*'
|
|
19
|
+
opt :bible, 'Name of the bible module filename of an .sqlbible file', type: String, **default_bible_param
|
|
20
|
+
opt :color, 'Colorize output', default: Sqlbible.color do |v|
|
|
21
|
+
$explizit_opts << :color
|
|
44
22
|
end
|
|
23
|
+
opt :info, 'Show infos for installed bibles'
|
|
24
|
+
opt :lang, 'Language for parsing and formatting scripture references', type: String, permitted: %w(de en), default: Sqlbible.lang.to_s
|
|
25
|
+
opt :output, 'Output filename', type: String
|
|
26
|
+
opt :pager, 'Use pager for terminal output', default: Sqlbible.pager
|
|
27
|
+
opt :reference, 'Reference to show or search, example: "John 3:16; 10:27-30"', type: String
|
|
45
28
|
version format("sqlbible %s\nschema version %s", Sqlbible::VERSION, Sqlbible.schema_version)
|
|
46
29
|
end
|
|
47
30
|
|
|
48
|
-
|
|
49
|
-
|
|
31
|
+
unless $explizit_opts.include? :color
|
|
32
|
+
if !$stdout.tty? || $opts[:output]
|
|
33
|
+
$opts[:color] = false
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def determine_lang_mod
|
|
38
|
+
case l = $opts[:lang]
|
|
50
39
|
when 'en', nil
|
|
51
40
|
Scripref::English
|
|
52
41
|
when 'de'
|
|
@@ -56,17 +45,23 @@ def determine_lang_mod subopts
|
|
|
56
45
|
end
|
|
57
46
|
end
|
|
58
47
|
|
|
59
|
-
def
|
|
60
|
-
if fn =
|
|
61
|
-
|
|
48
|
+
def open_out
|
|
49
|
+
if fn = $opts[:output]
|
|
50
|
+
File.open(fn, 'w') do |f|
|
|
51
|
+
yield f
|
|
52
|
+
end
|
|
53
|
+
elsif $opts[:pager]
|
|
54
|
+
IO.popen(Sqlbible.pager_command, 'w') do |p|
|
|
55
|
+
yield p
|
|
56
|
+
end
|
|
62
57
|
else
|
|
63
|
-
|
|
58
|
+
yield $stdout
|
|
64
59
|
end
|
|
65
60
|
end
|
|
66
61
|
|
|
67
62
|
def format_verse_ref f, v
|
|
68
63
|
ref = f.format(v.scripref_passage)
|
|
69
|
-
if
|
|
64
|
+
if $opts[:color]
|
|
70
65
|
Ansicolor.apply(ref, Sqlbible.color_reference)
|
|
71
66
|
else
|
|
72
67
|
ref
|
|
@@ -75,7 +70,7 @@ end
|
|
|
75
70
|
|
|
76
71
|
def format_text v, regexes
|
|
77
72
|
text = v.plaintext.gsub("\n", ' ¶')
|
|
78
|
-
if
|
|
73
|
+
if $opts[:color]
|
|
79
74
|
regexes.each do |re|
|
|
80
75
|
text = text.gsub(re, Ansicolor.apply('\0', Sqlbible.color_emphasize))
|
|
81
76
|
end
|
|
@@ -87,56 +82,36 @@ def format_verse_line f, v, regexes=[]
|
|
|
87
82
|
format('%s: %s', format_verse_ref(f, v), format_text(v, regexes))
|
|
88
83
|
end
|
|
89
84
|
|
|
90
|
-
subopts = result.subcommand_options
|
|
91
|
-
|
|
92
85
|
begin
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
fail 'no filename given'
|
|
99
|
-
end
|
|
100
|
-
sqlbible_fn = Sqlbible.resolve_db_filename(subopts[:bible])
|
|
101
|
-
if !subopts[:overwrite] && File.exist?(sqlbible_fn)
|
|
102
|
-
fail format('file %s exist, conversion aborted', sqlbible_fn)
|
|
103
|
-
end
|
|
104
|
-
unless File.exist?(dir = Sqlbible.bibles_dir)
|
|
105
|
-
puts format('create directory %s', dir)
|
|
106
|
-
FileUtils.mkdir_p dir
|
|
107
|
-
end
|
|
108
|
-
if $stdout.tty?
|
|
109
|
-
puts "convert #{osis_fn} to #{sqlbible_fn} ..."
|
|
110
|
-
end
|
|
111
|
-
Sqlbible.convert osis_fn, sqlbible_fn
|
|
112
|
-
when 'list'
|
|
113
|
-
puts 'Available bible names:'
|
|
114
|
-
puts Sqlbible.bible_names.join("\n")
|
|
115
|
-
when 'search'
|
|
116
|
-
searches = subopts[:search]
|
|
117
|
-
lang_mod = determine_lang_mod(subopts)
|
|
118
|
-
if r = subopts[:range]
|
|
119
|
-
p = Scripref::Parser.new(lang_mod)
|
|
120
|
-
range = p.parse(r)
|
|
121
|
-
else
|
|
122
|
-
range = nil
|
|
86
|
+
if $opts[:info]
|
|
87
|
+
names = Sqlbible.bible_names
|
|
88
|
+
max_size = names.map(&:size).max
|
|
89
|
+
names.each do |n|
|
|
90
|
+
puts format("%-#{max_size}s (schema version: %s)", n, Sqlbible.new(n).schema_version)
|
|
123
91
|
end
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
92
|
+
return
|
|
93
|
+
end
|
|
94
|
+
lang_mod = determine_lang_mod
|
|
95
|
+
p = Scripref::Parser.new(lang_mod)
|
|
96
|
+
f = Scripref::Formatter.new(lang_mod, abbrev_level: 1)
|
|
97
|
+
if r = $opts[:reference]
|
|
98
|
+
ref = p.parse(r)
|
|
99
|
+
else
|
|
100
|
+
ref = nil
|
|
101
|
+
end
|
|
102
|
+
bible = Sqlbible.new($opts[:bible])
|
|
103
|
+
if ARGV.size > 0
|
|
104
|
+
regexes = ARGV.map {|s| Regexp.new(s)}
|
|
105
|
+
open_out do |out|
|
|
106
|
+
bible.search(regexes, range: ref).each do |v|
|
|
107
|
+
out.puts format_verse_line(f, v, regexes)
|
|
108
|
+
end
|
|
130
109
|
end
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
bible = Sqlbible.new(subopts[:bible])
|
|
137
|
-
out = determine_out subopts
|
|
138
|
-
bible.reference(ref).flatten.each do |v|
|
|
139
|
-
out.puts format_verse_line(f, v)
|
|
110
|
+
else
|
|
111
|
+
open_out do |out|
|
|
112
|
+
bible.reference(Array(ref)).flatten.each do |v|
|
|
113
|
+
out.puts format_verse_line(f, v)
|
|
114
|
+
end
|
|
140
115
|
end
|
|
141
116
|
end
|
|
142
117
|
rescue Exception => e
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
# frozen_string_literal: false
|
|
4
|
+
|
|
5
|
+
require 'optimist'
|
|
6
|
+
require 'sqlbible'
|
|
7
|
+
require 'fileutils'
|
|
8
|
+
require 'sqlbible/convert'
|
|
9
|
+
|
|
10
|
+
opts = Optimist.options do
|
|
11
|
+
synopsis 'Usage: sqlbible [options] [filename]'
|
|
12
|
+
opt :bible, 'Name of the converted bible module or output filename of the generated .sqlbible file', type: String, required: true
|
|
13
|
+
opt :overwrite, 'Overwrite existing module or output file if exist', type: :Boolean, default: false
|
|
14
|
+
version format("sqlbible %s\nschema version %s", Sqlbible::VERSION, Sqlbible.schema_version)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
begin
|
|
18
|
+
unless osis_fn = ARGV.first
|
|
19
|
+
fail 'no filename given'
|
|
20
|
+
end
|
|
21
|
+
sqlbible_fn = Sqlbible.resolve_db_filename(opts[:bible])
|
|
22
|
+
if !opts[:overwrite] && File.exist?(sqlbible_fn)
|
|
23
|
+
fail format('file %s exist, conversion aborted', sqlbible_fn)
|
|
24
|
+
end
|
|
25
|
+
unless File.exist?(dir = Sqlbible.bibles_dir)
|
|
26
|
+
puts format('create directory %s', dir)
|
|
27
|
+
FileUtils.mkdir_p dir
|
|
28
|
+
end
|
|
29
|
+
if $stdout.tty?
|
|
30
|
+
puts "convert #{osis_fn} to #{sqlbible_fn} ..."
|
|
31
|
+
end
|
|
32
|
+
Sqlbible.convert osis_fn, sqlbible_fn
|
|
33
|
+
rescue Exception => e
|
|
34
|
+
$stderr.puts e.message
|
|
35
|
+
exit 1
|
|
36
|
+
end
|
data/lib/sqlbible/version.rb
CHANGED
data/lib/sqlbible.rb
CHANGED
|
@@ -85,11 +85,12 @@ class Sqlbible
|
|
|
85
85
|
@color_reference = :blue
|
|
86
86
|
@color_emphasize = :underline
|
|
87
87
|
@lang = :en
|
|
88
|
+
@pager_command = 'less -FRSX'
|
|
88
89
|
|
|
89
90
|
class << self
|
|
90
91
|
|
|
91
92
|
attr_reader :bibles_dir
|
|
92
|
-
attr_accessor :
|
|
93
|
+
attr_accessor :color, :color_reference, :color_emphasize, :bible, :lang, :pager, :pager_command
|
|
93
94
|
|
|
94
95
|
# Get the database schema as string
|
|
95
96
|
def db_schema
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sqlbible
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jan Friedrich
|
|
@@ -38,19 +38,19 @@ dependencies:
|
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '1.16'
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
|
-
name:
|
|
41
|
+
name: optimist
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
44
|
- - "~>"
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '3.
|
|
46
|
+
version: '3.2'
|
|
47
47
|
type: :runtime
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - "~>"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '3.
|
|
53
|
+
version: '3.2'
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
55
|
name: scripref
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -124,12 +124,14 @@ dependencies:
|
|
|
124
124
|
email: janfri26@gmail.com
|
|
125
125
|
executables:
|
|
126
126
|
- sqlbible
|
|
127
|
+
- sqlbible-convert
|
|
127
128
|
extensions: []
|
|
128
129
|
extra_rdoc_files: []
|
|
129
130
|
files:
|
|
130
131
|
- LICENSE
|
|
131
132
|
- README.md
|
|
132
133
|
- bin/sqlbible
|
|
134
|
+
- bin/sqlbible-convert
|
|
133
135
|
- lib/sqlbible.rb
|
|
134
136
|
- lib/sqlbible/ansicolor.rb
|
|
135
137
|
- lib/sqlbible/convert.rb
|
|
@@ -153,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
153
155
|
- !ruby/object:Gem::Version
|
|
154
156
|
version: '0'
|
|
155
157
|
requirements: []
|
|
156
|
-
rubygems_version: 4.
|
|
158
|
+
rubygems_version: 4.0.6
|
|
157
159
|
specification_version: 4
|
|
158
160
|
summary: Library for bibles as SQLite databases
|
|
159
161
|
test_files: []
|