Sha256: 35fda20ca3c0229562b294be3ddaffe6a0b16bbcb63f2755ea2f4c3580da02ad

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

require 'pathname'

module Ore
  module Config
    # The users home directory
    @@home = File.expand_path(ENV['HOME'] || ENV['HOMEPATH'])

    # Ore config directory
    @@path = File.join(@@home,'.ore')

    # Default `ore` options file.
    @@options_file = File.join(@@path,'default.opts')

    # Custom Ore Templates directory
    @@templates_dir = File.join(@@path,'templates')

    # The `data/` directory for Ore
    @@data_dir = File.expand_path(File.join('..','..','data'),File.dirname(__FILE__))

    #
    # The builtin templates.
    #
    # @yield [path]
    #   The given block will be passed every builtin template.
    #
    # @yieldparam [String] path
    #   The path of a Ore template directory.
    #
    def Config.builtin_templates(&block)
      path = File.join(@@data_dir,'ore','templates')

      if File.directory?(path)
        Dir.glob("#{path}/*",&block)
      end
    end

    #
    # The installed templates.
    #
    # @yield [path]
    #   The given block will be passed every installed template.
    #
    # @yieldparam [String] path
    #   The path of a Ore template directory.
    #
    def Config.installed_templates(&block)
      if File.directory?(@@templates_dir)
        Dir.glob("#{@@templates_dir}/*",&block)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ore-0.1.3 lib/ore/config.rb
ore-0.1.2 lib/ore/config.rb