Skip to content

Enable rules to accept Method object as prerequisites. #216

Merged
merged 1 commit into from Aug 2, 2013

2 participants

@avdi
avdi commented Aug 2, 2013

I have this rule:

rule /^#{highlights_dir}\/[[:xdigit:]]+\.html$/ =>
  [->(highlight_file){listing_for_highlight_file(highlight_file)}] do |t|
  dir = t.name.pathmap("%d")
  mkdir_p dir unless File.exist?(dir)
  sh *%W[pygmentize -o #{t.name} #{t.source}]
end

I would like to shorten it to this rule by using a Method object:

rule /^#{highlights_dir}\/[[:xdigit:]]+\.html$/ => [method(:listing_for_highlight_file)] do |t|
  dir = t.name.pathmap("%d")
  mkdir_p dir unless File.exist?(dir)
  sh *%W[pygmentize -o #{t.name} #{t.source}]
end

But this is not currently possible because rules expect executable prerequisites to be Proc instances.

@jimweirich jimweirich merged commit c35b5ab into jimweirich:master Aug 2, 2013

1 check passed

Details default The Travis CI build passed
@jimweirich
Owner

Good catch, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.