Sha256: 524a3a7d7a212b7c804c84f13581c459d3a0ccc37470727ba66c354fa055e94c

Contents?: true

Size: 548 Bytes

Versions: 1

Compression:

Stored size: 548 Bytes

Contents

# encoding: UTF-8

require 'pathname'

module Spontaneous
  class Paths < ::Hash
    def initialize(root)
      @root = File.expand_path(root)
      super()
    end

    def add(category, *paths)
      self[category] = paths
    end

    def expanded(category)
      self[category].map do |path, glob|
        path = Pathname.new(@root) + path
        if path.exist?
          path = path.cleanpath
          path += glob if glob
          path.to_s
        else
          nil
        end
      end.compact
    end

  end # Paths
end # Spontaneous

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spontaneous-0.1.0.alpha1 lib/spontaneous/paths.rb