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

payrollhero / dispatch-rider / #2975

17 Aug 2022 10:39PM UTC coverage: 85.141%. Remained the same
#2975

push

web-flow
Merge pull request #80 from payrollhero/support-aws-sdk-1-2-3

Support aws-sdk v1 and v3 - Fix for Security Update Rails (CVE-2022-32224)

997 of 1171 relevant lines covered (85.14%)

5.02 hits per line

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

96.97
/lib/dispatch-rider/queue_services/file_system/queue.rb
1
# This is a queue implementation for the queue service based on file systems
2
module DispatchRider
1✔
3
  module QueueServices
1✔
4
    class FileSystem < Base
1✔
5
      class Queue
1✔
6
        def initialize(path)
1✔
7
          FileUtils.mkdir_p(path)
17✔
8
          @path = path
17✔
9
        end
10

11
        def add(item)
1✔
12
          name_base = "#{@path}/#{Time.now.to_f}"
11✔
13
          File.open("#{name_base}.inprogress", "w"){ |f| f.write(item) }
22✔
14
          FileUtils.mv("#{name_base}.inprogress", "#{name_base}.ready")
11✔
15
        end
16

17
        def pop
1✔
18
          file_path = next_item(10)
5✔
19
          return nil unless file_path
5✔
20
          file_path_inflight = file_path.gsub(/\.ready$/, '.inflight')
5✔
21
          FileUtils.mv(file_path, file_path_inflight)
5✔
22
          File.new(file_path_inflight)
5✔
23
        end
24

25
        def put_back(item)
1✔
26
          add(item)
1✔
27
          remove(item)
1✔
28
        end
29

30
        def remove(item)
1✔
31
          item.close
3✔
32
          File.unlink(item.path)
3✔
33
        end
34

35
        def size
1✔
36
          file_paths.size
8✔
37
        end
38

39
        private
1✔
40

41
        # Long polling next item fetcher
42
        # allows to sleep between checks for a new file and not run the main loop as much
43
        def next_item(timeout = 10.seconds)
44
          Timeout.timeout(timeout) do
1✔
45
            sleep 1 until file_paths.first
5✔
46
            file_paths.first
5✔
47
          end
5✔
48
        rescue Timeout::Error
49
          nil
50
        end
×
51

52
        def file_paths
53
          Dir["#{@path}/*.ready"]
1✔
54
        end
25✔
55
      end
56
    end
57
  end
58
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

© 2026 Coveralls, Inc