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

pulibrary / pdc_describe / 1aaf6302-d8cf-4943-bb96-5e86951c32a3

pending completion
1aaf6302-d8cf-4943-bb96-5e86951c32a3

Pull #1079

circleci

Bess Sadler
Nil safe doi gsub
Pull Request #1079: Nil safe collection title

2 of 2 new or added lines in 1 file covered. (100.0%)

1777 of 2063 relevant lines covered (86.14%)

100.37 hits per line

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

91.67
/app/models/readme.rb
1
# frozen_string_literal: true
2
class Readme
1✔
3
  attr_reader :work
1✔
4

5
  def initialize(work)
1✔
6
    @work = work
13✔
7
  end
8

9
  def attach(readme_file_param)
1✔
10
    return "A README file is required!" if readme_file_param.blank? && blank?
6✔
11
    return nil if readme_file_param.blank?
6✔
12
    remove_old_readme
4✔
13

14
    extension = File.extname(readme_file_param.original_filename)
4✔
15
    if work.s3_query_service.upload_file(io: readme_file_param.to_io, filename: "README#{extension}")
4✔
16
      nil
17
    else
18
      "An error uploading your README was encountered.  Please try again."
×
19
    end
20
  end
21

22
  def blank?
1✔
23
    s3_readme_idx.nil?
13✔
24
  end
25

26
  def file_name
1✔
27
    return nil if blank?
7✔
28
    file_names[s3_readme_idx]
2✔
29
  end
30

31
    private
1✔
32

33
      def s3_readme_idx
1✔
34
        @s3_readme_idx ||= file_names.find_index { |file_name| file_name.start_with?("README") }
21✔
35
      end
36

37
      def file_names
1✔
38
        @file_names ||= work.pre_curation_uploads_fast.map(&:filename_display)
15✔
39
      end
40

41
      def remove_old_readme
1✔
42
        return if blank?
4✔
43

44
        work.s3_query_service.delete_s3_object(work.pre_curation_uploads_fast[s3_readme_idx].key)
×
45
      end
46
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