Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor Author

@chaadow chaadow Sep 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(it's the same helper from #10 )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello

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