Class: Steep::Server::TypeCheckController::Request
- Defined in:
- lib/steep/server/type_check_controller.rb
Instance Attribute Summary collapse
-
#checked_paths ⇒ Object
readonly
Returns the value of attribute checked_paths.
-
#code_paths ⇒ Object
readonly
Returns the value of attribute code_paths.
-
#guid ⇒ Object
readonly
Returns the value of attribute guid.
-
#library_paths ⇒ Object
readonly
Returns the value of attribute library_paths.
-
#needs_response ⇒ Object
Returns the value of attribute needs_response.
-
#priority_paths ⇒ Object
readonly
Returns the value of attribute priority_paths.
-
#report_progress ⇒ Object
readonly
Returns the value of attribute report_progress.
-
#signature_paths ⇒ Object
readonly
Returns the value of attribute signature_paths.
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
-
#work_done_progress ⇒ Object
readonly
Returns the value of attribute work_done_progress.
Instance Method Summary collapse
- #as_json(assignment:) ⇒ Object
- #assigned_uris(assignment, paths) ⇒ Object
- #checked(path, target) ⇒ Object
- #checking_path?(target_path) ⇒ Boolean
- #each_path(&block) ⇒ Object
- #each_target_path(&block) ⇒ Object
- #each_unchecked_code_target_path(&block) ⇒ Object
- #each_unchecked_library_target_path(&block) ⇒ Object
- #each_unchecked_path(&block) ⇒ Object
- #each_unchecked_signature_target_path(&block) ⇒ Object
- #each_unchecked_target_path(&block) ⇒ Object
- #empty? ⇒ Boolean
- #finished? ⇒ Boolean
-
#initialize(guid:, progress:) ⇒ Request
constructor
A new instance of Request.
- #merge!(request) ⇒ Object
- #percentage ⇒ Object
- #report_progress!(value = true) ⇒ Object
- #total ⇒ Object
- #uri(path) ⇒ Object
Constructor Details
#initialize(guid:, progress:) ⇒ Request
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/steep/server/type_check_controller.rb', line 16 def initialize(guid:, progress:) @guid = guid @library_paths = Set[] @signature_paths = Set[] @code_paths = Set[] @priority_paths = Set[] @checked_paths = Set[] @work_done_progress = progress @started_at = Time.now @needs_response = false @report_progress = false end |
Instance Attribute Details
#checked_paths ⇒ Object (readonly)
Returns the value of attribute checked_paths.
10 11 12 |
# File 'lib/steep/server/type_check_controller.rb', line 10 def checked_paths @checked_paths end |
#code_paths ⇒ Object (readonly)
Returns the value of attribute code_paths.
8 9 10 |
# File 'lib/steep/server/type_check_controller.rb', line 8 def code_paths @code_paths end |
#guid ⇒ Object (readonly)
Returns the value of attribute guid.
5 6 7 |
# File 'lib/steep/server/type_check_controller.rb', line 5 def guid @guid end |
#library_paths ⇒ Object (readonly)
Returns the value of attribute library_paths.
6 7 8 |
# File 'lib/steep/server/type_check_controller.rb', line 6 def library_paths @library_paths end |
#needs_response ⇒ Object
Returns the value of attribute needs_response.
13 14 15 |
# File 'lib/steep/server/type_check_controller.rb', line 13 def needs_response @needs_response end |
#priority_paths ⇒ Object (readonly)
Returns the value of attribute priority_paths.
9 10 11 |
# File 'lib/steep/server/type_check_controller.rb', line 9 def priority_paths @priority_paths end |
#report_progress ⇒ Object (readonly)
Returns the value of attribute report_progress.
14 15 16 |
# File 'lib/steep/server/type_check_controller.rb', line 14 def report_progress @report_progress end |
#signature_paths ⇒ Object (readonly)
Returns the value of attribute signature_paths.
7 8 9 |
# File 'lib/steep/server/type_check_controller.rb', line 7 def signature_paths @signature_paths end |
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at.
12 13 14 |
# File 'lib/steep/server/type_check_controller.rb', line 12 def started_at @started_at end |
#work_done_progress ⇒ Object (readonly)
Returns the value of attribute work_done_progress.
11 12 13 |
# File 'lib/steep/server/type_check_controller.rb', line 11 def work_done_progress @work_done_progress end |
Instance Method Details
#as_json(assignment:) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/steep/server/type_check_controller.rb', line 38 def as_json(assignment:) { guid: guid, library_uris: assigned_uris(assignment, library_paths), signature_uris: assigned_uris(assignment, signature_paths), code_uris: assigned_uris(assignment, code_paths), priority_uris: priority_paths.map {|path| uri(path).to_s } } end |
#assigned_uris(assignment, paths) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/steep/server/type_check_controller.rb', line 48 def assigned_uris(assignment, paths) paths.filter_map do |target_path| if assignment =~ target_path [target_path[0].to_s, uri(target_path[1]).to_s] end end end |
#checked(path, target) ⇒ Object
94 95 96 97 98 99 |
# File 'lib/steep/server/type_check_controller.rb', line 94 def checked(path, target) target_path = [target.name, path] #: target_and_path raise unless checking_path?(target_path) checked_paths << target_path end |
#checking_path?(target_path) ⇒ Boolean
88 89 90 91 92 |
# File 'lib/steep/server/type_check_controller.rb', line 88 def checking_path?(target_path) [library_paths, signature_paths, code_paths].any? do |paths| paths.include?(target_path) end end |
#each_path(&block) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/steep/server/type_check_controller.rb', line 68 def each_path(&block) if block each_target_path do |_target, path| yield path end else enum_for :each_path end end |
#each_target_path(&block) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/steep/server/type_check_controller.rb', line 78 def each_target_path(&block) if block library_paths.each(&block) signature_paths.each(&block) code_paths.each(&block) else enum_for :each_target_path end end |
#each_unchecked_code_target_path(&block) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/steep/server/type_check_controller.rb', line 127 def each_unchecked_code_target_path(&block) if block code_paths.each do |target_path| unless checked_paths.include?(target_path) yield target_path end end else enum_for :each_unchecked_code_target_path end end |
#each_unchecked_library_target_path(&block) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/steep/server/type_check_controller.rb', line 139 def each_unchecked_library_target_path(&block) if block library_paths.each do |target_path| unless checked_paths.include?(target_path) yield target_path end end else enum_for :each_unchecked_library_target_path end end |
#each_unchecked_path(&block) ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'lib/steep/server/type_check_controller.rb', line 105 def each_unchecked_path(&block) if block each_unchecked_target_path do |_target, path| yield path end else enum_for :each_unchecked_path end end |
#each_unchecked_signature_target_path(&block) ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/steep/server/type_check_controller.rb', line 151 def each_unchecked_signature_target_path(&block) if block signature_paths.each do |target_path| unless checked_paths.include?(target_path) yield target_path end end else enum_for :each_unchecked_signature_target_path end end |
#each_unchecked_target_path(&block) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/steep/server/type_check_controller.rb', line 115 def each_unchecked_target_path(&block) if block each_target_path do |target_path| unless checked_paths.include?(target_path) yield target_path end end else enum_for :each_unchecked_target_path end end |
#empty? ⇒ Boolean
60 61 62 |
# File 'lib/steep/server/type_check_controller.rb', line 60 def empty? total == 0 end |
#finished? ⇒ Boolean
101 102 103 |
# File 'lib/steep/server/type_check_controller.rb', line 101 def finished? total <= checked_paths.size end |
#merge!(request) ⇒ Object
163 164 165 166 167 168 169 |
# File 'lib/steep/server/type_check_controller.rb', line 163 def merge!(request) library_paths.merge(request.each_unchecked_library_target_path) signature_paths.merge(request.each_unchecked_signature_target_path) code_paths.merge(request.each_unchecked_code_target_path) self end |
#percentage ⇒ Object
64 65 66 |
# File 'lib/steep/server/type_check_controller.rb', line 64 def percentage checked_paths.size * 100 / total end |
#report_progress!(value = true) ⇒ Object
29 30 31 32 |
# File 'lib/steep/server/type_check_controller.rb', line 29 def report_progress!(value = true) @report_progress = value self end |
#total ⇒ Object
56 57 58 |
# File 'lib/steep/server/type_check_controller.rb', line 56 def total library_paths.size + signature_paths.size + code_paths.size end |
#uri(path) ⇒ Object
34 35 36 |
# File 'lib/steep/server/type_check_controller.rb', line 34 def uri(path) Steep::PathHelper.to_uri(path) end |