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

payrollhero / dispatch-rider / #3015

02 Sep 2022 11:22PM UTC coverage: 0.409% (-84.7%) from 85.154%
#3015

push

web-flow
Layout/SpaceInsideStringInterpolation-20220901233630 (#89)

* :police_car: regenerate rubocop todo

* :police_car: Layout/SpaceInsideStringInterpolation

* :police_car: regenerate rubocop todo

Co-authored-by: Rubocop Challenger <rubocop@payrollhero.com>

0 of 1 new or added line in 1 file covered. (0.0%)

1529 existing lines in 63 files now uncovered.

7 of 1711 relevant lines covered (0.41%)

0.0 hits per line

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

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

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

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

UNCOV
25
        def put_back(item)
×
UNCOV
26
          add(item)
×
UNCOV
27
          remove(item)
×
UNCOV
28
        end
×
29

UNCOV
30
        def remove(item)
×
UNCOV
31
          item.close
×
UNCOV
32
          File.unlink(item.path)
×
UNCOV
33
        end
×
34

UNCOV
35
        def size
×
UNCOV
36
          file_paths.size
×
UNCOV
37
        end
×
38

UNCOV
39
        private
×
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
UNCOV
43
        def next_item(timeout = 10.seconds)
×
UNCOV
44
          Timeout.timeout(timeout) do
×
UNCOV
45
            sleep 1 until file_paths.first
×
UNCOV
46
            file_paths.first
×
UNCOV
47
          end
×
UNCOV
48
        rescue Timeout::Error
×
49
          nil
×
UNCOV
50
        end
×
51

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

© 2025 Coveralls, Inc