Skip to content

Commit

Permalink
Display if block instead of placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
chaadow committed Sep 14, 2024
1 parent 281fa8a commit 8ff221d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 16 additions & 0 deletions app/helpers/clockwork_web/home_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,21 @@ def friendly_time_part(time_part)
"**"
end
end

def friendly_extract_source_from_callable(callable, with_affixes: true)
source = RubyVM::AbstractSyntaxTree.of(callable, keep_script_lines: true).source
return '-' unless source

source.strip!
return source if with_affixes

source.tap do |source|
source.delete_prefix!('{')
source.delete_suffix!('}')

source.delete_prefix!('do')
source.delete_suffix!('end')
end
end
end
end
6 changes: 3 additions & 3 deletions app/views/clockwork_web/home/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<table>
<thead>
<tr>
<th>Job</th>
<th class="width-15">Job</th>
<th class="width-15">Period</th>
<th class="width-15">Last Run</th>
<th class="width-15">Action</th>
Expand All @@ -94,8 +94,8 @@
<% if at %>
at <%= friendly_time_part(at.instance_variable_get(:@hour)) %>:<%= friendly_time_part(at.instance_variable_get(:@min)) %>
<% end %>
<% if event.instance_variable_get(:@if) %>
if __
<% if if_lambda = event.instance_variable_get(:@if) %>
if: -> <%= friendly_extract_source_from_callable(if_lambda)%>
<% end %>
</td>
<td><%= last_run(@last_runs[event.job]) %></td>
Expand Down

0 comments on commit 8ff221d

Please sign in to comment.