class Jekyll::Theme

Attributes

name[R]

Public Class Methods

new(name) click to toggle source
# File lib/jekyll/theme.rb, line 7
def initialize(name)
  @name = name.downcase.strip
  configure_sass
end

Public Instance Methods

configure_sass() click to toggle source
# File lib/jekyll/theme.rb, line 32
def configure_sass
  return unless sass_path
  require "sass"
  Sass.load_paths << sass_path
end
includes_path() click to toggle source
# File lib/jekyll/theme.rb, line 20
def includes_path
  path_for :includes
end
layouts_path() click to toggle source
# File lib/jekyll/theme.rb, line 24
def layouts_path
  path_for :layouts
end
root() click to toggle source
# File lib/jekyll/theme.rb, line 12
def root
  # Must use File.realpath to resolve symlinks created by rbenv
  # Otherwise, Jekyll.sanitized path with prepend the unresolved root
  @root ||= File.realpath(gemspec.full_gem_path)
rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP
  nil
end
sass_path() click to toggle source
# File lib/jekyll/theme.rb, line 28
def sass_path
  path_for :sass
end

Private Instance Methods

gemspec() click to toggle source
# File lib/jekyll/theme.rb, line 51
def gemspec
  @gemspec ||= Gem::Specification.find_by_name(name)
rescue Gem::LoadError
  raise Jekyll::Errors::MissingDependencyException,
    "The #{name} theme could not be found."
end
path_for(folder) click to toggle source
# File lib/jekyll/theme.rb, line 40
def path_for(folder)
  path = realpath_for(folder)
  path if path && File.directory?(path)
end
realpath_for(folder) click to toggle source
# File lib/jekyll/theme.rb, line 45
def realpath_for(folder)
  File.realpath(Jekyll.sanitized_path(root, "_#{folder}"))
rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP
  nil
end