create_accessories()
click to toggle source
def create_accessories
accessories = %w(README.md LICENSE.txt)
accessories << "CODE_OF_CONDUCT.md" if code_of_conduct
accessories.each do |filename|
write_file(filename, template(filename))
end
end
create_directories()
click to toggle source
def create_directories
mkdir_p(SCAFFOLD_DIRECTORIES)
end
create_gemspec()
click to toggle source
def create_gemspec
write_file("Gemfile", template("Gemfile"))
write_file("#{name}.gemspec", template("theme.gemspec"))
end
create_starter_files()
click to toggle source
def create_starter_files
%w(page post default).each do |layout|
write_file("_layouts/#{layout}.html", template("_layouts/#{layout}.html"))
end
end
erb()
click to toggle source
def erb
@erb ||= ERBRenderer.new(self)
end
initialize_git_repo()
click to toggle source
def initialize_git_repo
Jekyll.logger.info "initialize", path.join(".git").to_s
Dir.chdir(path.to_s) { %xgit init` }
write_file(".gitignore", template("gitignore"))
end
mkdir_p(directories)
click to toggle source
def mkdir_p(directories)
Array(directories).each do |directory|
full_path = path.join(directory)
Jekyll.logger.info "create", full_path.to_s
FileUtils.mkdir_p(full_path)
end
end
root()
click to toggle source
def root
@root ||= Pathname.new(File.expand_path("../", __dir__))
end
template(filename)
click to toggle source
def template(filename)
erb.render(template_file(filename).read)
end
template_file(filename)
click to toggle source
def template_file(filename)
[
root.join("theme_template", "#{filename}.erb"),
root.join("theme_template", filename.to_s)
].find(&:exist?)
end
user_email()
click to toggle source
def user_email
@user_email ||= %xgit config user.email`.chomp
end
user_name()
click to toggle source
def user_name
@user_name ||= %xgit config user.name`.chomp
end
write_file(filename, contents)
click to toggle source
def write_file(filename, contents)
full_path = path.join(filename)
Jekyll.logger.info "create", full_path.to_s
File.write(full_path, contents)
end