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

pulibrary / bibdata / 2ee2c4fc-5ef0-4806-b86e-01bf70aa67a0

24 Dec 2024 04:55PM UTC coverage: 91.859% (-0.04%) from 91.902%
2ee2c4fc-5ef0-4806-b86e-01bf70aa67a0

Pull #2569

circleci

christinach
Generate new .rubocop_todo.yml
rubocop fix
Pull Request #2569: Rubocop gems

335 of 378 new or added lines in 57 files covered. (88.62%)

2 existing lines in 2 files now uncovered.

3385 of 3685 relevant lines covered (91.86%)

377.92 hits per line

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

84.21
/marc_to_solr/lib/cache_manager.rb
1
require 'active_support/core_ext/module'
1✔
2

3
# Class for handling instances of caching objects
4
class CacheManager
1✔
5
  # Build and set the current cache to the new instance
6
  # @param cache [ActiveSupport::Cache::Store, CacheAdapter] Low-level cache
7
  # @param logger [IO] logger for handling output during HTTP service requests
8
  def self.initialize(figgy_cache:, logger: STDOUT)
1✔
9
    @current_cache = new(figgy_cache:, logger:)
3✔
10
  end
11

12
  # Retrieve the last initialized cache manager
13
  # Raises an error if a cache hasn't been initialized
14
  # @return [CacheManager]
15
  def self.current
1✔
16
    @current_cache
3✔
17
  rescue StandardError
18
    raise NotImplementedError, 'Please initialize a cache using CacheManager.initialize(cache: Rails.cache, logger: Rails.logger)'
×
19
  end
20

21
  # Clear a cache directory by removing its contents
22
  # @param dir [String] path to the cache directory
23
  def self.clear(dir:)
1✔
24
    return unless Dir.exist? dir
×
25

UNCOV
26
    FileUtils.rm_r Dir.glob("#{dir}/*")
×
27
  end
28

29
  # Constructor
30
  # @param cache [ActiveSupport::Cache::Store] Rails low-level cache
31
  # @param logger [IO] logger for handling output during HTTP service requests
32
  def initialize(figgy_cache:, logger: STDOUT)
1✔
33
    @figgy_cache = figgy_cache
3✔
34
    @logger = logger
3✔
35

36
    # Seed the caches
37
    seed!
3✔
38
  end
39

40
  # Retrieve the stored (or seed) the cache for the ARK's in Figgy
41
  # @return [CacheMap]
42
  def figgy_ark_cache
1✔
43
    @figgy_ark_cache ||= CacheMap.new(cache: @figgy_cache, host: 'figgy.princeton.edu', logger: @logger)
23✔
44
  end
45

46
  # Retrieve the stored (or seed) the cache for the ARK's in all repositories
47
  # @return [CompositeCacheMap]
48
  def ark_cache
1✔
49
    @cache_maps ||= CompositeCacheMap.new(cache_maps: [figgy_ark_cache])
17✔
50
  end
51

52
  # Ensure the the CacheMap and CompositeCacheMap instances are memoized
53
  delegate :seed!, to: :figgy_ark_cache
1✔
54
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