Detecting a source for the rule dynamically
Say, we have this list of articles in our blog: article1.md
, article2.md
, and article3.markdown
. When we get the value of task_name
, which is one among article1.html
, article2.html
, or article3.html
, there is no information on what the source is. If the value of task_name
is article1.html
, what is the source? Is it article1.md
or article1.mardown
? To understand this, we should define it dynamically. The possible solution is to go through articles
and see if there is a file named article1.md
or article1.mardown
there. This is a possibility with proc
too. Describing this is rather complicated.
The following example might give you some clarity:
require_relative 'blog_generator' articles = Rake::FileList.new('**/*.md', '**/*.markdown') do |files| files.exclude('~*') files.exclude(/^temp.+\//) files.exclude do |file| File.zero?(file) end end task :default...