rubyrakerake-taskrakefile

Change path in Rake file task prerequisites


I have a hardcoded file task

file 'feed.json' => 'lib/feed.rb'

How can I use match patterns

file '*.json' => 'lib/$1.rb' # Like this (this is pseudocode)

Solution

  • Could this do the trick?

    source_files = Rake::FileList.new("lib/*.md")
    task :default => :json
    task :json => source_files.ext(".rb")
    
    rule ".json" => ".rb" do |t|
      # here what you need to be done
    end
    
    

    To Wacht this video could help.