class SyncReadme::Config

Constants

DEFAULT_CONFIG_FILE
NO_CONFIGURATION_ERROR

Public Class Methods

default(config_file = DEFAULT_CONFIG_FILE) click to toggle source
# File lib/sync_readme/config.rb, line 11
def self.default(config_file = DEFAULT_CONFIG_FILE)
  raise NO_CONFIGURATION_ERROR unless File.exists?(config_file)
  default = YAML.load_file(config_file)['default']
  unless default
    profiles = SyncReadme::Config.profiles(config_file)
    return profiles[0] unless profiles.empty? || profiles[1]
    raise NO_CONFIGURATION_ERROR if profiles.empty?
  end
  default
end
new(profile, config_file = DEFAULT_CONFIG_FILE) click to toggle source
# File lib/sync_readme/config.rb, line 22
def initialize(profile, config_file = DEFAULT_CONFIG_FILE)
  @raw_config = YAML.load_file(config_file)[profile]
  raise NO_CONFIGURATION_ERROR unless @raw_config
end
profiles(config_file = DEFAULT_CONFIG_FILE) click to toggle source
# File lib/sync_readme/config.rb, line 7
def self.profiles(config_file = DEFAULT_CONFIG_FILE)
  YAML.load_file(config_file).keys.select { |key| key != 'default' }
end

Public Instance Methods

filename() click to toggle source
# File lib/sync_readme/config.rb, line 51
def filename
  @raw_config['filename']
end
notice() click to toggle source
# File lib/sync_readme/config.rb, line 35
def notice
  @raw_config['notice']
end
page_id() click to toggle source
# File lib/sync_readme/config.rb, line 47
def page_id
  @raw_config['page_id']
end
password() click to toggle source
# File lib/sync_readme/config.rb, line 43
def password
  ENV['CONFLUENCE_PASSWORD'] || @raw_config['password']
end
strip_title?() click to toggle source
# File lib/sync_readme/config.rb, line 55
def strip_title?
  @raw_config['strip_title'].nil? ? false : @raw_config['strip_title']
end
syntax_highlighting?() click to toggle source
# File lib/sync_readme/config.rb, line 59
def syntax_highlighting?
  @raw_config['syntax_highlighting'].nil? ? true : @raw_config['syntax_highlighting']
end
toc() click to toggle source
# File lib/sync_readme/config.rb, line 39
def toc
  @raw_config['toc']
end
url() click to toggle source
# File lib/sync_readme/config.rb, line 27
def url
  @raw_config['url']
end
username() click to toggle source
# File lib/sync_readme/config.rb, line 31
def username
  ENV['CONFLUENCE_USERNAME'] || @raw_config['username']
end