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

pulibrary / pdc_discovery / 3d2f72c5-75d9-474f-b4d1-6f0ef5804913

pending completion
3d2f72c5-75d9-474f-b4d1-6f0ef5804913

Pull #447

circleci

hectorcorrea
Update fixture to reflect mult-value domain field
Pull Request #447: Indexing community, subcommunity, and domain from PDC Describe

7 of 7 new or added lines in 4 files covered. (100.0%)

2082 of 2238 relevant lines covered (93.03%)

144.26 hits per line

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

68.75
/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
6

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

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

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

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