aoc_cli 0.2.2 → 1.0.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 (152) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.rubocop.yml +88 -0
  4. data/.ruby-version +1 -0
  5. data/CHANGELOG.md +4 -0
  6. data/Gemfile +8 -0
  7. data/Gemfile.lock +187 -0
  8. data/README.md +88 -282
  9. data/Rakefile +9 -2
  10. data/Steepfile +13 -0
  11. data/aoc_cli.gemspec +36 -26
  12. data/db/migrate/1_create_events.rb +14 -0
  13. data/db/migrate/2_create_puzzles.rb +21 -0
  14. data/db/migrate/3_create_stats.rb +19 -0
  15. data/db/migrate/4_create_attempts.rb +19 -0
  16. data/db/migrate/5_create_locations.rb +17 -0
  17. data/db/migrate/6_create_puzzle_dir_sync_logs.rb +18 -0
  18. data/exe/aoc +5 -0
  19. data/lib/aoc_cli/components/attempts_table.erb +5 -0
  20. data/lib/aoc_cli/components/attempts_table.rb +58 -0
  21. data/lib/aoc_cli/components/docs_component.erb +19 -0
  22. data/lib/aoc_cli/components/docs_component.rb +41 -0
  23. data/lib/aoc_cli/components/errors_component.erb +8 -0
  24. data/lib/aoc_cli/components/errors_component.rb +36 -0
  25. data/lib/aoc_cli/components/progress_table.erb +1 -0
  26. data/lib/aoc_cli/components/progress_table.rb +43 -0
  27. data/lib/aoc_cli/components/puzzle_sync_component.erb +2 -0
  28. data/lib/aoc_cli/components/puzzle_sync_component.rb +26 -0
  29. data/lib/aoc_cli/configurators/session_configurator.rb +7 -0
  30. data/lib/aoc_cli/controllers/application_controller.rb +27 -0
  31. data/lib/aoc_cli/controllers/concerns/error_concern.rb +17 -0
  32. data/lib/aoc_cli/controllers/concerns/location_concern.rb +79 -0
  33. data/lib/aoc_cli/controllers/default_controller.rb +9 -0
  34. data/lib/aoc_cli/controllers/event_controller.rb +35 -0
  35. data/lib/aoc_cli/controllers/help/event_controller.rb +11 -0
  36. data/lib/aoc_cli/controllers/help/puzzle_controller.rb +13 -0
  37. data/lib/aoc_cli/controllers/puzzle_controller.rb +39 -0
  38. data/lib/aoc_cli/core/attempt_parser.rb +69 -0
  39. data/lib/aoc_cli/core/processor.rb +32 -0
  40. data/lib/aoc_cli/core/repository.rb +74 -0
  41. data/lib/aoc_cli/core/request.rb +37 -0
  42. data/lib/aoc_cli/core/resource.rb +39 -0
  43. data/lib/aoc_cli/core/stats_parser.rb +43 -0
  44. data/lib/aoc_cli/helpers/table_generator.rb +64 -0
  45. data/lib/aoc_cli/helpers/view_helper.rb +35 -0
  46. data/lib/aoc_cli/models/attempt.rb +67 -0
  47. data/lib/aoc_cli/models/event.rb +9 -0
  48. data/lib/aoc_cli/models/location.rb +24 -0
  49. data/lib/aoc_cli/models/puzzle.rb +28 -0
  50. data/lib/aoc_cli/models/puzzle_dir_sync_log.rb +14 -0
  51. data/lib/aoc_cli/models/stats.rb +43 -0
  52. data/lib/aoc_cli/presenters/attempt_presenter.rb +29 -0
  53. data/lib/aoc_cli/presenters/puzzle_presenter.rb +29 -0
  54. data/lib/aoc_cli/presenters/stats_presenter.rb +32 -0
  55. data/lib/aoc_cli/processors/event_initialiser.rb +64 -0
  56. data/lib/aoc_cli/processors/puzzle_dir_synchroniser.rb +80 -0
  57. data/lib/aoc_cli/processors/puzzle_initialiser.rb +91 -0
  58. data/lib/aoc_cli/processors/puzzle_refresher.rb +27 -0
  59. data/lib/aoc_cli/processors/resource_attacher.rb +22 -0
  60. data/lib/aoc_cli/processors/solution_poster.rb +72 -0
  61. data/lib/aoc_cli/processors/stats_initialiser.rb +36 -0
  62. data/lib/aoc_cli/processors/stats_refresher.rb +23 -0
  63. data/lib/aoc_cli/validators/collection_type_validator.rb +57 -0
  64. data/lib/aoc_cli/validators/event_year_validator.rb +42 -0
  65. data/lib/aoc_cli/validators/included_validator.rb +21 -0
  66. data/lib/aoc_cli/validators/integer_validator.rb +32 -0
  67. data/lib/aoc_cli/validators/path_validator.rb +39 -0
  68. data/lib/aoc_cli/validators/type_validator.rb +54 -0
  69. data/lib/aoc_cli/version.rb +1 -1
  70. data/lib/aoc_cli/views/event/attach.erb +3 -0
  71. data/lib/aoc_cli/views/event/init.erb +3 -0
  72. data/lib/aoc_cli/views/help/event/attach.erb +32 -0
  73. data/lib/aoc_cli/views/help/event/init.erb +38 -0
  74. data/lib/aoc_cli/views/help/event/progress.erb +12 -0
  75. data/lib/aoc_cli/views/help/puzzle/attempts.erb +12 -0
  76. data/lib/aoc_cli/views/help/puzzle/init.erb +31 -0
  77. data/lib/aoc_cli/views/help/puzzle/solve.erb +33 -0
  78. data/lib/aoc_cli/views/help/puzzle/sync.erb +32 -0
  79. data/lib/aoc_cli/views/puzzle/init.erb +3 -0
  80. data/lib/aoc_cli/views/puzzle/solve.erb +10 -0
  81. data/lib/aoc_cli.rb +32 -16
  82. data/rbs_collection.lock.yaml +168 -0
  83. data/rbs_collection.yaml +28 -0
  84. data/sig/aoc_cli/components/attempts_table.rbs +29 -0
  85. data/sig/aoc_cli/components/docs_component.rbs +15 -0
  86. data/sig/aoc_cli/components/errors_component.rbs +19 -0
  87. data/sig/aoc_cli/components/progress_table.rbs +28 -0
  88. data/sig/aoc_cli/components/puzzle_sync_component.rbs +19 -0
  89. data/sig/aoc_cli/configurators/session_configurator.rbs +7 -0
  90. data/sig/aoc_cli/controllers/application_controller.rbs +12 -0
  91. data/sig/aoc_cli/controllers/concerns/error_concern.rbs +9 -0
  92. data/sig/aoc_cli/controllers/concerns/location_concern.rbs +35 -0
  93. data/sig/aoc_cli/controllers/default_controller.rbs +7 -0
  94. data/sig/aoc_cli/controllers/event_controller.rbs +18 -0
  95. data/sig/aoc_cli/controllers/help/event_controller.rbs +11 -0
  96. data/sig/aoc_cli/controllers/help/puzzle_controller.rbs +13 -0
  97. data/sig/aoc_cli/controllers/puzzle_controller.rbs +15 -0
  98. data/sig/aoc_cli/core/attempt_parser.rbs +41 -0
  99. data/sig/aoc_cli/core/processor.rbs +25 -0
  100. data/sig/aoc_cli/core/repository.rbs +25 -0
  101. data/sig/aoc_cli/core/request.rbs +29 -0
  102. data/sig/aoc_cli/core/resource.rbs +25 -0
  103. data/sig/aoc_cli/core/stats_parser.rbs +23 -0
  104. data/sig/aoc_cli/helpers/table_generator.rbs +36 -0
  105. data/sig/aoc_cli/helpers/view_helper.rbs +15 -0
  106. data/sig/aoc_cli/models/attempt.rbs +35 -0
  107. data/sig/aoc_cli/models/event.rbs +17 -0
  108. data/sig/aoc_cli/models/location.rbs +19 -0
  109. data/sig/aoc_cli/models/puzzle.rbs +28 -0
  110. data/sig/aoc_cli/models/puzzle_dir_sync_log.rbs +11 -0
  111. data/sig/aoc_cli/models/stats.rbs +53 -0
  112. data/sig/aoc_cli/presenters/attempt_presenter.rbs +13 -0
  113. data/sig/aoc_cli/presenters/puzzle_presenter.rbs +19 -0
  114. data/sig/aoc_cli/presenters/stats_presenter.rbs +19 -0
  115. data/sig/aoc_cli/processors/event_initialiser.rbs +26 -0
  116. data/sig/aoc_cli/processors/puzzle_dir_synchroniser.rbs +40 -0
  117. data/sig/aoc_cli/processors/puzzle_initialiser.rbs +37 -0
  118. data/sig/aoc_cli/processors/puzzle_refresher.rbs +21 -0
  119. data/sig/aoc_cli/processors/resource_attacher.rbs +16 -0
  120. data/sig/aoc_cli/processors/solution_poster.rbs +34 -0
  121. data/sig/aoc_cli/processors/stats_initialiser.rbs +15 -0
  122. data/sig/aoc_cli/processors/stats_refresher.rbs +19 -0
  123. data/sig/aoc_cli/validators/collection_type_validator.rbs +24 -0
  124. data/sig/aoc_cli/validators/event_year_validator.rbs +19 -0
  125. data/sig/aoc_cli/validators/included_validator.rbs +11 -0
  126. data/sig/aoc_cli/validators/integer_validator.rbs +15 -0
  127. data/sig/aoc_cli/validators/path_validator.rbs +17 -0
  128. data/sig/aoc_cli/validators/type_validator.rbs +22 -0
  129. data/sig/aoc_cli.rbs +6 -0
  130. data/sig/http.rbs +3 -0
  131. data/sig/kangaru.rbs +5 -0
  132. data/sig/nokogiri.rbs +3 -0
  133. data/sig/reverse_markdown.rbs +3 -0
  134. metadata +142 -34
  135. data/.gitignore +0 -5
  136. data/bin/aoc +0 -4
  137. data/bin/console +0 -15
  138. data/bin/setup +0 -7
  139. data/lib/aoc_cli/commands.rb +0 -232
  140. data/lib/aoc_cli/database.rb +0 -224
  141. data/lib/aoc_cli/day.rb +0 -124
  142. data/lib/aoc_cli/db/reddit.db +0 -0
  143. data/lib/aoc_cli/errors.rb +0 -275
  144. data/lib/aoc_cli/files.rb +0 -163
  145. data/lib/aoc_cli/help.rb +0 -77
  146. data/lib/aoc_cli/interface.rb +0 -81
  147. data/lib/aoc_cli/paths.rb +0 -101
  148. data/lib/aoc_cli/solve.rb +0 -104
  149. data/lib/aoc_cli/tables.rb +0 -138
  150. data/lib/aoc_cli/tools.rb +0 -120
  151. data/lib/aoc_cli/year.rb +0 -116
  152. data/sample/aoc.rc +0 -21
