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)
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
11 changes: 11 additions & 0 deletions app/views/clockwork_web/home/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<tr>
<th>Job</th>
<th class="width-15">Period</th>
<th class="width-15">Implementation block</th>
<th class="width-15">Last Run</th>
<th class="width-15">Action</th>
</tr>
Expand All @@ -98,6 +99,16 @@
if __
<% end %>
</td>
<td>
<% if block = event.instance_variable_get(:@block) %>
<details>
<summary>Click to see implementation</summary>
{
<%= friendly_extract_source_from_callable(block, with_affixes: false) %>
}
</details>
<% end %>
</td>
<td><%= last_run(@last_runs[event.job]) %></td>
<td><%= button_to enabled ? "Disable" : "Enable", home_job_path(job: event.job, enable: !enabled), disabled: !ClockworkWeb.redis %></td>
</tr>
Expand Down