• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / bibdata / 97cbe92d-c54f-45de-a4c8-e506299fcc4d

21 Dec 2023 09:42PM UTC coverage: 90.834% (-0.5%) from 91.287%
97cbe92d-c54f-45de-a4c8-e506299fcc4d

Pull #2284

circleci

sandbergja
Upgrade old gem dependencies

Removes the rerun gem, since it is no longer used.  Also, remove some leftover files from the spring gem.
Pull Request #2284: Upgrade old gem dependencies

3409 of 3753 relevant lines covered (90.83%)

334.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.59
/marc_to_solr/lib/cache_adapter.rb
1
# Class which provides an API similar to that of ActiveSupport::Cache::Store Objects
2
# Currently this just supports the Lightly Gem (@see https://github.com/DannyBen/lightly)
3
class CacheAdapter
1✔
4
  # Clear a directory path used by a caching service
5
  # @param dir [String] the path to the directory used by the cache
6
  def self.clear(dir:)
1✔
7
    # Ensure that the directory is empty
8
    base_path = File.expand_path(dir)
×
9
    glob_path = File.join(base_path, '**', '*')
×
10
    paths = Dir.glob(glob_path)
×
11
    FileUtils.rm_r(paths)
×
12
  end
13

14
  # Constructor
15
  # @param service [Lightly] the caching service
16
  def initialize(service:)
1✔
17
    @service = service
3✔
18
  end
19

20
  # Fetch a value from the cache
21
  # @param key [String] key for the cache
22
  # @return [Object, nil] the value (or nil if no objects have been cached)
23
  def fetch(key)
1✔
24
    return nil unless @service.cached?(key)
31✔
25
    @service.get(key)
×
26
  end
27

28
  # Write to the cache
29
  # @param key [String] key for the cache
30
  # @return [Object] the object being cached for the key
31
  def write(key, value)
1✔
32
    @service.clear(key)
4✔
33
    @service.get(key) do
4✔
34
      value
4✔
35
    end
36
  end
37

38
  # Determine whether or not a value for a given key has been cached
39
  # @param key [String] the key
40
  # @return [TrueClass, FalseClass]
41
  def exist?(key)
1✔
42
    @service.cached?(key)
2✔
43
  end
44
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc