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

pulibrary / pdc_discovery / 77aad3ef-33fa-40bd-8e08-da5fca8b87c0

17 Aug 2023 12:03PM UTC coverage: 87.863% (-8.7%) from 96.544%
77aad3ef-33fa-40bd-8e08-da5fca8b87c0

Pull #478

circleci

carolyncole
Switching to selenium to fix CI
Pull Request #478: Switching to selenium to fix CI

2085 of 2373 relevant lines covered (87.86%)

182.95 hits per line

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

67.65
/app/models/dataset_file.rb
1
# frozen_string_literal: true
2

3
class DatasetFile
1✔
4
  attr_accessor :name, :description, :format, :size, :mime_type, :sequence, :handle, :extension,
1✔
5
    :source, :download_url, :full_path
6

7
  def self.from_hash(data, data_source)
1✔
8
    if data_source == "pdc_describe"
4✔
9
      from_hash_describe(data)
×
10
    else
11
      from_hash_dataspace(data)
4✔
12
    end
13
  end
14

15
  def self.from_hash_dataspace(data)
1✔
16
    hash = data.with_indifferent_access
4✔
17
    file = DatasetFile.new
4✔
18
    file.source = "dataspace"
4✔
19
    file.full_path = hash[:name]
4✔
20
    file.name = hash[:name]
4✔
21
    file.extension = File.extname(file.name)
4✔
22
    file.extension = file.extension[1..] if file.extension != "." # drop the leading period
4✔
23
    file.description = hash[:description]
4✔
24
    file.mime_type = hash[:mime_type]
4✔
25
    file.size = hash[:size]
4✔
26
    file.sequence = (hash[:sequence] || "").to_i
4✔
27
    # Technically the handle is a property of the dataset item rather than the file (aka bitstream)
28
    # but we store it at the file level for convenience.
29
    file.handle = hash[:handle]
4✔
30
    file.download_url = "#{DatasetFile.download_root}/#{file.handle}/#{file.sequence}/#{file.name}"
4✔
31
    file
4✔
32
  end
33

34
  def self.from_hash_describe(data)
1✔
35
    hash = data.with_indifferent_access
×
36
    file = DatasetFile.new
×
37
    file.source = "pdc_describe"
×
38
    file.full_path = hash[:full_name]
×
39
    file.name = hash[:name]
×
40
    file.extension = File.extname(file.name)
×
41
    file.extension = file.extension[1..] if file.extension != "." # drop the leading period
×
42
    file.size = hash[:size]
×
43
    file.download_url = hash[:url]
×
44
    file
×
45
  end
46

47
  def self.download_root
1✔
48
    "#{Rails.configuration.pdc_discovery.dataspace_url}/bitstream"
4✔
49
  end
50
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