sqlbible 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8eddf93d395b8029d0de33f4f87e68c719612675e808aa135d583e7d5448f95
4
- data.tar.gz: 5ecefd2dff29958e4dd5714a1f07385508478c05381bbed70d12317d3392cae5
3
+ metadata.gz: 9766fb43d793d07864c2de0ddbc6df73883f6d606498776e0f4c323e75440618
4
+ data.tar.gz: 906e690a19110464e8e2a42511eadc1e29eefc7b0fcd216e8fc7d999f2fa1706
5
5
  SHA512:
6
- metadata.gz: 9ad3995f53208bab47b42b75007661f849664855665e066a154cc271891dc195b6aca2057d529839e86309e8da9df39300e3519eecbebe2cad50fb374d1772d6
7
- data.tar.gz: e5b669d1610f13f753106e2dba8f530e8b715f4456eafcca974475109fe99ce80a696d6fe0fd948064dcf5e70399f04bd5b6d9ea0a85aae752635cad9b2ddc74
6
+ metadata.gz: ace4dd9751b380f6b61f95ad16b9929f6a0f88e141ebd6c3c19e35a2b8e0b4d8720383a79048c70c2de6b4a8f2fe9c109e090ba5d9c4fccaebe3afc101d3c9e4
7
+ data.tar.gz: 4fed2ba4ad46cd2bc47a017c2a1b8c6c13b086cf77c8467f16cbcbd0551a652f21b0e68252913d647a6a1e943de34d6cef0c96df47b0e6f268b950d3839bd19e
data/bin/sqlbible CHANGED
@@ -54,55 +54,60 @@ end
54
54
 
55
55
  subopts = result.subcommand_options
56
56
 
57
- case result.subcommand
58
- when 'convert'
59
- require 'fileutils'
60
- require 'sqlbible/convert'
61
- unless osis_fn = result.leftovers.first
62
- $stderr.puts 'no filename given'
63
- exit 1
64
- end
65
- sqlbible_fn = Sqlbible.resolve_db_filename(subopts[:bible])
66
- if !subopts[:overwrite] && File.exist?(sqlbible_fn)
67
- $stderr.puts format('file %s exist, conversion aborted', sqlbible_fn)
68
- exit 1
69
- end
70
- unless File.exist?(dir = Sqlbible.bibles_dir)
71
- puts format('create directory %s', dir)
72
- FileUtils.mkdir_p dir
73
- end
74
- if $stdout.tty?
75
- puts "convert #{osis_fn} to #{sqlbible_fn} ..."
76
- end
77
- Sqlbible.convert osis_fn, sqlbible_fn
78
- exit
79
- when 'list'
80
- puts 'Available bible names:'
81
- puts Sqlbible.bible_names.join("\n")
82
- when 'search'
83
- searches = subopts[:search]
84
- lang_mod = determine_lang_mod(subopts)
85
- if r = subopts[:range]
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
- range = p.parse(r)
88
- else
89
- range = nil
90
- end
91
- out = determine_out(subopts)
92
- bible = Sqlbible.new(subopts[:bible])
93
- regexes = searches.map {|s| Regexp.new(s)}
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
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  class Sqlbible
5
- VERSION = '1.3.2'
5
+ VERSION = '1.3.3'
6
6
  end
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
 
@@ -112,11 +113,21 @@ class Sqlbible
112
113
  end
113
114
 
114
115
  def resolve_db_filename db_name
115
- fn = db_name.to_s
116
- if File.basename(fn) == fn
117
- File.join(bibles_dir, format('%s.sqlbible', fn.sub(/\.sqlbible$/, '')))
118
- else
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
119
128
  fn
129
+ else
130
+ db_name
120
131
  end
121
132
  end
122
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.2
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-18 00:00:00.000000000 Z
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.0.dev
127
+ rubygems_version: 3.6.1
115
128
  specification_version: 4
116
129
  summary: Library for bibles as SQLite databases
117
130
  test_files: []