Skip to content

Commit

Permalink
Fixing gem cache (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
kigster authored Dec 1, 2023
1 parent 3890b37 commit 2b6adf3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.1
3.2.2
8 changes: 4 additions & 4 deletions lib/db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ db.config.parse() {
db.config.connections-list() {
[[ -f ${bashmatic_db_config} ]] || return 2
ruby.handle-missing
gem.install colored2 >/dev/null
gem.install colorize >/dev/null
__yaml_source="${bashmatic_db_config}" ruby <<RUBY
require 'yaml'
require 'colored2'
h = YAML.load(File.read(ENV['__yaml_source']))
require 'colorize'
h = YAML.load(File.read(ENV['__yaml_source']), aliases: true)
h.each_pair do |name, params|
printf "%50s → %s@%s/%s\n",
name.bold.yellow,
name.yellow,
params['username'].blue,
params['host'].green,
params['database'].cyan
Expand Down
13 changes: 10 additions & 3 deletions lib/gem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,21 @@ gem.gemfile.version() {
# this ensures the cache is only at most 30 minutes old
gem.cache-installed() {
gem.configure-cache
if [[ ! -s "${LibGem__GemListCache}" || \
if [[ ! -f "${LibGem__GemListCache}" || ! -s "${LibGem__GemListCache}" || \
-z "$(find "${LibGem__GemListCache}" -mmin -30 2>/dev/null)" ]]; then
gem list > "${LibGem__GemListCache}" >/dev/null
mkdir -p $(dirname ${LibGem__GemListCache})
gem list > "${LibGem__GemListCache}" 2>/dev/null
fi

[[ -s "${LibGem__GemListCache}" ]]
}

gem.cache-list() {
cat "${LibGem__GemListCache}"
}

gem.clear-cache() {
rm -f "${LibGem__GemListCache}" >/dev/null
cp /dev/null "${LibGem__GemListCache}"
}

gem.cache-refresh() {
Expand Down

0 comments on commit 2b6adf3

Please sign in to comment.