Sha256: a68122f5c06e5957120a8b9e46ee81df8a4811f2f140f0ed7a6c0480cecc9d7c

Contents?: true

Size: 706 Bytes

Versions: 6

Compression:

Stored size: 706 Bytes

Contents

# encoding: UTF-8

require 'pathname'

module Spontaneous
  class Paths < ::Hash
    def self.pad_revision_number(revision)
      revision.to_s.rjust(5, "0")
    end

    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(path)
        path = Pathname.new(@root) + path unless (path.absolute? && path.exist?)
        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

6 entries across 6 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta1 lib/spontaneous/paths.rb
spontaneous-0.2.0.alpha7 lib/spontaneous/paths.rb
spontaneous-0.2.0.alpha6 lib/spontaneous/paths.rb
spontaneous-0.2.0.alpha5 lib/spontaneous/paths.rb
spontaneous-0.2.0.alpha4 lib/spontaneous/paths.rb
spontaneous-0.2.0.alpha3 lib/spontaneous/paths.rb