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

pulibrary / tigerdata-app / 5205f704-d89d-4c43-8cfa-9e6783edc33a

29 Feb 2024 07:04PM UTC coverage: 60.206% (-29.9%) from 90.092%
5205f704-d89d-4c43-8cfa-9e6783edc33a

push

circleci

jrgriffiniii
Ensuring that the storage usage and storage capacity is retrieved for
Mediaflux Projects and rendered on the "contents" Project View

11 of 34 new or added lines in 4 files covered. (32.35%)

451 existing lines in 34 files now uncovered.

935 of 1553 relevant lines covered (60.21%)

9.47 hits per line

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

41.94
/app/models/mediaflux/http/get_metadata_request.rb
1
# frozen_string_literal: true
2
module Mediaflux
1✔
3
  module Http
1✔
4
    class GetMetadataRequest < Request
1✔
5
      attr_reader :id
1✔
6

7
      # Constructor
8
      # @param session_token [String] the API token for the authenticated session
9
      # @param id [Integer] Id of the Asset to return the metadata for
10
      def initialize(session_token:, id:)
1✔
11
        super(session_token: session_token)
2✔
UNCOV
12
        @id = id
×
13
      end
14

15
      # Specifies the Mediaflux service to use when getting asset metadata
16
      # @return [String]
17
      def self.service
1✔
UNCOV
18
        "asset.get"
×
19
      end
20

21
      # parse the returned XML into a hash about the asset that can be utilized
22
      def metadata
1✔
UNCOV
23
        xml = response_xml
×
UNCOV
24
        asset = xml.xpath("/response/reply/result/asset")
×
UNCOV
25
        metadata = parse(asset)
×
26

UNCOV
27
        if metadata[:collection]
×
UNCOV
28
          metadata[:total_file_count] = asset.xpath("./collection/accumulator/value/non-collections").text
×
29
        end
30

UNCOV
31
        parse_image(asset.xpath("./meta/mf-image"), metadata) # this does not do anything because mf-image is not a part of the meta xpath
×
32

UNCOV
33
        parse_note(asset.xpath("./meta/mf-note"), metadata) # this does not do anything because mf-note is not a part of the meta xpath
×
34

UNCOV
35
        metadata
×
36
      end
37

38
      private
1✔
39

40
        def build_http_request_body(name:)
1✔
UNCOV
41
          super do |xml|
×
UNCOV
42
            xml.args do
×
UNCOV
43
              xml.id id
×
44
            end
45
          end
46
        end
47

48
        def parse_note(note, metadata)
1✔
UNCOV
49
          if note.count > 0
×
50
            metadata[:mf_note] = note.text
×
51
          end
52
        end
53

54
        def parse_image(image, metadata)
1✔
UNCOV
55
          if image.count > 0
×
56
            metadata[:image_size] = image.xpath("./width").text + " X " + image.xpath("./height").text
×
57
          end
58
        end
59

60
        def parse(asset)
1✔
61
          {
UNCOV
62
            id: asset.xpath("./@id").text,
×
63
            creator: asset.xpath("./creator/user").text,
64
            description: asset.xpath("./description").text,
65
            collection: asset.xpath("./@collection")&.text == "true",
66
            path: asset.xpath("./path").text,
67
            type: asset.xpath("./type").text,
68
            size: asset.xpath("./content/size").text,
69
            size_human: asset.xpath("./content/size/@h").text,
70
            namespace: asset.xpath("./namespace").text,
71
            accumulators: asset.xpath("./collection/accumulator/value") # list of accumulator values in xml format. Can parse further through xpath
72
          }
73
        end
74
    end
75
  end
76
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