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

pulibrary / tigerdata-app / 8c398bb9-338a-4e12-bef3-a01866f641e4

10 Nov 2025 08:58PM UTC coverage: 91.243% (+2.3%) from 88.974%
8c398bb9-338a-4e12-bef3-a01866f641e4

Pull #2177

circleci

web-flow
Merge branch 'main' into 2155-access-error
Pull Request #2177: Handles access error gracefully

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

394 existing lines in 25 files now uncovered.

2855 of 3129 relevant lines covered (91.24%)

554.96 hits per line

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

92.86
/app/models/mediaflux/iterator_request.rb
1
# frozen_string_literal: true
2
module Mediaflux
5✔
3
  class IteratorRequest < Request
5✔
4
    # Constructor
5
    # @param session_token [String] the API token for the authenticated session
6
    # @iterator [Int] The iterator returned by Mediaflux (via QueryRequest)
7
    def initialize(session_token:, iterator:, action: "get-values", size: nil)
5✔
8
      super(session_token: session_token)
48✔
9
      @iterator = iterator
48✔
10
      @size = size
48✔
11
      @action = action
48✔
12
    end
13

14
    # Specifies the Mediaflux service to use when running a query
15
    # @return [String]
16
    def self.service
5✔
17
      "asset.query.iterate"
96✔
18
    end
19

20
    # Returns hash with the files fetched in this iteration as well as a flag on whether we are
21
    # done iterating (complete=true) or if we need to keep iterating
22
    def result
5✔
23
      xml = response_xml
48✔
24
      {
25
        files: parse_files(xml),
48✔
26
        complete: xml.xpath("/response/reply/result/iterated/@complete").text == "true",
27
        count: xml.xpath("/response/reply/result/iterated").text.to_i
28
      }
29
    end
30

31
    private
5✔
32

33
      def build_http_request_body(name:)
5✔
34
        super do |xml|
96✔
35
          xml.args do
96✔
36
            xml.id @iterator
96✔
37
            xml.size @size if @size.present?
96✔
38
          end
39
        end
40
      end
41

42
      def parse_files(xml)
5✔
43
        case @action
48✔
44
        when "get-name"
45
          parse_get_name(xml)
1✔
46
        when "get-meta"
47
          parse_get_meta(xml)
1✔
48
        when "get-values"
49
          parse_get_values(xml)
46✔
50
        else
51
          raise "Cannot parse result. Unknow action: #{@action}."
×
52
        end
53
      end
54

55
      # Extracts file information when the request was made with the "action: get-name" parameter
56
      def parse_get_name(xml)
5✔
57
        files = []
1✔
58
        xml.xpath("/response/reply/result/name").each do |node|
1✔
59
          file = Mediaflux::Asset.new(
×
60
            id: node.xpath("./@id").text,
61
            name: node.text,
62
            collection: node.xpath("./@collection").text == "true"
63
          )
64
          files << file
×
65
        end
66
        files
1✔
67
      end
68

69
      # Extracts file information when the request was made with the "action: get-meta" parameter
70
      def parse_get_meta(xml)
5✔
71
        files = []
1✔
72
        xml.xpath("/response/reply/result/asset").each do |node|
1✔
73
          file = Mediaflux::Asset.new(
2✔
74
            id: node.xpath("./@id").text,
75
            name: node.xpath("./name").text,
76
            path: node.xpath("./path").text,
77
            collection: node.xpath("./@collection").text == "true",
78
            size: node.xpath("./content/@total-size").text.to_i,
79
            last_modified_mf: node.xpath("mtime").text
80
          )
81
          files << file
2✔
82
        end
83
        files
1✔
84
      end
85

86
      # Extracts file information when the request was made with the "action: get-values" parameter
87
      # Notice that this code is coupled with the fields defined in QueryRequest.
88
      def parse_get_values(xml)
5✔
89
        files = []
46✔
90
        xml.xpath("/response/reply/result/asset").each do |node|
46✔
UNCOV
91
          file = Mediaflux::Asset.new(
214✔
92
            id: node.xpath("./@id").text,
93
            name: node.xpath("./name").text,
94
            path: node.xpath("./path").text,
95
            collection: node.xpath("./collection").text == "true",
96
            size: node.xpath("./total-size").text.to_i,
97
            last_modified_mf: node.xpath("mtime").text
98
          )
UNCOV
99
          files << file
214✔
100
        end
101
        files
46✔
102
      end
103
  end
104
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