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

pulibrary / pdc_describe / 4e4e59fc-9df4-4838-9fd4-6c7ea33cdb7c

07 Apr 2025 06:36PM UTC coverage: 1.283% (-94.6%) from 95.862%
4e4e59fc-9df4-4838-9fd4-6c7ea33cdb7c

Pull #1994

circleci

hectorcorrea
Switched to use the autocomplete that we aleady use for ROR. Integrated it with the existing logic for creators
Pull Request #1994: Started adding auto complete to contributors

0 of 46 new or added lines in 2 files covered. (0.0%)

4806 existing lines in 74 files now uncovered.

65 of 5065 relevant lines covered (1.28%)

0.01 hits per line

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

0.0
/app/models/readme.rb
1
# frozen_string_literal: true
UNCOV
2
class Readme
×
UNCOV
3
  attr_reader :work, :current_user
×
4

UNCOV
5
  def initialize(work, current_user)
×
UNCOV
6
    @work = work
×
UNCOV
7
    @current_user = current_user
×
UNCOV
8
  end
×
9

UNCOV
10
  def attach(readme_file_param)
×
UNCOV
11
    return "A README file is required!" if readme_file_param.blank? && blank?
×
UNCOV
12
    return nil if readme_file_param.blank?
×
UNCOV
13
    remove_old_readme
×
14

UNCOV
15
    key = upload_readme(readme_file_param)
×
UNCOV
16
    if key
×
UNCOV
17
      @file_names = [readme_file_param.original_filename]
×
UNCOV
18
      @s3_readme_idx = 0
×
UNCOV
19
      log_changes
×
UNCOV
20
      nil
×
UNCOV
21
    else
×
UNCOV
22
      "An error uploading your README was encountered.  Please try again."
×
UNCOV
23
    end
×
UNCOV
24
  end
×
25

UNCOV
26
  def blank?
×
UNCOV
27
    s3_readme_idx.nil?
×
UNCOV
28
  end
×
29

UNCOV
30
  def file_name
×
UNCOV
31
    return nil if blank?
×
UNCOV
32
    file_names[s3_readme_idx]
×
UNCOV
33
  end
×
34

UNCOV
35
    private
×
36

UNCOV
37
      def s3_readme_idx
×
UNCOV
38
        @s3_readme_idx ||= file_names.find_index { |file_name| file_name.upcase.include?("README") }
×
UNCOV
39
      end
×
40

UNCOV
41
      def file_names
×
UNCOV
42
        @file_names ||= work.pre_curation_uploads.map(&:filename_display)
×
UNCOV
43
      end
×
44

UNCOV
45
      def remove_old_readme
×
UNCOV
46
        return if blank?
×
UNCOV
47
        work.s3_query_service.delete_s3_object(work.pre_curation_uploads[s3_readme_idx].key)
×
UNCOV
48
      end
×
49

UNCOV
50
      def upload_readme(readme_file_param)
×
UNCOV
51
        readme_name = readme_file_param.original_filename
×
UNCOV
52
        size = readme_file_param.size
×
UNCOV
53
        work.s3_query_service.upload_file(io: readme_file_param.to_io, filename: readme_name, size:)
×
UNCOV
54
      end
×
55

UNCOV
56
      def log_changes
×
UNCOV
57
        work.s3_query_service.client_s3_files(reload: true)
×
UNCOV
58
        work.reload_snapshots(user_id: current_user.id)
×
UNCOV
59
      end
×
UNCOV
60
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