sqlbible 1.3.4 → 1.4.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 +9 -4
- data/lib/sqlbible/convert.rb +1 -0
- data/lib/sqlbible/version.rb +1 -1
- data/lib/sqlbible.rb +27 -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: f39d010a766a67ef4574af340249107716a57be643c51cea6dbfb78c71b14682
         | 
| 4 | 
            +
              data.tar.gz: 48861d4b399b62d0d572ec7e414eb8188f2364b0c6b3d5009fbcd37c917ecaf8
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 4c37623b9841ecde065861f6364a6be31758d3f7c358004f32983dd96ae71870b8afa6f99682871b4e148af4cf8d9e2ad41a50157323c0aea85404477ac634d7
         | 
| 7 | 
            +
              data.tar.gz: 31e6d182ba802cfc3f96581c239e8fc5d7039b26f1fc1476b0b0502820360d0b948fbaefd276ec035b5a24a2bbd755bea3ccd59e5e208d051ba3bd86f37fd7e7
         | 
    
        data/bin/sqlbible
    CHANGED
    
    | @@ -6,6 +6,11 @@ require 'optimist_xl' | |
| 6 6 | 
             
            require 'scripref'
         | 
| 7 7 | 
             
            require 'sqlbible'
         | 
| 8 8 |  | 
| 9 | 
            +
            default_bible_param = {}
         | 
| 10 | 
            +
            if b = Sqlbible.bible
         | 
| 11 | 
            +
              default_bible_param[:default] = b.to_s
         | 
| 12 | 
            +
            end
         | 
| 13 | 
            +
             | 
| 9 14 | 
             
            result = OptimistXL.options do
         | 
| 10 15 | 
             
              synopsis 'Usage: sqlbible <command> [options] [filename]?'
         | 
| 11 16 | 
             
              subcmd :convert, 'Convert a bible from OSIS-XML to Sqlbible format' do
         | 
| @@ -14,15 +19,15 @@ result = OptimistXL.options do | |
| 14 19 | 
             
              end
         | 
| 15 20 | 
             
              subcmd :list, 'Show a list of the names of the bibles in central directory'
         | 
| 16 21 | 
             
              subcmd :search, 'Search with regular expressions' do
         | 
| 17 | 
            -
                opt :bible, 'Name of the bible module filename of an .sqlbible file', type: String
         | 
| 22 | 
            +
                opt :bible, 'Name of the bible module filename of an .sqlbible file', type: String, **default_bible_param
         | 
| 18 23 | 
             
                opt :search, 'Regular expression to search (multiple allowed)', type: String, multi: true, required: true
         | 
| 19 | 
            -
                opt :lang, 'Language for parsing and formatting scripture references', type: String, permitted: %w(de en), default:  | 
| 24 | 
            +
                opt :lang, 'Language for parsing and formatting scripture references', type: String, permitted: %w(de en), default: Sqlbible.lang.to_s
         | 
| 20 25 | 
             
                opt :output, 'Output filename', type: String
         | 
| 21 26 | 
             
                opt :range, 'Search range, example: "John 1-10"', type: String
         | 
| 22 27 | 
             
              end
         | 
| 23 28 | 
             
              subcmd :text, 'Show text of references' do
         | 
| 24 | 
            -
                opt :bible, 'Name of the bible module filename of an .sqlbible file', type: String
         | 
| 25 | 
            -
                opt :lang, 'Language for parsing and formatting scripture references', type: String, permitted: %w(de en), default:  | 
| 29 | 
            +
                opt :bible, 'Name of the bible module filename of an .sqlbible file', type: String, **default_bible_param
         | 
| 30 | 
            +
                opt :lang, 'Language for parsing and formatting scripture references', type: String, permitted: %w(de en), default: Sqlbible.lang.to_s
         | 
| 26 31 | 
             
                opt :output, 'Output filename', type: String
         | 
| 27 32 | 
             
                opt :reference, 'Reference to show, example: "John 3:16; 10:27-30"', type: String, required: true
         | 
| 28 33 | 
             
              end
         | 
    
        data/lib/sqlbible/convert.rb
    CHANGED
    
    
    
        data/lib/sqlbible/version.rb
    CHANGED
    
    
    
        data/lib/sqlbible.rb
    CHANGED
    
    | @@ -11,7 +11,7 @@ class Sqlbible | |
| 11 11 |  | 
| 12 12 | 
             
              attr_reader :db_filename
         | 
| 13 13 |  | 
| 14 | 
            -
              def initialize db_name
         | 
