sqlbible 1.5.0 → 1.6.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/bin/sqlbible +36 -9
- data/lib/sqlbible/ansicolor.rb +37 -0
- data/lib/sqlbible/version.rb +1 -1
- data/lib/sqlbible.rb +3 -1
- metadata +31 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0c3587cce5d8ce1c25b56573857ab5dd2646424caf7619bef4a2b19cf0a4b6f3
|
|
4
|
+
data.tar.gz: 1ec12d901611d25a4b77adcbef952f1a182a452b15ad319c2e84a19eed76a2fb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 625757471d933f660113a01e930cab73545bcd28bc51a39db5b811a77ca2e49101aa214695f31b469b93fe3477168aa527673842e630a9dfcfc459a40b4180e3
|
|
7
|
+
data.tar.gz: 156977de3c8c7da1ab0b02fc60f7b497f46ef1f3b3d1f9251904863318e354875541bf3d827c2cec22089aa784b5196f099efb8628792bdfb2486affa12b635b
|
data/bin/sqlbible
CHANGED
|
@@ -5,12 +5,17 @@
|
|
|
5
5
|
require 'optimist_xl'
|
|
6
6
|
require 'scripref'
|
|
7
7
|
require 'sqlbible'
|
|
8
|
+
require 'sqlbible/ansicolor'
|
|
8
9
|
|
|
9
10
|
default_bible_param = {}
|
|
10
11
|
if b = Sqlbible.bible
|
|
11
12
|
default_bible_param[:default] = b.to_s
|
|
12
13
|
end
|
|
13
14
|
|
|
15
|
+
unless $stdout.tty?
|
|
16
|
+
Sqlbible.colorize = false
|
|
17
|
+
end
|
|
18
|
+
|
|
14
19
|
result = OptimistXL.options do
|
|
15
20
|
synopsis 'Usage: sqlbible <command> [options] [filename]?'
|
|
16
21
|
subcmd :convert, 'Convert a bible from OSIS-XML to Sqlbible format' do
|
|
@@ -20,6 +25,9 @@ result = OptimistXL.options do
|
|
|
20
25
|
subcmd :list, 'Show a list of the names of the bibles in central directory'
|
|
21
26
|
subcmd :search, 'Search with regular expressions' do
|
|
22
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
|
|
23
31
|
opt :search, 'Regular expression to search (multiple allowed)', type: String, multi: true, required: true
|
|
24
32
|
opt :lang, 'Language for parsing and formatting scripture references', type: String, permitted: %w(de en), default: Sqlbible.lang.to_s
|
|
25
33
|
opt :output, 'Output filename', type: String
|
|
@@ -27,6 +35,9 @@ result = OptimistXL.options do
|
|
|
27
35
|
end
|
|
28
36
|
subcmd :text, 'Show text of references' do
|
|
29
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
|
|
30
41
|
opt :lang, 'Language for parsing and formatting scripture references', type: String, permitted: %w(de en), default: Sqlbible.lang.to_s
|
|
31
42
|
opt :output, 'Output filename', type: String
|
|
32
43
|
opt :reference, 'Reference to show, example: "John 3:16; 10:27-30"', type: String, required: true
|
|
@@ -53,8 +64,27 @@ def determine_out subopts
|
|
|
53
64
|
end
|
|
54
65
|
end
|
|
55
66
|
|
|
56
|
-
def
|
|
57
|
-
|
|
67
|
+
def format_verse_ref f, v
|
|
68
|
+
ref = f.format(v.scripref_passage)
|
|
69
|
+
if Sqlbible.colorize
|
|
70
|
+
Ansicolor.apply(ref, Sqlbible.color_reference)
|
|
71
|
+
else
|
|
72
|
+
ref
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def format_text v, regexes
|
|
77
|
+
text = v.plaintext.gsub("\n", ' ¶')
|
|
78
|
+
if Sqlbible.colorize
|
|
79
|
+
regexes.each do |re|
|
|
80
|
+
text = text.gsub(re, Ansicolor.apply('\0', Sqlbible.color_emphasize))
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
text
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def format_verse_line f, v, regexes=[]
|
|
87
|
+
format('%s: %s', format_verse_ref(f, v), format_text(v, regexes))
|
|
58
88
|
end
|
|
59
89
|
|
|
60
90
|
subopts = result.subcommand_options
|
|
@@ -65,13 +95,11 @@ begin
|
|
|
65
95
|
require 'fileutils'
|
|
66
96
|
require 'sqlbible/convert'
|
|
67
97
|
unless osis_fn = result.leftovers.first
|
|
68
|
-
|
|
69
|
-
exit 1
|
|
98
|
+
fail 'no filename given'
|
|
70
99
|
end
|
|
71
100
|
sqlbible_fn = Sqlbible.resolve_db_filename(subopts[:bible])
|
|
72
101
|
if !subopts[:overwrite] && File.exist?(sqlbible_fn)
|
|
73
|
-
|
|
74
|
-
exit 1
|
|
102
|
+
fail format('file %s exist, conversion aborted', sqlbible_fn)
|
|
75
103
|
end
|
|
76
104
|
unless File.exist?(dir = Sqlbible.bibles_dir)
|
|
77
105
|
puts format('create directory %s', dir)
|
|
@@ -81,7 +109,6 @@ begin
|
|
|
81
109
|
puts "convert #{osis_fn} to #{sqlbible_fn} ..."
|
|
82
110
|
end
|
|
83
111
|
Sqlbible.convert osis_fn, sqlbible_fn
|
|
84
|
-
exit
|
|
85
112
|
when 'list'
|
|
86
113
|
puts 'Available bible names:'
|
|
87
114
|
puts Sqlbible.bible_names.join("\n")
|
|
@@ -99,7 +126,7 @@ begin
|
|
|
99
126
|
regexes = searches.map {|s| Regexp.new(s)}
|
|
100
127
|
f = Scripref::Formatter.new(lang_mod, bookformat: :abbrev)
|
|
101
128
|
bible.search(regexes, range: range).each do |v|
|
|
102
|
-
out.puts
|
|
129
|
+
out.puts format_verse_line(f, v, regexes)
|
|
103
130
|
end
|
|
104
131
|
when 'text'
|
|
105
132
|
lang_mod = determine_lang_mod(subopts)
|
|
@@ -109,7 +136,7 @@ begin
|
|
|
109
136
|
bible = Sqlbible.new(subopts[:bible])
|
|
110
137
|
out = determine_out subopts
|
|
111
138
|
bible.reference(ref).flatten.each do |v|
|
|
112
|
-
out.puts
|
|
139
|
+
out.puts format_verse_line(f, v)
|
|
113
140
|
end
|
|
114
141
|
end
|
|
115
142
|
rescue Exception => e
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# Copyright (c) 2019 by Jan Friedrich <janfri26@gmail.com>
|
|
5
|
+
# License: Public Domain
|
|
6
|
+
|
|
7
|
+
module Ansicolor
|
|
8
|
+
|
|
9
|
+
@codes = {}
|
|
10
|
+
|
|
11
|
+
%i(bold faint italic underline).each_with_index do |mode, i|
|
|
12
|
+
@codes[mode] = 1 + i
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
%i(black red green yellow blue magenta cyan white).each_with_index do |color, i|
|
|
16
|
+
@codes[color] = 30 + i
|
|
17
|
+
@codes[format('@%s', color).to_sym] = 40 + i
|
|
18
|
+
@codes[format('light%s', color).to_sym] = 90 + i
|
|
19
|
+
@codes[format('@light%s', color).to_sym] = 100 + i
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class << self
|
|
23
|
+
def apply str, *codes
|
|
24
|
+
codes.flatten.each do |c|
|
|
25
|
+
num = @codes[c.to_sym]
|
|
26
|
+
fail format('Code %s not supported.', c) unless num
|
|
27
|
+
str = format("\e[%dm%s", num, str)
|
|
28
|
+
end
|
|
29
|
+
format("%s\e[0m", str)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def codes
|
|
33
|
+
@codes.keys
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
data/lib/sqlbible/version.rb
CHANGED
data/lib/sqlbible.rb
CHANGED
|
@@ -78,12 +78,14 @@ class Sqlbible
|
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
@bibles_dir = File.join(Dir.home, '.sqlbible/bibles')
|
|
81
|
+
@color_reference = :blue
|
|
82
|
+
@color_emphasize = :underline
|
|
81
83
|
@lang = :en
|
|
82
84
|
|
|
83
85
|
class << self
|
|
84
86
|
|
|
85
87
|
attr_reader :bibles_dir
|
|
86
|
-
attr_accessor :bible, :lang
|
|
88
|
+
attr_accessor :colorize, :color_reference, :color_emphasize, :bible, :lang
|
|
87
89
|
|
|
88
90
|
# Get the database schema as string
|
|
89
91
|
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.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jan Friedrich
|
|
@@ -93,6 +93,34 @@ dependencies:
|
|
|
93
93
|
- - "~>"
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
95
|
version: '3.0'
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: regtest
|
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - "~>"
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: 2.5.0
|
|
103
|
+
type: :development
|
|
104
|
+
prerelease: false
|
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - "~>"
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: 2.5.0
|
|
110
|
+
- !ruby/object:Gem::Dependency
|
|
111
|
+
name: test-unit
|
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
|
113
|
+
requirements:
|
|
114
|
+
- - "~>"
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: 3.7.0
|
|
117
|
+
type: :development
|
|
118
|
+
prerelease: false
|
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - "~>"
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: 3.7.0
|
|
96
124
|
email: janfri26@gmail.com
|
|
97
125
|
executables:
|
|
98
126
|
- sqlbible
|
|
@@ -103,6 +131,7 @@ files:
|
|
|
103
131
|
- README.md
|
|
104
132
|
- bin/sqlbible
|
|
105
133
|
- lib/sqlbible.rb
|
|
134
|
+
- lib/sqlbible/ansicolor.rb
|
|
106
135
|
- lib/sqlbible/convert.rb
|
|
107
136
|
- lib/sqlbible/version.rb
|
|
108
137
|
- schema.sql
|
|
@@ -124,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
124
153
|
- !ruby/object:Gem::Version
|
|
125
154
|
version: '0'
|
|
126
155
|
requirements: []
|
|
127
|
-
rubygems_version: 3.
|
|
156
|
+
rubygems_version: 3.8.0.dev
|
|
128
157
|
specification_version: 4
|
|
129
158
|
summary: Library for bibles as SQLite databases
|
|
130
159
|
test_files: []
|