ruby_raider 4.0.1 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/e2e_tests.yml +3 -0
  3. data/README.md +58 -1
  4. data/RELEASE.md +25 -0
  5. data/lib/commands/schedule_commands.rb +84 -0
  6. data/lib/generators/templates/common/git_ignore.tt +1 -0
  7. data/lib/ruby_raider/runtime/retry_reset.rb +32 -0
  8. data/lib/ruby_raider/runtime/rspec.rb +1 -0
  9. data/lib/ruby_raider/runtime/show_browser.rb +53 -0
  10. data/lib/ruby_raider/runtime.rb +2 -0
  11. data/lib/ruby_raider.rb +31 -0
  12. data/lib/utilities/schedules/adapter.rb +22 -0
  13. data/lib/utilities/schedules/base.rb +27 -0
  14. data/lib/utilities/schedules/kind.rb +74 -0
  15. data/lib/utilities/schedules/legacy.rb +196 -0
  16. data/lib/utilities/schedules/legacy_stub.rb +62 -0
  17. data/lib/utilities/schedules/next_run.rb +61 -0
  18. data/lib/utilities/schedules/notifier.rb +76 -0
  19. data/lib/utilities/schedules/os/command_runner.rb +73 -0
  20. data/lib/utilities/schedules/os/cron.rb +147 -0
  21. data/lib/utilities/schedules/os/launchd.rb +182 -0
  22. data/lib/utilities/schedules/os/linux.rb +81 -0
  23. data/lib/utilities/schedules/os/systemd.rb +194 -0
  24. data/lib/utilities/schedules/os/task_scheduler.rb +195 -0
  25. data/lib/utilities/schedules/os_enumerator.rb +30 -0
  26. data/lib/utilities/schedules/project.rb +70 -0
  27. data/lib/utilities/schedules/rule.rb +162 -0
  28. data/lib/utilities/schedules/run_lock.rb +160 -0
  29. data/lib/utilities/schedules/run_log.rb +122 -0
  30. data/lib/utilities/schedules/run_report.rb +139 -0
  31. data/lib/utilities/schedules/run_wrapper.rb +216 -0
  32. data/lib/utilities/schedules/schedule.rb +89 -0
  33. data/lib/utilities/schedules/schedule_store.rb +53 -0
  34. data/lib/utilities/schedules/scheduler.rb +178 -0
  35. data/lib/utilities/schedules/scheduler_steps.rb +69 -0
  36. data/lib/utilities/schedules/selection.rb +133 -0
  37. data/lib/utilities/schedules/spawn.rb +68 -0
  38. data/lib/utilities/schedules/store.rb +139 -0
  39. data/lib/version +1 -1
  40. data/ruby_raider.gemspec +1 -0
  41. data/sig/commands/schedule_commands.rbs +12 -0
  42. data/sig/ruby_raider/runtime/retry_reset.rbs +7 -0
  43. data/sig/ruby_raider/runtime/show_browser.rbs +27 -0
  44. data/sig/ruby_raider.rbs +6 -0
  45. data/sig/utilities/schedules/adapter.rbs +5 -0
  46. data/sig/utilities/schedules/base.rbs +15 -0
  47. data/sig/utilities/schedules/kind.rbs +32 -0
  48. data/sig/utilities/schedules/legacy.rbs +45 -0
  49. data/sig/utilities/schedules/legacy_stub.rbs +15 -0
  50. data/sig/utilities/schedules/next_run.rbs +15 -0
  51. data/sig/utilities/schedules/notifier.rbs +29 -0
  52. data/sig/utilities/schedules/os/command_runner.rbs +27 -0
  53. data/sig/utilities/schedules/os/cron.rbs +34 -0
  54. data/sig/utilities/schedules/os/launchd.rbs +46 -0
  55. data/sig/utilities/schedules/os/linux.rbs +33 -0
  56. data/sig/utilities/schedules/os/systemd.rbs +44 -0
  57. data/sig/utilities/schedules/os/task_scheduler.rbs +56 -0
  58. data/sig/utilities/schedules/os_enumerator.rbs +12 -0
  59. data/sig/utilities/schedules/project.rbs +22 -0
  60. data/sig/utilities/schedules/rule.rbs +72 -0
  61. data/sig/utilities/schedules/run_lock.rbs +29 -0
  62. data/sig/utilities/schedules/run_log.rbs +33 -0
  63. data/sig/utilities/schedules/run_report.rbs +34 -0
  64. data/sig/utilities/schedules/run_wrapper.rbs +45 -0
  65. data/sig/utilities/schedules/schedule.rbs +27 -0
  66. data/sig/utilities/schedules/schedule_store.rbs +21 -0
  67. data/sig/utilities/schedules/scheduler.rbs +49 -0
  68. data/sig/utilities/schedules/scheduler_steps.rbs +22 -0
  69. data/sig/utilities/schedules/selection.rbs +36 -0
  70. data/sig/utilities/schedules/spawn.rbs +10 -0
  71. data/sig/utilities/schedules/store.rbs +39 -0
  72. data/spec/commands/schedule_commands_spec.rb +284 -0
  73. data/spec/integration/content/common_content_spec.rb +8 -2
  74. data/spec/integration/content/gemfile_content_spec.rb +2 -2
  75. data/spec/runtime/retry_reset_spec.rb +112 -0
  76. data/spec/runtime/show_browser_project_spec.rb +70 -0
  77. data/spec/runtime/show_browser_spec.rb +101 -0
  78. data/spec/utilities/schedules/kind_spec.rb +81 -0
  79. data/spec/utilities/schedules/legacy_spec.rb +433 -0
  80. data/spec/utilities/schedules/legacy_stub_spec.rb +144 -0
  81. data/spec/utilities/schedules/next_run_spec.rb +119 -0
  82. data/spec/utilities/schedules/notifier_spec.rb +120 -0
  83. data/spec/utilities/schedules/os/command_runner_spec.rb +55 -0
  84. data/spec/utilities/schedules/os/cron_spec.rb +292 -0
  85. data/spec/utilities/schedules/os/launchd_spec.rb +306 -0
  86. data/spec/utilities/schedules/os/linux_spec.rb +163 -0
  87. data/spec/utilities/schedules/os/list_ids_spec.rb +202 -0
  88. data/spec/utilities/schedules/os/systemd_spec.rb +333 -0
  89. data/spec/utilities/schedules/os/task_scheduler_spec.rb +511 -0
  90. data/spec/utilities/schedules/os_entry_spec.rb +54 -0
  91. data/spec/utilities/schedules/os_enumerator_spec.rb +57 -0
  92. data/spec/utilities/schedules/project_spec.rb +125 -0
  93. data/spec/utilities/schedules/run_lock_spec.rb +143 -0
  94. data/spec/utilities/schedules/run_log_spec.rb +83 -0
  95. data/spec/utilities/schedules/run_report_spec.rb +150 -0
  96. data/spec/utilities/schedules/run_wrapper_integration_spec.rb +166 -0
  97. data/spec/utilities/schedules/run_wrapper_spec.rb +430 -0
  98. data/spec/utilities/schedules/schedule_spec.rb +120 -0
  99. data/spec/utilities/schedules/schedule_store_spec.rb +151 -0
  100. data/spec/utilities/schedules/scheduler_launchd_spec.rb +77 -0
  101. data/spec/utilities/schedules/scheduler_spec.rb +445 -0
  102. data/spec/utilities/schedules/selection_spec.rb +176 -0
  103. data/spec/utilities/schedules/spawn_spec.rb +104 -0
  104. metadata +106 -2
