diff --git a/app/helpers/clockwork_web/home_helper.rb b/app/helpers/clockwork_web/home_helper.rb index 3b82c7f..464955e 100644 --- a/app/helpers/clockwork_web/home_helper.rb +++ b/app/helpers/clockwork_web/home_helper.rb @@ -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 diff --git a/app/views/clockwork_web/home/index.html.erb b/app/views/clockwork_web/home/index.html.erb index d9cc85b..b91c42d 100644 --- a/app/views/clockwork_web/home/index.html.erb +++ b/app/views/clockwork_web/home/index.html.erb @@ -79,6 +79,7 @@