sqlbible 1.8.0 → 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/bin/sqlbible +30 -24
- data/lib/sqlbible/version.rb +1 -1
- data/lib/sqlbible.rb +1 -1
- metadata +2 -2
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/bin/sqlbible
CHANGED
|
@@ -12,14 +12,14 @@ 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
|
-
opts = Optimist.options do
|
|
17
|
+
$opts = Optimist.options do
|
|
20
18
|
synopsis 'Usage: sqlbible [options] [search regexes]*'
|
|
21
19
|
opt :bible, 'Name of the bible module filename of an .sqlbible file', type: String, **default_bible_param
|
|
22
|
-
opt :
|
|
20
|
+
opt :color, 'Colorize output', default: Sqlbible.color do |v|
|
|
21
|
+
$explizit_opts << :color
|
|
22
|
+
end
|
|
23
23
|
opt :info, 'Show infos for installed bibles'
|
|
24
24
|
opt :lang, 'Language for parsing and formatting scripture references', type: String, permitted: %w(de en), default: Sqlbible.lang.to_s
|
|
25
25
|
opt :output, 'Output filename', type: String
|
|
@@ -28,8 +28,14 @@ opts = Optimist.options do
|
|
|
28
28
|
version format("sqlbible %s\nschema version %s", Sqlbible::VERSION, Sqlbible.schema_version)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
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]
|
|
33
39
|
when 'en', nil
|
|
34
40
|
Scripref::English
|
|
35
41
|
when 'de'
|
|
@@ -39,12 +45,12 @@ def determine_lang_mod opts
|
|
|
39
45
|
end
|
|
40
46
|
end
|
|
41
47
|
|
|
42
|
-
def open_out
|
|
43
|
-
if fn = opts[:output]
|
|
48
|
+
def open_out
|
|
49
|
+
if fn = $opts[:output]
|
|
44
50
|
File.open(fn, 'w') do |f|
|
|
45
51
|
yield f
|
|
46
52
|
end
|
|
47
|
-
elsif opts[:pager]
|
|
53
|
+
elsif $opts[:pager]
|
|
48
54
|
IO.popen(Sqlbible.pager_command, 'w') do |p|
|
|
49
55
|
yield p
|
|
50
56
|
end
|
|
@@ -53,18 +59,18 @@ def open_out opts
|
|
|
53
59
|
end
|
|
54
60
|
end
|
|
55
61
|
|
|
56
|
-
def format_verse_ref
|
|
62
|
+
def format_verse_ref f, v
|
|
57
63
|
ref = f.format(v.scripref_passage)
|
|
58
|
-
if opts[:
|
|
64
|
+
if $opts[:color]
|
|
59
65
|
Ansicolor.apply(ref, Sqlbible.color_reference)
|
|
60
66
|
else
|
|
61
67
|
ref
|
|
62
68
|
end
|
|
63
69
|
end
|
|
64
70
|
|
|
65
|
-
def format_text
|
|
71
|
+
def format_text v, regexes
|
|
66
72
|
text = v.plaintext.gsub("\n", ' ¶')
|
|
67
|
-
if opts[:
|
|
73
|
+
if $opts[:color]
|
|
68
74
|
regexes.each do |re|
|
|
69
75
|
text = text.gsub(re, Ansicolor.apply('\0', Sqlbible.color_emphasize))
|
|
70
76
|
end
|
|
@@ -72,12 +78,12 @@ def format_text opts, v, regexes
|
|
|
72
78
|
text
|
|
73
79
|
end
|
|
74
80
|
|
|
75
|
-
def format_verse_line
|
|
76
|
-
format('%s: %s', format_verse_ref(
|
|
81
|
+
def format_verse_line f, v, regexes=[]
|
|
82
|
+
format('%s: %s', format_verse_ref(f, v), format_text(v, regexes))
|
|
77
83
|
end
|
|
78
84
|
|
|
79
85
|
begin
|
|
80
|
-
if opts[:info]
|
|
86
|
+
if $opts[:info]
|
|
81
87
|
names = Sqlbible.bible_names
|
|
82
88
|
max_size = names.map(&:size).max
|
|
83
89
|
names.each do |n|
|
|
@@ -85,26 +91,26 @@ begin
|
|
|
85
91
|
end
|
|
86
92
|
return
|
|
87
93
|
end
|
|
88
|
-
lang_mod = determine_lang_mod
|
|
94
|
+
lang_mod = determine_lang_mod
|
|
89
95
|
p = Scripref::Parser.new(lang_mod)
|
|
90
96
|
f = Scripref::Formatter.new(lang_mod, abbrev_level: 1)
|
|
91
|
-
if r = opts[:reference]
|
|
97
|
+
if r = $opts[:reference]
|
|
92
98
|
ref = p.parse(r)
|
|
93
99
|
else
|
|
94
100
|
ref = nil
|
|
95
101
|
end
|
|
96
|
-
bible = Sqlbible.new(opts[:bible])
|
|
102
|
+
bible = Sqlbible.new($opts[:bible])
|
|
97
103
|
if ARGV.size > 0
|
|
98
104
|
regexes = ARGV.map {|s| Regexp.new(s)}
|
|
99
|
-
open_out
|
|
105
|
+
open_out do |out|
|
|
100
106
|
bible.search(regexes, range: ref).each do |v|
|
|
101
|
-
out.puts format_verse_line(
|
|
107
|
+
out.puts format_verse_line(f, v, regexes)
|
|
102
108
|
end
|
|
103
109
|
end
|
|
104
110
|
else
|
|
105
|
-
open_out
|
|
111
|
+
open_out do |out|
|
|
106
112
|
bible.reference(Array(ref)).flatten.each do |v|
|
|
107
|
-
out.puts format_verse_line(
|
|
113
|
+
out.puts format_verse_line(f, v)
|
|
108
114
|
end
|
|
109
115
|
end
|
|
110
116
|
end
|
data/lib/sqlbible/version.rb
CHANGED
data/lib/sqlbible.rb
CHANGED
|
@@ -90,7 +90,7 @@ class Sqlbible
|
|
|
90
90
|
class << self
|
|
91
91
|
|
|
92
92
|
attr_reader :bibles_dir
|
|
93
|
-
attr_accessor :
|
|
93
|
+
attr_accessor :color, :color_reference, :color_emphasize, :bible, :lang, :pager, :pager_command
|
|
94
94
|
|
|
95
95
|
# Get the database schema as string
|
|
96
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
|
|
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
155
155
|
- !ruby/object:Gem::Version
|
|
156
156
|
version: '0'
|
|
157
157
|
requirements: []
|
|
158
|
-
rubygems_version: 4.
|
|
158
|
+
rubygems_version: 4.0.6
|
|
159
159
|
specification_version: 4
|
|
160
160
|
summary: Library for bibles as SQLite databases
|
|
161
161
|
test_files: []
|