@@ -0,0 +1,12 @@
1
+ aoc event progress
2
+
3
+ Description:
4
+
5
+ Prints a table displaying progress (stars) for the current event.
6
+
7
+ This command can be run from both event and puzzle directories.
8
+
9
+ Usage:
10
+
11
+ aoc event progress
12
+
@@ -0,0 +1,12 @@
1
+ aoc puzzle attempts
2
+
3
+ Description:
4
+
5
+ This command can only be run from a puzzle directory (see puzzle init).
6
+
7
+ Shows posted solution attempts for the current puzzle.
8
+
9
+ Usage:
10
+
11
+ aoc puzzle attempts
12
+
@@ -0,0 +1,31 @@
1
+ aoc puzzle init
2
+
3
+ Description:
4
+
5
+ This command can only be run from an event directory (see event init).
6
+
7
+ Initialises the given day's puzzle for the current event. This fetches
8
+ the puzzle prompt and input from Advent of Code, creates a puzzle directory,
9
+ and writes the puzzle files to it.
10
+
11
+ Once initialised, the new puzzle directory contains two files:
12
+ * Markdown puzzle prompt (format "day_<day>.md")
13
+ * Plain text puzzle input (format "input")
14
+
15
+ These files can be restored at any time using puzzle sync.
16
+
17
+ The puzzle directory is a good place to write puzzle solution code and review
18
+ previous solution attempts. See puzzle solve and puzzle attempts respectively
19
+
20
+ Usage:
21
+
22
+ aoc puzzle init <day>
23
+
24
+ * <day>: Day of puzzle to initialise (1-25).
25
+
26
+ Examples:
27
+
28
+ aoc puzzle init 20 (in an event directory)
29
+
30
+ Initializes the day 20 puzzle and creates puzzle directory
31
+
@@ -0,0 +1,33 @@
1
+ aoc puzzle solve
2
+
3
+ Description:
4
+
5
+ This command can only be run from a puzzle directory (see puzzle init).
6
+
7
+ Posts the given answer to Advent of Code for the current puzzle. The response
8
+ will have one of three possible states:
9
+
10
+ 1. Correct
11
+ 2. Incorrect
12
+ 3. Rate-limited
13
+
14
+ If the attempt was correct, relevant stats are updated and the puzzle files
15
+ are refreshed to include any new puzzle information.
16
+
17
+ If the attempt was incorrect or rate-limited, the required wait time will be
18
+ indicated to the nearest minute.
19
+
20
+ Previous attempt data can be reviewed with the puzzle attempts command.
21
+
22
+ Usage:
23
+
24
+ aoc puzzle solve --answer=<answer>
25
+
26
+ * <answer>: The puzzle solution to attempt
27
+
28
+ Examples:
29
+
30
+ aoc puzzle solve --answer abcdef (in a puzzle directory)
31
+
32
+ Initializes the day 20 puzzle and creates puzzle directory
33
+
@@ -0,0 +1,32 @@
1
+ aoc puzzle sync
2
+
3
+ Description:
4
+
5
+ This command can only be run from a puzzle directory (see puzzle init).
6
+
7
+ Restores puzzle dir files (puzzle and input) to their cached state.
8
+
9
+ Puzzle data is cached when puzzles are initialised and correctly solved in
10
+ order to decrease load on Advent of Code and increase performance. However
11
+ there may be situations where the cache is outdated: for example if puzzles
12
+ have been solved from the browser.
13
+
14
+ To fetch and write the latest puzzle data, pass the --skip-cache flag.
15
+
16
+ Usage:
17
+
18
+ aoc puzzle sync [--skip-cache]
19
+
20
+ * <skip-cache>: Whether to ignore puzzle file cache (default false)
21
+
22
+ Examples:
23
+
24
+ aoc puzzle sync (in a puzzle directory)
25
+
26
+ Restores (writes or updates) puzzle files to cached state.
27
+
28
+
29
+ aoc puzzle sync --skip-cache (in a puzzle directory)
30
+
31
+ Puzzle data is refreshed before writing the puzzle files.
32
+
@@ -0,0 +1,3 @@
1
+ <%= success_tag %>: puzzle initialised
2
+ event <%= @puzzle.year %>
3
+ day <%= @puzzle.day %>
@@ -0,0 +1,10 @@
1
+ <% if @attempt.rate_limited? -%>
2
+ <%= "Rate limited".yellow.bold %>: please wait <%= @attempt.wait_time %> minutes.
3
+ <% elsif @attempt.incorrect? -%>
4
+ <%= "Incorrect".red.bold %>: please wait <%= @attempt.wait_time %> minutes.
5
+ <% unless @attempt.hint.nil? -%>
6
+ Hint: your answer is <%= @attempt.presenter.hint.downcase %>
7
+ <% end -%>
8
+ <% elsif @attempt.correct? -%>
9
+ <%= "Correct".green.bold %>: part <%= @attempt.level %> complete.
10
+ <% end -%>
data/lib/aoc_cli.rb CHANGED
@@ -1,19 +1,35 @@
1
- require 'colorize'
2
-
3
- require_relative 'aoc_cli/errors'
4
- require_relative 'aoc_cli/interface'
5
- require_relative "aoc_cli/version"
6
- require_relative 'aoc_cli/files'
7
- require_relative 'aoc_cli/commands'
8
- require_relative 'aoc_cli/tools'
9
- require_relative 'aoc_cli/year'
10
- require_relative 'aoc_cli/day'
11
- require_relative 'aoc_cli/solve'
12
- require_relative 'aoc_cli/database'
13
- require_relative 'aoc_cli/paths'
14
- require_relative 'aoc_cli/tables'
1
+ require "fileutils"
2
+ require "forwardable"
3
+ require "http"
4
+ require "kangaru"
5
+ require "nokogiri"
6
+ require "reverse_markdown"
7
+ require "terminal-table"
15
8
 
