I wanted to change it dynamically so in the end I did this:
Filter = "#{filter}%"
Results = db.execute("SELECT fullpath FROM main WHERE #{Array.new(Query.length, 'basename LIKE ?').join(' AND ')} AND fullpath like ? ORDER BY accesstime DESC LIMIT ?;", Query, Filter, Limit).flatten
Here's the error I get when I run `gem install pathname` I've substituted my username with $USER
current directory: /Users/$USER/.gem/gems/pathname-0.1.0/ext/pathname
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20210903-70329-wn4b37.rb extconf.rb
checking for rb_file_s_birthtime()... no
creating Makefile
current directory: /Users/$USER/.gem/gems/pathname-0.1.0/ext/pathname
make "DESTDIR=" clean
current directory: /Users/$USER/.gem/gems/pathname-0.1.0/ext/pathname
make "DESTDIR="
compiling pathname.c
pathname.c:388:12: error: implicit declaration of function 'rb_funcallv_kw' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
return rb_funcallv_kw(rb_cFile, id_read, 1+n, args, RB_PASS_CALLED_KEYWORDS);
^
pathname.c:388:12: note: did you mean 'rb_funcallv'?
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:1870:7: note: 'rb_funcallv' declared here
VALUE rb_funcallv(VALUE, ID, int, const VALUE*);
^
pathname.c:388:57: error: use of undeclared identifier 'RB_PASS_CALLED_KEYWORDS'
return rb_funcallv_kw(rb_cFile, id_read, 1+n, args, RB_PASS_CALLED_KEYWORDS);
^
pathname.c:429:12: error: implicit declaration of function 'rb_funcallv_kw' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
return rb_funcallv_kw(rb_cFile, id_write, 1+n, args, RB_PASS_CALLED_KEYWORDS);
^
pathname.c:429:58: error: use of undeclared identifier 'RB_PASS_CALLED_KEYWORDS'
return rb_funcallv_kw(rb_cFile, id_write, 1+n, args, RB_PASS_CALLED_KEYWORDS);
^
pathname.c:450:12: error: implicit declaration of function 'rb_funcallv_kw' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
return rb_funcallv_kw(rb_cFile, id_binwrite, 1+n, args, RB_PASS_CALLED_KEYWORDS);
^
pathname.c:450:61: error: use of undeclared identifier 'RB_PASS_CALLED_KEYWORDS'
return rb_funcallv_kw(rb_cFile, id_binwrite, 1+n, args, RB_PASS_CALLED_KEYWORDS);
^
pathname.c:472:12: error: implicit declaration of function 'rb_funcallv_kw' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
return rb_funcallv_kw(rb_cFile, id_readlines, 1+n, args, RB_PASS_CALLED_KEYWORDS);
^
pathname.c:472:62: error: use of undeclared identifier 'RB_PASS_CALLED_KEYWORDS'
return rb_funcallv_kw(rb_cFile, id_readlines, 1+n, args, RB_PASS_CALLED_KEYWORDS);
^
pathname.c:680:16: error: implicit declaration of function 'rb_block_call_kw' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
return rb_block_call_kw(rb_cFile, id_open, 1+n, args, 0, 0, RB_PASS_CALLED_KEYWORDS);
^
pathname.c:680:16: note: did you mean 'rb_block_call'?
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:1951:7: note: 'rb_block_call' declared here
VALUE rb_block_call(VALUE,ID,int,const VALUE*,rb_block_call_func_t,VALUE);
^
pathname.c:680:69: error: use of undeclared identifier 'RB_PASS_CALLED_KEYWORDS'
return rb_block_call_kw(rb_cFile, id_open, 1+n, args, 0, 0, RB_PASS_CALLED_KEYWORDS);
^
pathname.c:683:16: error: implicit declaration of function 'rb_funcallv_kw' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
return rb_funcallv_kw(rb_cFile, id_open, 1+n, args, RB_PASS_CALLED_KEYWORDS);
^
pathname.c:683:61: error: use of undeclared identifier 'RB_PASS_CALLED_KEYWORDS'
return rb_funcallv_kw(rb_cFile, id_open, 1+n, args, RB_PASS_CALLED_KEYWORDS);
^
pathname.c:1099:16: error: implicit declaration of function 'rb_block_call_kw' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
return rb_block_call_kw(rb_cDir, id_glob, n, args, s_glob_i, klass, RB_PASS_CALLED_KEYWORDS);
^
pathname.c:1099:77: error: use of undeclared identifier 'RB_PASS_CALLED_KEYWORDS'
return rb_block_call_kw(rb_cDir, id_glob, n, args, s_glob_i, klass, RB_PASS_CALLED_KEYWORDS);
^
pathname.c:1104:15: error: implicit declaration of function 'rb_funcallv_kw' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ary = rb_funcallv_kw(rb_cDir, id_glob, n, args, RB_PASS_CALLED_KEYWORDS);
^
pathname.c:1104:57: error: use of undeclared identifier 'RB_PASS_CALLED_KEYWORDS'
ary = rb_funcallv_kw(rb_cDir, id_glob, n, args, RB_PASS_CALLED_KEYWORDS);
^
pathname.c:1147:16: error: implicit declaration of function 'rb_block_call_kw' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
return rb_block_call_kw(rb_cDir, id_glob, n, args, glob_i, self, RB_PASS_KEYWORDS);
^
pathname.c:1147:74: error: use of undeclared identifier 'RB_PASS_KEYWORDS'
return rb_block_call_kw(rb_cDir, id_glob, n, args, glob_i, self, RB_PASS_KEYWORDS);
^
pathname.c:1152:15: error: implicit declaration of function 'rb_funcallv_kw' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ary = rb_funcallv_kw(rb_cDir, id_glob, n, args, RB_PASS_KEYWORDS);
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [pathname.o] Error 1
make failed, exit code 2
It seems to me that pathname is a built-inclass
Worst case you can just do something like?
begin
require 'pathname'
rescue LoadError
puts "gem 'pathname' is not installed"
system("gem install pathname")
end