Maybe this can be good enough:

```ruby
if File.file?(path) && path.sub(source, '') !~ /\/_/
  classes = [
    Post,
    Draft,
    Page,
    StaticFile
  ]

  files << classes.select { |k| k.is_item_path?(path) }.first.new(self, path)
elsif path =~ /#{config['layouts']}/
   ext = File.extname(path)
   name = File.basename(path, ext)
   layouts[name] = Layout.new(self, path)
end  

class Item
  # old code ommited

  def is_item_path?(path)
    false
  end
end

class Post
  # old code ommited

  def is_item_path?(path)
    path =~ /_posts/
  end
end

class Draft
  # old code ommited

  def is_item_path?(path)
    path =~ /_drafts/ && show_drafts # I don't know if show_drafts is accessible from here, but you can make it be
  end
end

class Page
  # old code ommited

  def is_item_path?(path)
    has_yaml_header?(path)
  end
end

class StaticFile
  # old code ommited

  def is_item_path?(path)
    true
  end
end
```