Sha256: 451f2095e86c7d02880b80d73cddd8656efcaf5ad63cdf57582ced4b7a00265e

Contents?: true

Size: 547 Bytes

Versions: 2

Compression:

Stored size: 547 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

2 entries across 2 versions & 1 rubygems

Version Path
spontaneous-0.2.0.alpha2 lib/spontaneous/paths.rb
spontaneous-0.2.0.alpha1 lib/spontaneous/paths.rb