class Smeagol::Config
Server configuration is used to store the options for the Smeagol
server for serving sites.
Configuration can be loaded from configuration files located at `/etc/smaegol/config.yml` and `~/.config/smaegol/config.yml` or `~/.smaegol/config.yml`. Here is an example configuration:
Examples
--- port: 3000 auto_update: true cache_enabled: true repositories: - path: /path/to/wiki/repo cname: 'domain.name' origin: 'git@github.com:foo/foo.github.com.wiki.git' ref: master bare: false secret: 'pass123'
Constants
- CONFIG_HOME
Directory which contains user configuration.
Attributes
While running server, auto-update wiki every day.
Serve website via a given base path.
Use page cache to speed up page requests.
Use page cache to speed up page requests.
Use page cache to speed up page requests.
Serve website via a given base path.
Serve website via a given base path.
Port to use for server. Default is 4567.
Wiki
repository list.
Examples
repositories: - path: ~/wikis/banana-blog - cname: blog.bananas.org - secret: abc123
While running server, auto-update wiki every day.
While running server, auto-update wiki every day.
Public Class Methods
Public: Load Smeagol
server configuration.
Returns [Config]
# File lib/smeagol/config.rb, line 32 def self.load(file=nil) config = {} if file config.update(load_config(file)) else config.update(load_config('/etc/smeagol')) config.update(load_config("#{CONFIG_HOME}/smeagol", '~/.smeagol')) end new(config) end
Internal: Searches through the given directories looking for `settings.yml` file. Loads and returns the result of the first file found.
dirs - List of directories to search for config file. [Array<String>]
Returns configuration settings or empty Hash if none found. [Hash]
# File lib/smeagol/config.rb, line 52 def self.load_config(*dirs) dirs.each do |dir| file = File.join(dir, 'config.yml') file = File.expand_path(file) if File.exist?(file) return YAML.load_file(file) end end return {} end
Initialize new Config
instance.
# File lib/smeagol/config.rb, line 66 def initialize(settings={}) @port = 4567 @auto_update = false @cache_enabled = true @base_path = '' @repositories = [] assign(settings) end
Public Instance Methods
Deprecated: Ability to access config like hash.
# File lib/smeagol/config.rb, line 133 def [](name) instance_variable_get("@#{name}") end
Given a Hash of settings, assign via writer methods.
# File lib/smeagol/config.rb, line 79 def assign(settings={}) settings.each do |k,v| __send__("#{k}=", v) end end
Set list of repositories.
# File lib/smeagol/config.rb, line 119 def repositories=(repos) @repositories = ( repos.map do |repo| case repo when Repository then repo else Repository.new(repo) end end ) end
Set secret for all repositories.
# File lib/smeagol/config.rb, line 145 def secret=(secret) return if secret.nil? repositories.each do |repo| repo.secret = secret end end