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

pulibrary / bibdata / 1dcebae2-3318-4e77-bc53-82276e293354

02 May 2025 04:45PM UTC coverage: 28.256% (-63.9%) from 92.189%
1dcebae2-3318-4e77-bc53-82276e293354

push

circleci

sandbergja
Add basic infrastructure for compiling rust code

* Add a rake compile task to compile
* Run the rake task in CI
* Run the rake task before rspec tests with the rust tag, to provide quick feedback on rust changes in TDD cycles

2 of 7 new or added lines in 2 files covered. (28.57%)

2467 existing lines in 97 files now uncovered.

1089 of 3854 relevant lines covered (28.26%)

0.29 hits per line

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

52.17
/app/services/location_maps_generator_service.rb
1
class LocationMapsGeneratorService
1✔
2
  def self.generate
1✔
UNCOV
3
    new.generate
×
4
  end
5

6
  def self.generate_from_templates
1✔
7
    new.generate_from_templates
1✔
8
  end
9

10
  attr_reader :base_path, :logger
1✔
11

12
  def initialize(base_path: Rails.root.join('marc_to_solr', 'translation_maps'), logger: Rails.logger)
1✔
13
    @base_path = base_path
1✔
14
    @logger = logger
1✔
15
  end
16

17
  def generate
1✔
UNCOV
18
    return unless holding_locations_table_exists?
×
19

UNCOV
20
    lib_display = {}
×
UNCOV
21
    locations_display = {}
×
UNCOV
22
    locations.each do |holding|
×
UNCOV
23
      holding_code = holding['code']
×
UNCOV
24
      lib_label = holding.library['label']
×
25
      # The locations.rb file needs to have the scsb locations as e.g "scsbnypl"=>"ReCAP".
26
      # This is why we are pulling the library label only for the scsb locations.
27
      # The rest of the holding_location_library records will take the holding['label'] value, even if it is blank.
28
      # This change will reflect on the holdings1_display["location"] value since it is using the locations.rb file for the location field.
29
      # see https://github.com/pulibrary/bibdata/blob/fe0a9b9495b7a8275f5a64463257c06537dd9c1e/marc_to_solr/lib/princeton_marc.rb#L653 for more info.
UNCOV
30
      holding_label = holding['label']
×
UNCOV
31
      lib_display[holding_code] = lib_label
×
UNCOV
32
      locations_display[holding_code] = holding_label
×
33
    end
UNCOV
34
    write_file('location_display.rb', lib_display)
×
UNCOV
35
    write_file('locations.rb', locations_display)
×
36
  end
37

38
  def generate_from_templates
1✔
39
    copy_template('locations.rb.tmpl')
1✔
40
    copy_template('location_display.rb.tmpl')
1✔
41
    copy_template('holding_library.rb.tmpl')
1✔
42
  end
43

44
  private
1✔
45

46
    def copy_template(template_name)
1✔
47
      output_file_name = template_name.gsub('.tmpl', '')
3✔
48
      output_file_path = file_path(output_file_name)
3✔
49
      template_file_path = file_path(template_name)
3✔
50
      FileUtils.cp(template_file_path, output_file_path)
3✔
51
    end
52

53
    def file_path(name)
1✔
54
      File.join(base_path, name)
6✔
55
    end
56

57
    def holding_locations_table_exists?
1✔
UNCOV
58
      if ActiveRecord::Base.connection.table_exists?('locations_holding_locations')
×
UNCOV
59
        true
×
60
      else
UNCOV
61
        logger.warn('Failed to seed the holding locations for Traject as the database table has not been created. Please invoke bundle exec rake db:create')
×
UNCOV
62
        false
×
63
      end
64
    rescue StandardError => e
UNCOV
65
      logger.warn("Failed to seed the holding locations for Traject due to a database error: #{e}.")
×
UNCOV
66
      false
×
67
    end
68

69
    def locations
1✔
UNCOV
70
      HoldingLocation.all
×
71
    end
72

73
    def write_file(file_name, values)
1✔
UNCOV
74
      path = file_path(file_name)
×
UNCOV
75
      File.open(path, 'w') do |file|
×
UNCOV
76
        PP.pp(values, file)
×
77
      end
78
    end
79
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