16
9
  module AocCli
17
- Metafile = AocCli::Files::Metafile
18
- Prefs = AocCli::Files::Config::Prefs
10
+ extend Kangaru::Initialiser
11
+
12
+ config_path File.expand_path("~/.config/aoc_cli/config.yml")
13
+
14
+ config_path "spec/aoc.yml", env: :test
15
+
16
+ configure do |config|
17
+ config.database.adaptor = :sqlite
18
+ config.database.path = File.expand_path("~/.local/share/aoc/aoc.sqlite3")
19
+ config.database.migration_path = "db/migrate"
20
+ end
21
+
22
+ configure env: :test do |config|
23
+ config.database.path = "db/test.sqlite3"
24
+ end
25
+
26
+ apply_config!
27
+
28
+ Sequel::Model.plugin(:polymorphic)
29
+ Sequel::Model.plugin(:enum)
30
+
31
+ Terminal::Table::Style.defaults = {
32
+ border: :unicode,
33
+ alignment: :center
34
+ }
19
35
  end
@@ -0,0 +1,168 @@
1
+ ---
2
+ path: ".gems"
3
+ gems:
4
+ - name: activesupport
5
+ version: '7.0'
6
+ source:
7
+ type: git
8
+ name: ruby/gem_rbs_collection
9
+ revision: 20e6e0f0685139dbd29df50e03367e222aa5d1b8
10
+ remote: https://github.com/ruby/gem_rbs_collection.git
11
+ repo_dir: gems
12
+ - name: addressable
13
+ version: '2.8'
14
+ source:
15
+ type: git
16
+ name: ruby/gem_rbs_collection
17
+ revision: 20e6e0f0685139dbd29df50e03367e222aa5d1b8
18
+ remote: https://github.com/ruby/gem_rbs_collection.git
19
+ repo_dir: gems
20
+ - name: base64
21
+ version: '0'
22
+ source:
23
+ type: stdlib
24
+ - name: bigdecimal
25
+ version: '0'
26
+ source:
27
+ type: stdlib
28
+ - name: cgi
29
+ version: '0'
30
+ source:
31
+ type: stdlib
32
+ - name: colorize
33
+ version: '1.1'
34
+ source:
35
+ type: git
36
+ name: apexatoll/gem_signatures
37
+ revision: aad38d45071ab6a1389c58052d06604f0ef71591
38
+ remote: https://github.com/apexatoll/gem_signatures
39
+ repo_dir: sig
40
+ - name: concurrent-ruby
41
+ version: '1.1'
42
+ source:
43
+ type: git
44
+ name: ruby/gem_rbs_collection
45
+ revision: 20e6e0f0685139dbd29df50e03367e222aa5d1b8
46
+ remote: https://github.com/ruby/gem_rbs_collection.git
47
+ repo_dir: gems
48
+ - name: connection_pool
49
+ version: '2.4'
50
+ source:
51
+ type: git
52
+ name: ruby/gem_rbs_collection
53
+ revision: 20e6e0f0685139dbd29df50e03367e222aa5d1b8
54
+ remote: https://github.com/ruby/gem_rbs_collection.git
55
+ repo_dir: gems
56
+ - name: date
57
+ version: '0'
58
+ source:
59
+ type: stdlib
60
+ - name: erb
61
+ version: '0'
62
+ source:
63
+ type: stdlib
64
+ - name: fileutils
65
+ version: '0'
66
+ source:
67
+ type: stdlib
68
+ - name: forwardable
69
+ version: '0'
70
+ source:
71
+ type: stdlib
72
+ - name: http
73
+ version: '5.1'
74
+ source:
75
+ type: git
76
+ name: ruby/gem_rbs_collection
77
+ revision: 20e6e0f0685139dbd29df50e03367e222aa5d1b8
78
+ remote: https://github.com/ruby/gem_rbs_collection.git
79
+ repo_dir: gems
80
+ - name: i18n
81
+ version: '1.10'
82
+ source:
83
+ type: git
84
+ name: ruby/gem_rbs_collection
85
+ revision: 20e6e0f0685139dbd29df50e03367e222aa5d1b8
86
+ remote: https://github.com/ruby/gem_rbs_collection.git
87
+ repo_dir: gems
88
+ - name: kangaru
89
+ version: '0.2'
90
+ source:
91
+ type: git
92
+ name: apexatoll/gem_signatures
93
+ revision: aad38d45071ab6a1389c58052d06604f0ef71591
94
+ remote: https://github.com/apexatoll/gem_signatures
95
+ repo_dir: sig
96
+ - name: logger
97
+ version: '0'
98
+ source:
99
+ type: stdlib
100
+ - name: minitest
101
+ version: '0'
102
+ source:
103
+ type: stdlib
104
+ - name: monitor
105
+ version: '0'
106
+ source:
107
+ type: stdlib
108
+ - name: mutex_m
109
+ version: '0'
110
+ source:
111
+ type: stdlib
112
+ - name: nokogiri
113
+ version: '1.11'
114
+ source:
115
+ type: git
116
+ name: ruby/gem_rbs_collection
117
+ revision: 20e6e0f0685139dbd29df50e03367e222aa5d1b8
118
+ remote: https://github.com/ruby/gem_rbs_collection.git
119
+ repo_dir: gems
120
+ - name: pathname
121
+ version: '0'
122
+ source:
123
+ type: stdlib
124
+ - name: securerandom
125
+ version: '0'
126
+ source:
127
+ type: stdlib
128
+ - name: sequel
129
+ version: '5.72'
130
+ source:
131
+ type: git
132
+ name: apexatoll/gem_signatures
133
+ revision: aad38d45071ab6a1389c58052d06604f0ef71591
134
+ remote: https://github.com/apexatoll/gem_signatures
135
+ repo_dir: sig
136
+ - name: singleton
137
+ version: '0'
138
+ source:
139
+ type: stdlib
140
+ - name: tempfile
141
+ version: '0'
142
+ source:
143
+ type: stdlib
144
+ - name: terminal-table
145
+ version: '3.0'
146
+ source:
147
+ type: git
148
+ name: apexatoll/gem_signatures
149
+ revision: aad38d45071ab6a1389c58052d06604f0ef71591
150
+ remote: https://github.com/apexatoll/gem_signatures
151
+ repo_dir: sig
152
+ - name: time
153
+ version: '0'
154
+ source:
155
+ type: stdlib
156
+ - name: timeout
157
+ version: '0'
158
+ source:
159
+ type: stdlib
160
+ - name: zeitwerk
161
+ version: '2.6'
162
+ source:
163
+ type: git
164
+ name: apexatoll/gem_signatures
165
+ revision: aad38d45071ab6a1389c58052d06604f0ef71591
166
+ remote: https://github.com/apexatoll/gem_signatures
167
+ repo_dir: sig
168
+ gemfile_lock_path: Gemfile.lock
@@ -0,0 +1,28 @@
1
+ sources:
2
+ - type: git
3
+ name: ruby/gem_rbs_collection
4
+ remote: https://github.com/ruby/gem_rbs_collection.git
5
+ revision: main
6
+ repo_dir: gems
7
+
8
+ - type: git
9
+ name: apexatoll/gem_signatures
10
+ remote: https://github.com/apexatoll/gem_signatures
11
+ revision: main
12
+ repo_dir: sig
13
+
14
+ path: .gems
15
+
16
+ gems:
17
+ - name: date
18
+ - name: fileutils
19
+ - name: forwardable
20
+ - name: pathname
21
+ - name: rake
22
+ ignore: true
23
+ - name: rspec
24
+ ignore: true
25
+ - name: rubocop
26
+ ignore: true
27
+ - name: steep
28
+ ignore: true
@@ -0,0 +1,29 @@
1
+ module AocCli
2
+ module Components
3
+ class AttemptsTable < Kangaru::Component
4
+ attr_reader puzzle: Puzzle
5
+
6
+ def initialize: (puzzle: Puzzle) -> void
7
+
8
+ def title: -> String
9
+
10
+ def headings: -> Array[String]
11
+
12
+ def rows: -> Array[Array[untyped] | Symbol]
13
+
14
+ private
15
+
16
+ attr_reader level_one_rows: Array[Array[untyped]]
17
+
18
+ attr_reader level_two_rows: Array[Array[untyped]]
19
+
20
+ def separator: -> Symbol?
21
+
22
+ def level_one_attempts: -> Array[Attempt]
23
+
24
+ def level_two_attempts: -> Array[Attempt]
25
+
26
+ def rows_for: (Array[Attempt]) -> Array[Array[untyped]]
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,15 @@
1
+ module AocCli
2
+ module Components
3
+ class DocsComponent < Kangaru::Component
4
+ include Helpers::ViewHelper
5
+
6
+ ENDPOINTS: Hash[Symbol, untyped]
7
+
8
+ def endpoints: -> Hash[Symbol, untyped]
9
+
10
+ def title: -> String
11
+
12
+ def commands_table: (Hash[Symbol, String], ?indent: Integer) -> String
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ module AocCli
2
+ module Components
3
+ class ErrorsComponent < Kangaru::Component
4
+ attr_reader messages: Array[String]
5
+
6
+ def initialize: (*String) -> void
7
+
8
+ def render: -> void
9
+
10
+ def self.from_model: (untyped) -> ErrorsComponent
11
+
12
+ private
13
+
14
+ def render?: -> bool
15
+
16
+ def title: -> String
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,28 @@
1
+ module AocCli
2
+ module Components
3
+ class ProgressTable < Kangaru::Component
4
+ attr_reader event: Event
5
+
6
+ def initialize: (event: Event) -> void
7
+
8
+ private
9
+
10
+ type row = [String, String]
11
+
12
+ TITLE: String
13
+ HEADINGS: Array[String]
14
+ PROGRESS: String
15
+ TOTAL: String
16
+
17
+ def title: -> String
18
+
19
+ def headings: -> Array[String]
20
+
21
+ def rows: -> Array[row | Symbol]
22
+
23
+ def progress_rows: -> Array[row]
24
+
25
+ def total_row: -> row
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,19 @@
1
+ module AocCli
2
+ module Components
3
+ class PuzzleSyncComponent < Kangaru::Component
4
+ extend Forwardable
5
+
6
+ include Helpers::ViewHelper
7
+
8
+ attr_reader log: PuzzleDirSyncLog
9
+
10
+ def puzzle: -> Puzzle
11
+
12
+ def initialize: (log: PuzzleDirSyncLog) -> void
13
+
14
+ private
15
+
16
+ def status_rows: -> Array[[untyped, untyped]]
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ module AocCli
2
+ module Configurators
3
+ class SessionConfigurator < Kangaru::Configurator
4
+ attr_accessor token: String
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ module AocCli
2
+ class ApplicationController < Kangaru::Controller
3
+ include Concerns::ErrorConcern
4
+ include Concerns::LocationConcern
5
+
6
+ include Helpers::ViewHelper
7
+
8
+ private
9
+
10
+ def handle_help_param!: -> void
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ module AocCli
2
+ module Concerns
3
+ module ErrorConcern
4
+ def render_error!: (String) -> false
5
+
6
+ def render_model_errors!: (untyped) -> false
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,35 @@
1
+ module AocCli
2
+ module Concerns
3
+ module LocationConcern
4
+ include ErrorConcern
5
+
6
+ def current_path: -> String
7
+
8
+ def current_location: -> Location?
9
+
10
+ def current_event: -> Event?
11
+
12
+ def current_puzzle: -> Puzzle?
13
+
14
+ def ensure_in_event_dir!: -> bool
15
+
16
+ def ensure_in_puzzle_dir!: -> bool
17
+
18
+ def ensure_in_aoc_dir!: -> bool
19
+
20
+ def ensure_not_in_aoc_dir!: -> bool
21
+
22
+ private
23
+
24
+ ERRORS: Hash[Symbol, String]
25
+
26
+ def current_resource: -> untyped
27
+
28
+ def in_event_dir?: -> bool
29
+
30
+ def in_puzzle_dir?: -> bool
31
+
32
+ def in_aoc_dir?: -> bool
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,7 @@
1
+ module AocCli
2
+ class DefaultController < ApplicationController
3
+ def default: -> void
4
+
5
+ alias help default
6
+ end
7
+ end
@@ -0,0 +1,18 @@
1
+ module AocCli
2
+ class EventController < ApplicationController
3
+ @event: Event
4
+
5
+ def init: -> void
6
+
7
+ @source: String
8
+ @target: String
9
+
10
+ def attach: -> void
11
+
12
+ def progress: -> void
13
+
14
+ private
15
+
16
+ attr_reader queried_event: Event?
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ module AocCli
2
+ module Help
3
+ class EventController < ApplicationController
4
+ def init: -> void
5
+
6
+ def attach: -> void
7
+
8
+ def progress: -> void
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ module AocCli
2
+ module Help
3
+ class PuzzleController < ApplicationController
4
+ def init: -> void
5
+
6
+ def solve: -> void
7
+
8
+ def sync: -> void
9
+
10
+ def attempts: -> void
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ module AocCli
2
+ class PuzzleController < ApplicationController
3
+ @puzzle: Puzzle
4
+ @attempt: Attempt
5
+ @sync_log: PuzzleDirSyncLog
6
+
7
+ def init: -> void
8
+
9
+ def solve: -> void
10
+
11
+ def sync: -> void
12
+
13
+ def attempts: -> void
14
+ end
15
+ end
@@ -0,0 +1,41 @@
1
+ module AocCli
2
+ module Core
3
+ class AttemptParser
4
+ attr_reader response: String
5
+
6
+ def initialize: (String) -> void
7
+
8
+ def to_h: -> Hash[Symbol, untyped]
9
+
10
+ private
11
+
12
+ module Prefixes
13
+ CORRECT: Regexp
14
+ INCORRECT: Regexp
15
+ RATE_LIMITED: Regexp
16
+ WRONG_LEVEL: Regexp
17
+ end
18
+
19
+ module Hints
20
+ TOO_LOW: Regexp
21
+ TOO_HIGH: Regexp
22
+ end
23
+
24
+ module WaitTimes
25
+ ONE_MINUTE: Regexp
26
+ INCORRECT_FORMAT: Regexp
27
+ RATE_LIMITED_FORMAT: Regexp
28
+ end
29
+
30
+ def status: -> Symbol
31
+
32
+ def hint: -> Symbol?
33
+
34
+ def wait_time: -> Integer?
35
+
36
+ def scan_incorrect_wait_time!: -> Integer?
37
+
38
+ def scan_rated_limited_wait_time!: -> Integer?
39
+ end
40
+ end
41
+ end