@@ -0,0 +1,46 @@
1
+ module RubyRaider
2
+ module Schedules
3
+ module Os
4
+ class Launchd
5
+ LAUNCHCTL: String
6
+ PLUTIL: String
7
+ NOFOLLOW: Integer
8
+ ESCAPES: Hash[String, String]
9
+ HEADER: String
10
+
11
+ @kind: Kind
12
+ @runner: CommandRunner
13
+ @home: String
14
+ @uid: Integer
15
+
16
+ def initialize: (kind: Kind, ?runner: CommandRunner, ?home: String, ?uid: Integer) -> void
17
+ def label: () -> String
18
+ def plist: (_OsEntry schedule) -> String
19
+ def plist_path: (String os_id) -> String
20
+ def install: (_OsEntry schedule) -> true
21
+ def remove: (String os_id) -> bool
22
+ def present?: (String os_id) -> bool
23
+ def list_ids: (String prefix) -> Array[String]
24
+
25
+ private
26
+
27
+ def launchctl: (*String args) -> CommandRunner::Result
28
+ def domain: () -> String
29
+ def service: (String os_id) -> String
30
+ def unlink: (String path) -> bool
31
+ def agents_dir: () -> String
32
+ def checked_os_id: (untyped os_id) -> String
33
+ def escape: (untyped text) -> String
34
+ def string: (untyped text) -> Array[String]
35
+ def integer: (Integer number) -> Array[String]
36
+ def array: (Array[Array[String]] items) -> Array[String]
37
+ def dict: (Array[[String, Array[String]]] pairs) -> Array[String]
38
+ def indent: (Array[String] lines) -> Array[String]
39
+ def calendar: (_OsEntry schedule) -> Array[String]
40
+ def weekday: (String day) -> Integer
41
+ def discard: (String path) -> String
42
+ def write: (String path, String text) -> void
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,33 @@
1
+ module RubyRaider
2
+ module Schedules
3
+ module Os
4
+ class Linux
5
+ @kind: Kind
6
+ @primary: Systemd | Cron
7
+ @other: Cron?
8
+ @systemd: Systemd
9
+
10
+ def self.pick: (?CommandRunner runner, kind: Kind) -> Linux
11
+
12
+ def initialize: (kind: Kind, ?runner: CommandRunner, ?systemd: Systemd, ?cron: Cron) -> void
13
+ def label: () -> String
14
+ def missed_runs_note: () -> String?
15
+ def install: (_OsEntry schedule) -> true
16
+ def remove: (String os_id) -> bool
17
+ def present?: (String os_id) -> bool
18
+
19
+ def list_ids: (String prefix) -> Array[String]
20
+
21
+ private
22
+
23
+ def other_ids: (String prefix) -> Array[String]
24
+ def quietly: () { () -> Array[String] } -> Array[String]
25
+
26
+ def stranded?: (String os_id) -> bool
27
+ def refuse_stranded: (String os_id) -> void
28
+
29
+ def other_present?: (String os_id) -> bool
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,44 @@
1
+ module RubyRaider
2
+ module Schedules
3
+ module Os
4
+ class Systemd
5
+ SYSTEMCTL: String
6
+ NOFOLLOW: Integer
7
+ QUOTED: Hash[String, String]
8
+ CALENDAR: Hash[String, String]
9
+ UNSAFE_PATH: Regexp
10
+
11
+ @kind: Kind
12
+ @runner: CommandRunner
13
+ @home: String
14
+ @config_home: String?
15
+
16
+ def initialize: (kind: Kind, ?runner: CommandRunner, ?home: String, ?config_home: String?) -> void
17
+ def label: () -> String
18
+ def missed_runs_note: () -> nil
19
+ def service: (_OsEntry schedule) -> String
20
+ def timer: (_OsEntry schedule) -> String
21
+ def unit_path: (String os_id, String unit) -> String
22
+ def install: (_OsEntry schedule) -> true
23
+ def remove: (String os_id) -> bool
24
+ def present?: (String os_id) -> bool
25
+ def usable?: () -> bool
26
+ def list_ids: (String prefix) -> Array[String]
27
+ def unit_files?: (String os_id) -> bool
28
+
29
+ private
30
+
31
+ def systemctl: (*String args) -> CommandRunner::Result
32
+ def units_dir: () -> String
33
+ def checked_os_id: (untyped os_id) -> String
34
+ def checked_path: (String path) -> void
35
+ def quote: (String text) -> String
36
+ def specifiers: (String text) -> String
37
+ def unlink: (String path) -> bool
38
+ def discard: (String os_id) -> String
39
+ def write: (Hash[String, String] texts) -> void
40
+ def temp_file: (String path, String text) -> String
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,56 @@
1
+ module RubyRaider
2
+ module Schedules
3
+ module Os
4
+ class TaskScheduler
5
+ interface _Clock
6
+ def now: () -> Time
7
+ end
8
+
9
+ FOLDER: String
10
+ ESCAPES: Hash[String, String]
11
+ NAMESPACE: String
12
+ NEEDS_QUOTES: Regexp
13
+ GLOB: Regexp
14
+ EXPANDS: Regexp
15
+ DAY_NAMES: Array[String]
16
+ ROW: Regexp
17
+
18
+ @kind: Kind
19
+ @runner: CommandRunner
20
+ @clock: _Clock
21
+ @schtasks: String
22
+
23
+ def self.quote: (String arg) -> String
24
+ def self.glob_quote: (String arg) -> String
25
+ def self.odd_doubled: (String slashes) -> String
26
+ def self.join: (Array[String] args) -> String
27
+
28
+ def initialize: (kind: Kind, ?runner: CommandRunner, ?clock: _Clock, ?schtasks: String) -> void
29
+ def label: () -> String
30
+ def task_name: (untyped os_id) -> String
31
+ def task_xml: (_OsEntry schedule) -> String
32
+ def install: (_OsEntry schedule) -> true
33
+ def remove: (String os_id) -> bool
34
+ def present?: (String os_id) -> bool
35
+ def list_ids: (String prefix) -> Array[String]
36
+
37
+ private
38
+
39
+ def schtasks: (*String args) -> CommandRunner::Result
40
+ def list: () -> CommandRunner::Result
41
+ def tasks: () -> String
42
+ def listed?: (String text, String name) -> bool
43
+ def refuse_expansion: (_OsEntry schedule) -> void
44
+ def checked_os_id: (untyped os_id) -> String
45
+ def escape: (untyped value) -> String
46
+ def text: (String name, untyped value) -> Array[String]
47
+ def element: (String tag, Array[untyped] children) -> Array[String]
48
+ def indent: (Array[String] lines) -> Array[String]
49
+ def trigger: (_OsEntry schedule) -> Array[untyped]
50
+ def calendar: (_OsEntry schedule, String every) -> Array[String]
51
+ def settings: () -> Array[Array[String]]
52
+ def action: (_OsEntry schedule) -> Array[Array[String]]
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,12 @@
1
+ module RubyRaider
2
+ module Schedules
3
+ class OsEnumerator
4
+ @adapter: untyped
5
+ @kind: Kind
6
+ @prefix: String
7
+
8
+ def initialize: (untyped adapter, schedule_class: singleton(Rule), root: String) -> void
9
+ def names: () -> Array[String]
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,22 @@
1
+ module RubyRaider
2
+ module Schedules
3
+ class Project
4
+ DRIVER_HELPER: String
5
+ REQUIRES_RUNTIME: Regexp
6
+ MAX_HELPER_BYTES: Integer
7
+ NO_RUNTIME: String
8
+ OWN_VERSION: String
9
+ LOCKED_RAIDER: Regexp
10
+ MAX_LOCK_BYTES: Integer
11
+
12
+ attr_reader root: String
13
+
14
+ def initialize: (String path) -> void
15
+ def path: (String relative) -> String
16
+ def check_show_browser!: () -> void
17
+ def check_raider_version!: (?String own) -> void
18
+ def locked_raider_version: () -> (String | :no_lock | nil)
19
+ def runtime_driver?: () -> bool
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,72 @@
1
+ module RubyRaider
2
+ module Schedules
3
+ # What an OS scheduler adapter and NextRun read from a schedule, tests or 4.1
4
+ interface _OsEntry
5
+ def name: () -> String
6
+ def every: () -> String
7
+ def on: () -> String?
8
+ def os_id: () -> String
9
+ def ruby: () -> String
10
+ def hour: () -> Integer
11
+ def minute: () -> Integer
12
+ def days: () -> Array[String]
13
+ def argv: () -> Array[String]
14
+ def env: () -> Hash[String, String]
15
+ def working_directory: () -> String
16
+ def log_path: () -> String
17
+ def rule_text: () -> String
18
+ end
19
+
20
+ class Rule
21
+ EVERY: Array[String]
22
+ DAYS: Array[String]
23
+ DAYS_RULE: String
24
+ CLOCK: Regexp
25
+ MINUTE: Regexp
26
+ GEM_ENV: Array[String]
27
+ SYSTEM_PATH: Array[String]
28
+
29
+ attr_reader name: String
30
+ attr_reader every: String
31
+ attr_reader at: String
32
+ attr_reader on: String?
33
+ attr_reader retries: Integer
34
+ attr_reader notify: bool
35
+ attr_reader os_id: String
36
+ attr_reader ruby: String
37
+ attr_reader bundle: String
38
+ attr_reader gem_env: Hash[String, String]
39
+ attr_reader project_root: String
40
+ attr_reader created_at: String
41
+
42
+ def self.kind: () -> Kind
43
+ def self.os_id_for: (String project_root, String name) -> String
44
+ def self.os_id_prefix_for: (String project_root) -> String
45
+ def self.bundle_path: () -> String
46
+ def self.captured_gem_env: () -> Hash[String, String]
47
+
48
+ def kind: () -> Kind
49
+ def hour: () -> Integer
50
+ def minute: () -> Integer
51
+ def days: () -> Array[String]
52
+ def argv: () -> Array[String]
53
+ def env: () -> Hash[String, String]
54
+ def working_directory: () -> String
55
+ def log_path: () -> String
56
+ def rule_text: () -> String
57
+
58
+ private
59
+
60
+ def checked_every: (untyped every) -> String
61
+ def checked_at: (untyped at) -> String
62
+ def clock: (untyped at) -> String
63
+ def checked_on: (untyped on) -> String?
64
+ def checked_retries: (untyped retries) -> Integer
65
+ def checked_flag: (String label, untyped flag) -> bool
66
+ def checked_os_id: (untyped os_id) -> String
67
+ def checked_path: (String label, untyped path) -> String
68
+ def checked_gem_env: (untyped gem_env) -> Hash[String, String]
69
+ def checked_text: (String label, untyped text) -> String
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,29 @@
1
+ module RubyRaider
2
+ module Schedules
3
+ class RunLock
4
+ LOCK: String
5
+ RUNNING: String
6
+ MAX_RUNNING_BYTES: Integer
7
+
8
+ @project: Project
9
+ @lock: File?
10
+ @run_id: String?
11
+
12
+ def initialize: (Project project) -> void
13
+ def acquire: (name: String, run_id: String, started_at: String) -> bool
14
+ def release: () -> void
15
+
16
+ private
17
+
18
+ def lock: (String path) -> bool
19
+ def busy: () -> false
20
+ def inspect_running: (String running) -> Hash[Symbol, untyped]?
21
+ def remove_stale: (String running, Array[Integer]? id) -> bool
22
+ def restore: (String aside, String running) -> void
23
+ def live?: (Hash[String, untyped]? data) -> bool
24
+ def read_running: (String running) -> Hash[String, untyped]?
25
+ def parse_running: (File file) -> Hash[String, untyped]?
26
+ def write_running: (String running, String name, String run_id, String started_at) -> bool
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,33 @@
1
+ module RubyRaider
2
+ module Schedules
3
+ class RunLog
4
+ MAX_BYTES: Integer
5
+ MAX_LINES: Integer
6
+ FILE: String
7
+ LOCK: String
8
+ NOFOLLOW: Integer
9
+ NONBLOCK: Integer
10
+
11
+ @project: Project
12
+ @parts: Array[String]
13
+ @file: String
14
+ @lock: String
15
+
16
+ def self.private_dir: (Project project, *String parts) -> String
17
+
18
+ def initialize: (Project project, String name, ?dir: String) -> void
19
+ def lines: () -> Array[Hash[String, untyped]]
20
+ def last: () -> Hash[String, untyped]?
21
+ def last_result: () -> Hash[String, untyped]?
22
+ def find: (String run_id) -> Hash[String, untyped]?
23
+ def append: (Hash[String, untyped] line) -> void
24
+
25
+ private
26
+
27
+ def locked: [T] () { () -> T } -> T
28
+ def add: (String text) -> void
29
+ def replace: (String text) -> void
30
+ def tail: () -> String
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,34 @@
1
+ module RubyRaider
2
+ module Schedules
3
+ class RunReport
4
+ DIR: String
5
+ RUN: String
6
+ INDEX: String
7
+ ATTACHMENTS: String
8
+ SLACK: Integer
9
+ MAX_RUN_BYTES: Integer
10
+ MAX_ATTACHMENT_BYTES: Integer
11
+ MAX_ATTACHMENT_DEPTH: Integer
12
+ MAX_ATTACHMENT_FILES: Integer
13
+
14
+ @dir: String
15
+ @run_json: String
16
+
17
+ attr_reader counts: Hash[String, Integer]
18
+
19
+ def self.load: (Project project, since: Time) -> RunReport?
20
+ def self.read_file: (String path, Integer max) -> [String, Time]?
21
+ def self.fresh?: (untyped run, Time? mtime, Time since) -> bool
22
+
23
+ def initialize: (String dir, String run_json, Array[untyped] results) -> void
24
+ def copy_to: (String target) -> bool
25
+
26
+ private
27
+
28
+ def copy_attachments: (String temp) -> void
29
+ def copy_file: (String source, String target, Integer size) -> void
30
+ def regular_files: (String dir, ?String? prefix, ?Hash[String, Integer] found, ?Integer depth) -> Hash[String, Integer]?
31
+ def swap: (String temp, String target) -> void
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,45 @@
1
+ module RubyRaider
2
+ module Schedules
3
+ class RunWrapper
4
+ EXIT_CODES: Hash[String, Integer]
5
+ TRIGGERS: Array[String]
6
+ LOG_BYTES: Integer
7
+ MISSING: String
8
+ ZERO: Hash[String, Integer]
9
+ SPAWNER: ^(Hash[String, String?], Array[String], String) -> [Integer?, bool]
10
+
11
+ @project: Project
12
+ @out: IO | StringIO
13
+ @err: IO | StringIO
14
+ @spawner: untyped
15
+ @clock: ^() -> Time
16
+ @notifier: untyped
17
+ @lock: RunLock
18
+
19
+ def initialize: (Project project, ?out: IO | StringIO, ?err: IO | StringIO, ?spawner: untyped, ?clock: ^() -> Time, ?notifier: untyped) -> void
20
+ def run: (String name, ?trigger: String) -> Integer
21
+
22
+ private
23
+
24
+ def load: (String name) -> Schedule
25
+ def attempt: (Schedule schedule, Hash[String, String] record) -> Hash[Symbol, untyped]
26
+ def stopped: (Schedule schedule, Hash[String, String] record, Hash[Symbol, untyped] outcome) -> Hash[Symbol, untyped]
27
+ def spawn: (Schedule schedule) -> Hash[Symbol, untyped]
28
+ def status: (Integer? code, bool stopped, Hash[String, Integer]? counts) -> String
29
+ def argv: (Schedule schedule) -> Array[String]
30
+ def env: (Schedule schedule) -> Hash[String, String?]
31
+ def gem_env: (Schedule schedule) -> Hash[String, String?]
32
+ def copy_report: (Schedule schedule, RunReport? report) -> String?
33
+ def append: (Schedule schedule, Hash[String, String] record, Hash[Symbol, untyped] outcome) -> void
34
+ def finish: (Schedule schedule, Hash[String, String] record, Hash[Symbol, untyped] outcome) -> Integer
35
+ def append_quietly: (Schedule schedule, Hash[String, String] record, Hash[Symbol, untyped] outcome) -> void
36
+ def result_text: (Schedule schedule, Hash[String, String] record, Hash[Symbol, untyped] outcome) -> String
37
+ def failures: (Hash[String, Integer] counts) -> String
38
+ def tests: (Integer total) -> String
39
+ def notify: (Schedule schedule, Hash[String, String] record, Hash[Symbol, untyped] outcome) -> bool
40
+ def start_reason: (Schedule schedule, Hash[String, String] record, Hash[Symbol, untyped] outcome, long: bool) -> String
41
+ def rotate_log: (Schedule schedule) -> void
42
+ def stamp: () -> String
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,27 @@
1
+ module RubyRaider
2
+ module Schedules
3
+ class Schedule < Rule
4
+ KIND: Kind
5
+ KEYS: Array[String]
6
+ LINUX: Regexp
7
+ NO_BROWSER_ON_LINUX: String
8
+
9
+ attr_reader show_browser: bool
10
+ attr_reader selection: Selection
11
+
12
+ def self.kind: () -> Kind
13
+ def self.build: (project: Project, name: String, every: String, ?at: String?, ?on: String?, ?retries: untyped, ?notify: bool, ?show_browser: bool,
14
+ ?selection: Selection, ?now: Time, ?host_os: String) -> Schedule
15
+ def self.from_h: (untyped hash, String project_root, ?host_os: String) -> Schedule
16
+
17
+ def initialize: (name: untyped, every: untyped, at: untyped, on: untyped, retries: untyped, selection: untyped, os_id: untyped, ruby: untyped, bundle: untyped,
18
+ gem_env: untyped, project_root: untyped, created_at: untyped, ?notify: untyped, ?show_browser: untyped) -> void
19
+ def to_h: () -> Hash[String, untyped]
20
+
21
+ private
22
+
23
+ def checked_name: (untyped name) -> String
24
+ def checked_selection: (untyped selection) -> Selection
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,21 @@
1
+ module RubyRaider
2
+ module Schedules
3
+ class ScheduleStore < Store
4
+ DIR: String
5
+ GITIGNORE_LINE: String
6
+
7
+ def initialize: (Project project) -> void
8
+ def all: () -> Array[Schedule]
9
+ def find: (String name) -> Schedule?
10
+ def save: (Schedule schedule) -> Schedule
11
+ def delete: (String name) -> (Schedule | Store::Removed)?
12
+ def ignore_in_git: () -> bool
13
+
14
+ private
15
+
16
+ def gitignore: () -> String
17
+ def gitignore_text: (File file) -> String
18
+ def ignored?: (String content) -> bool
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,49 @@
1
+ module RubyRaider
2
+ module Schedules
3
+ class Scheduler
4
+ include SchedulerSteps
5
+
6
+ KIND: Kind
7
+ TIME: String
8
+ LIST_TIME: String
9
+ LAST: Array[String]
10
+ EMPTY: String
11
+ UNLISTED: String
12
+ RULE_KEYS: Array[String]
13
+
14
+ type row = { json: Hash[String, untyped], text: String }
15
+
16
+ @project: Project
17
+ @adapter: untyped
18
+ @store: ScheduleStore
19
+ @out: IO | StringIO
20
+ @err: IO | StringIO
21
+ @now: ^() -> Time
22
+ @host_os: String
23
+
24
+ def self.adapter: (?runner: Os::CommandRunner, ?host_os: String) -> (Os::Launchd | Os::TaskScheduler | Os::Linux)
25
+
26
+ def initialize: (Project project, ?adapter: untyped, ?store: ScheduleStore, ?out: IO | StringIO, ?err: IO | StringIO, ?now: ^() -> Time,
27
+ ?host_os: String) -> void
28
+ def add: (String name, every: String?, ?files: Array[String], ?tag: String?, ?at: String?, ?on: String?, ?retries: untyped, ?notify: bool,
29
+ ?show_browser: bool) -> void
30
+ def remove: (String name) -> void
31
+ def list: (?json: bool, ?notice: String?) -> void
32
+
33
+ private
34
+
35
+ attr_reader store: ScheduleStore
36
+
37
+ def adapter: () -> untyped
38
+ def checked_name: (untyped name) -> void
39
+ def schedule_dirs: (String name) -> void
40
+ def ignore_in_git: () -> void
41
+ def row: (Schedule schedule, Time now) -> row
42
+ def unlisted_rows: (Array[String] listed) -> Array[row]
43
+ def unlisted_names: () -> Array[String]
44
+ def os_state: (Schedule schedule) -> String
45
+ def rule: (Schedule schedule) -> String
46
+ def last_run: (String name) -> Hash[String, untyped]?
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,22 @@
1
+ module RubyRaider
2
+ module Schedules
3
+ module SchedulerSteps
4
+ RUBY_NOT_FOUND: String
5
+
6
+ private
7
+
8
+ # Given by the includer
9
+ def adapter: () -> untyped
10
+ def store: () -> Store
11
+
12
+ def save: (untyped schedule) -> untyped
13
+ def delete: (String name, String label) -> untyped
14
+ def unreadable_warning: (String name, String label) -> String
15
+ def ruby_found?: (untyped schedule) -> bool
16
+ def os_entry_state: (String os_id) -> String
17
+ def present?: (String os_id) -> bool
18
+ def missed_runs_note: () -> String?
19
+ def line: (String name, String rule, String next_run, Hash[String, untyped]? last, String state) -> String
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,36 @@
1
+ module RubyRaider
2
+ module Schedules
3
+ class Selection
4
+ KINDS: Array[String]
5
+ KEYS: Array[String]
6
+ TAG: Regexp
7
+ MAX_FILES: Integer
8
+ WINDOWS: Regexp
9
+ FILE_RULE: String
10
+ WINDOWS_RULE: String
11
+
12
+ attr_reader kind: String
13
+ attr_reader tag: String?
14
+ attr_reader files: Array[String]
15
+
16
+ def self.all: () -> Selection
17
+ def self.parse: (files: untyped, tag: untyped, root: String, ?host_os: String) -> Selection
18
+ def self.from_h: (untyped hash, root: String, ?host_os: String) -> Selection
19
+
20
+ def initialize: (kind: untyped, ?tag: untyped, ?files: untyped, ?host_os: String) -> void
21
+ def missing_file: (String root) -> String?
22
+ def check!: (String root) -> self
23
+ def to_h: () -> Hash[String, untyped]
24
+
25
+ private
26
+
27
+ def nothing: (String label, untyped value) -> nil
28
+ def checked_tag: (untyped tag) -> String
29
+ def checked_files: (untyped files, bool windows) -> Array[String]
30
+ def checked_file: (untyped file, bool windows) -> String
31
+ def spec_path?: (untyped file, bool windows) -> bool
32
+ def relative?: (String file, bool windows) -> bool
33
+ def present?: (String root, String file) -> bool
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,10 @@
1
+ module RubyRaider
2
+ module Schedules
3
+ module Spawn
4
+ def self.call: (Hash[String, String?] env, Array[String] argv, String chdir, ?forward_int: bool) -> [Integer?, bool]
5
+ def self.run: (Hash[String, String?] env, Array[String] argv, String chdir, Hash[Symbol, untyped] state, bool forward_int) -> Integer?
6
+ def self.stop: (Hash[Symbol, untyped] state, String signal, bool forward_int) -> void
7
+ def self.interrupt: (Hash[Symbol, untyped] state) -> void
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,39 @@
1
+ module RubyRaider
2
+ module Schedules
3
+ class Store
4
+ FILE: String
5
+ NOFOLLOW: Integer
6
+ NONBLOCK: Integer
7
+
8
+ class Removed
9
+ attr_reader name: String
10
+ attr_reader os_id: String
11
+
12
+ def initialize: (String name, String os_id) -> void
13
+ end
14
+
15
+ @project: Project
16
+ @schedule_class: untyped
17
+ @dir: String
18
+ @file: String
19
+
20
+ def initialize: (Project project, untyped schedule_class) -> void
21
+ def all: () -> Array[untyped]
22
+ def find: (String name) -> untyped
23
+ def save: (untyped schedule) -> untyped
24
+ def writable!: () -> nil
25
+ def delete: (String name) -> untyped
26
+
27
+ private
28
+
29
+ attr_reader project: Project
30
+ def from_entry: (untyped entry) -> untyped
31
+ def named?: (untyped entry, String name) -> bool
32
+ def read_entries: () -> Array[untyped]?
33
+ def writable_entries: () -> Array[untyped]
34
+ def read_text: () -> (String | false)?
35
+ def write: (Array[untyped] entries) -> void
36
+ def private_dir: () -> String
37
+ end
38
+ end
39
+ end