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

pulibrary / bibdata / b3c4a532-5da0-46f8-9c20-20018605a028

21 Mar 2025 08:11PM UTC coverage: 42.257% (-49.9%) from 92.185%
b3c4a532-5da0-46f8-9c20-20018605a028

push

circleci

sandbergja
Move various gems from the default Gemfile group to a more appropriate group

1599 of 3784 relevant lines covered (42.26%)

2.56 hits per line

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

35.29
/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
×
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)
×
25

26
    @service.get(key)
×
27
  end
28

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

39
  # Determine whether or not a value for a given key has been cached
40
  # @param key [String] the key
41
  # @return [TrueClass, FalseClass]
42
  def exist?(key)
1✔
43
    @service.cached?(key)
×
44
  end
45
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