Module: Ore::Config

Defined in:
lib/ore/config.rb

Constant Summary collapse

HOME =

The users home directory

Gem.user_home
PATH =

Ore config directory

File.join(HOME,'.ore')
OPTIONS_FILE =

Default options file.

File.join(PATH,'options.yml')
TEMPLATES_DIR =

Custom Ore Templates directory

File.join(PATH,'templates')
DATA_DIR =

The data/ore directory for Ore

File.expand_path(File.join('..','..','data','ore'),File.dirname(__FILE__))
BUILTIN_TEMPLATES_DIR =

The data/ore/templates directory for Ore

File.join(DATA_DIR,'templates')

Class Method Summary collapse

Class Method Details

.builtin_templates {|path| ... } ⇒ Object

The builtin templates.

Yields:

  • (path)

    The given block will be passed every builtin template.

Yield Parameters:

  • path (String)

    The path of a Ore template directory.


75
76
77
78
79
80
81
# File 'lib/ore/config.rb', line 75

def self.builtin_templates
  if File.directory?(BUILTIN_TEMPLATES_DIR)
    Dir.glob("#{BUILTIN_TEMPLATES_DIR}/*") do |template|
      yield template if File.directory?(template)
    end
  end
end

.disable!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Disables access to user config.

Since:

  • 0.5.0


43
44
45
# File 'lib/ore/config.rb', line 43

def self.disable!
  @enabled = false
end

.enable!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Enables access to user config.

Since:

  • 0.5.0


32
33
34
# File 'lib/ore/config.rb', line 32

def self.enable!
  @enabled = true
end

.installed_templates {|path| ... } ⇒ Object

The installed templates.

Yields:

  • (path)

    The given block will be passed every installed template.

Yield Parameters:

  • path (String)

    The path of a Ore template directory.


92
93
94
95
96
97
98
99
100
# File 'lib/ore/config.rb', line 92

def self.installed_templates
  return unless @enabled

  if File.directory?(TEMPLATES_DIR)
    Dir.glob("#{TEMPLATES_DIR}/*") do |template|
      yield template if File.directory?(template)
    end
  end
end

.optionsOptions

Loads the default options from ~/.ore/options.yml.

Returns:

  • (Options)

    The loaded default options.

Raises:

  • (RuntimeError)

    The ~/.ore/options.yml did not contain a YAML encoded Hash.

Since:

  • 0.9.0


58
59
60
61
62
63
64
# File 'lib/ore/config.rb', line 58

def self.options
  @options ||= if @enabled && File.file?(OPTIONS_FILE)
                 Options.load(OPTIONS_FILE)
               else
                 Options.new
               end
end