Skip to content

Commit 8ff221d

Browse files
committed
Display if block instead of placeholder
1 parent 281fa8a commit 8ff221d

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

app/helpers/clockwork_web/home_helper.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,21 @@ def friendly_time_part(time_part)
2525
"**"
2626
end
2727
end
28+
29+
def friendly_extract_source_from_callable(callable, with_affixes: true)
30+
source = RubyVM::AbstractSyntaxTree.of(callable, keep_script_lines: true).source
31+
return '-' unless source
32+
33+
source.strip!
34+
return source if with_affixes
35+
36+
source.tap do |source|
37+
source.delete_prefix!('{')
38+
source.delete_suffix!('}')
39+
40+
source.delete_prefix!('do')
41+
source.delete_suffix!('end')
42+
end
43+
end
2844
end
2945
end

app/views/clockwork_web/home/index.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<table>
7878
<thead>
7979
<tr>
80-
<th>Job</th>
80+
<th class="width-15">Job</th>
8181
<th class="width-15">Period</th>
8282
<th class="width-15">Last Run</th>
8383
<th class="width-15">Action</th>
@@ -94,8 +94,8 @@
9494
<% if at %>
9595
at <%= friendly_time_part(at.instance_variable_get(:@hour)) %>:<%= friendly_time_part(at.instance_variable_get(:@min)) %>
9696
<% end %>
97-
<% if event.instance_variable_get(:@if) %>
98-
if __
97+
<% if if_lambda = event.instance_variable_get(:@if) %>
98+
if: -> <%= friendly_extract_source_from_callable(if_lambda)%>
9999
<% end %>
100100
</td>
101101
<td><%= last_run(@last_runs[event.job]) %></td>

0 commit comments

Comments
 (0)