module Artifact

Constants

FORMATS
VERSION

Public Class Methods

config() click to toggle source
# File lib/artifact.rb, line 12
def self.config
  @config ||= Config.new
end
configure() { |config| ... } click to toggle source
# File lib/artifact.rb, line 16
def self.configure
  yield config
  unless config.author_name && config.author_email
    raise "Both author_name and author_email are needed."
  end
end
drafts() click to toggle source
# File lib/artifact/middleman.rb, line 47
def self.drafts
  opts = {:new_file_path => ''} # flat, no date
  @drafts ||= Tree.new(File.join(source_root, Artifact.config.drafts_path), opts)
end
ensure_dir!(full_path) click to toggle source
# File lib/artifact.rb, line 55
def self.ensure_dir!(full_path)
  dir = File.dirname(full_path)
  FileUtils.mkdir_p(dir) unless File.exist?(dir)
end
files() click to toggle source
# File lib/artifact/files.rb, line 5
def self.files
  @files ||= Tree.new(config.root)
end
full_path(path) click to toggle source
# File lib/artifact.rb, line 27
def self.full_path(path)
  File.join(root, path)
end
load_file(path, fallback) click to toggle source
# File lib/artifact.rb, line 43
def self.load_file(path, fallback)
  if klass = FORMATS[File.extname(path)]
    Kernel.const_get(klass).new(path)
  else
    fallback.new(path)
  end
end
middleman() click to toggle source
# File lib/artifact/middleman.rb, line 35
def self.middleman
  @app
end
middleman=(app) click to toggle source
# File lib/artifact/middleman.rb, line 31
def self.middleman=(app)
  @app = app
end
new_file(path) click to toggle source
# File lib/artifact.rb, line 39
def self.new_file(path)
  load_file(path, WritableFile)
end
open_file(path) click to toggle source
# File lib/artifact.rb, line 35
def self.open_file(path)
  load_file(path, ReadableFile)
end
posts() click to toggle source
# File lib/artifact/middleman.rb, line 43
def self.posts
  @posts ||= Tree.new(File.join(source_root, Artifact.config.posts_path))
end
relative_path(path) click to toggle source
# File lib/artifact.rb, line 31
def self.relative_path(path)
  path.sub(root + '/', '')
end
repo() click to toggle source
# File lib/artifact.rb, line 51
def self.repo
  @repo ||= Repo.new(File.expand_path(config.root))
end
root() click to toggle source
# File lib/artifact.rb, line 23
def self.root
  config.root
end
run_hook(name, *args) click to toggle source
# File lib/artifact.rb, line 60
def self.run_hook(name, *args)
  if proc = config.send(name)
    puts " ------------> Running hook: #{name}"
    proc.call(*args)
  end
end
source_root() click to toggle source
# File lib/artifact/middleman.rb, line 39
def self.source_root
  File.join(config.root, config.source_root)
end
uploads() click to toggle source
# File lib/artifact/middleman.rb, line 52
def self.uploads
  @uploads ||= Tree.new(File.join(source_root, Artifact.config.uploads_path))
end