Sha256: 74fd99a09f99b517bec0b6edd3c09e7fb20f350669c20cd3de21a91e2ab4386d

Contents?: true

Size: 665 Bytes

Versions: 2

Compression:

Stored size: 665 Bytes

Contents

module Hyde
  module Utils
    def same_file?(a, b)
      File.expand_path(a) == File.expand_path(b)
    end

    def matches_files?(needle, haystack)
      haystack.inject(false) do |a, match|
        a ||= same_file?(needle, match)
      end
    end

    def force_file_open(filepath)
      require 'fileutils'
      FileUtils.mkdir_p File.dirname(filepath)
      File.new filepath, 'w'
    end

    # Returns all helper classes under the Hyde::Helpers module.
    def get_helpers
      Hyde::Helpers.constants.inject([]) do |a, constant|
        mod = Hyde::Helpers.const_get(constant)
        a << mod  if mod.is_a? Module
        a
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hydeweb-0.0.4 lib/hyde/utils.rb
hydeweb-0.0.3.pre lib/hyde/utils.rb