| 14 | 
            +
              def initialize db_name=Sqlbible.bible
         | 
| 15 15 | 
             
                @db_filename = Sqlbible.resolve_db_filename(db_name, check_existence: true)
         | 
| 16 16 | 
             
                @db = SQLite3::Database.new(@db_filename)
         | 
| 17 17 | 
             
                @db.enable_load_extension(true)
         | 
| @@ -71,10 +71,12 @@ class Sqlbible | |
| 71 71 | 
             
              end
         | 
| 72 72 |  | 
| 73 73 | 
             
              @bibles_dir = File.join(Dir.home, '.sqlbible/bibles')
         | 
| 74 | 
            +
              @lang = :en
         | 
| 74 75 |  | 
| 75 76 | 
             
              class << self
         | 
| 76 77 |  | 
| 77 78 | 
             
                attr_reader :bibles_dir
         | 
| 79 | 
            +
                attr_accessor :bible, :lang
         | 
| 78 80 |  | 
| 79 81 | 
             
                # Get the database schema as string
         | 
| 80 82 | 
             
                def db_schema
         | 
| @@ -131,6 +133,11 @@ class Sqlbible | |
| 131 133 | 
             
                  fn
         | 
| 132 134 | 
             
                end
         | 
| 133 135 |  | 
| 136 | 
            +
                config_file = Dir[File.join(Dir.home, '.sqlbible/config{,.rb}')].first
         | 
| 137 | 
            +
                if config_file && !ENV['NOSQLBIBLECONFIG']
         | 
| 138 | 
            +
                  load config_file
         | 
| 139 | 
            +
                end
         | 
| 140 | 
            +
             | 
| 134 141 | 
             
              end
         | 
| 135 142 |  | 
| 136 143 | 
             
              private
         | 
| @@ -152,14 +159,33 @@ class Sqlbible | |
| 152 159 |  | 
| 153 160 | 
             
              def passage2rowids pass
         | 
| 154 161 | 
             
                rowid1 = select_rowid(pass.b1, pass.c1, pass.v1, :asc)
         | 
| 162 | 
            +
                unless rowid1
         | 
| 163 | 
            +
                  fail_book_chapter_verse pass.b1, pass.c1, pass.v1
         | 
| 164 | 
            +
                end
         | 
| 155 165 | 
             
                if rowid1 && pass.v2 == :f
         | 
| 156 166 | 
             
                  rowid2 = rowid1 + 1
         | 
| 157 167 | 
             
                  return [rowid1, rowid2]
         | 
| 158 168 | 
             
                end
         | 
| 159 169 | 
             
                rowid2 = select_rowid(pass.b2, pass.c2, pass.v2, :desc)
         | 
| 170 | 
            +
                unless rowid2
         | 
| 171 | 
            +
                  fail_book_chapter_verse pass.b2, pass.c2, pass.v2
         | 
| 172 | 
            +
                end
         | 
| 160 173 | 
             
                [rowid1, rowid2]
         | 
| 161 174 | 
             
              end
         | 
| 162 175 |  | 
| 176 | 
            +
              def fail_book_chapter_verse b, c, v
         | 
| 177 | 
            +
                parts = []
         | 
| 178 | 
            +
                parts << format('Passage for %s', b)
         | 
| 179 | 
            +
                if c
         | 
| 180 | 
            +
                  parts << format(' chapter %d', c.to_i)
         | 
| 181 | 
            +
                end
         | 
| 182 | 
            +
                if v
         | 
| 183 | 
            +
                  parts << format(' verse %d', v.to_i)
         | 
| 184 | 
            +
                end
         | 
| 185 | 
            +
                parts << ' does not exist'
         | 
| 186 | 
            +
                fail parts.join
         | 
| 187 | 
            +
              end
         | 
| 188 | 
            +
             | 
| 163 189 | 
             
              def select_rowid b, c, v, orderby
         | 
| 164 190 | 
             
                cond = []
         | 
| 165 191 | 
             
                args = []
         | 
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: sqlbible
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.4.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Jan Friedrich
         | 
| 8 8 | 
             
            bindir: bin
         | 
| 9 9 | 
             
            cert_chain: []
         | 
| 10 | 
            -
            date:  | 
| 10 | 
            +
            date: 1980-01-02 00:00:00.000000000 Z
         | 
| 11 11 | 
             
            dependencies:
         | 
| 12 12 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 13 13 | 
             
              name: did_you_mean
         |