Sha256: 8c66e09112655f632ad34fe20e15f40a81033649d33fb86b8c27a3964c08a6c7

Contents?: true

Size: 515 Bytes

Versions: 3

Compression:

Stored size: 515 Bytes

Contents

class Path

  register_loader '.rb', '.ruby' do |path|
    ::Kernel.eval(path.read, TOPLEVEL_BINDING, path.to_s)
  end

  register_loader '.md' do |path|
    require 'yaml'
    content = path.read
    if content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
      (YAML::load($1) || {}).merge("content" => $')
    else
      {"content" => content}
    end
  end

  def to_url
    path = self.rm_ext
    path = path.dir if path.basename.to_s == 'index'
    path = path == Path('.') ? Path("") : path
    path.to_s
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
polygon-0.10.1 lib/polygon/core_ext/path.rb
polygon-0.10.0 lib/polygon/core_ext/path.rb
polygon-0.9.1 lib/polygon/core_ext/path.rb