class Octopress::Ink::Assets::Config
Public Class Methods
new(plugin, path)
click to toggle source
# File lib/octopress-ink/assets/config.rb, line 6 def initialize(plugin, path) @root = plugin.assets_path @plugin = plugin @dir = plugin.slug @base = '' @exists = {} @file = path end
Public Instance Methods
fix_permalinks(config)
click to toggle source
Permalinks should not contain file extensions This replaces file extensions in the keys so they still work
# File lib/octopress-ink/assets/config.rb, line 43 def fix_permalinks(config) fixed_permalinks = {} config['permalinks'] ||= {} config['permalinks'].each do |k,v| if k.match('.') key = k.sub(File.extname(k), '') fixed_permalinks[key] = v config['permalinks'].delete(k) end end config['permalinks'] = fixed_permalinks config end
info()
click to toggle source
If config plugin config file exists, return contents for list command
# File lib/octopress-ink/assets/config.rb, line 16 def info if exists?(config = plugin_path) Ink::Utils.pretty_print_yaml(read) else " none" end end
read()
click to toggle source
# File lib/octopress-ink/assets/config.rb, line 24 def read config = {} default = plugin_path if exists? default config = SafeYAML.load_file(default) || {} end if exists? user_path user_config = SafeYAML.load_file(user_path) || {} config = Jekyll::Utils.deep_merge_hashes(config, user_config) end fix_permalinks(config) end