Module: Artifact
- Defined in:
- lib/artifact.rb,
lib/artifact/app.rb,
lib/artifact/cli.rb,
lib/artifact/files.rb,
lib/artifact/static.rb,
lib/artifact/helpers.rb,
lib/artifact/version.rb,
lib/artifact/middleman.rb
Defined Under Namespace
Modules: Helpers
Classes: App, CLI, Config, Files, HTMLFile, MarkdownFile, Middleman, ReadableFile, Repo, Static, Tree, WritableFile
Constant Summary
collapse
- FORMATS =
{
'.markdown' => "Artifact::MarkdownFile",
'.html' => "Artifact::HTMLFile"
}
- VERSION =
"0.3.6"
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
12
13
14
|
# File 'lib/artifact.rb', line 12
def self.config
@config ||= Config.new
end
|
16
17
18
19
20
21
|
# 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 ⇒ Object
47
48
49
50
|
# File 'lib/artifact/middleman.rb', line 47
def self.drafts
opts = {:new_file_path => ''} @drafts ||= Tree.new(File.join(source_root, Artifact.config.drafts_path), opts)
end
|
.ensure_dir!(full_path) ⇒ Object
55
56
57
58
|
# 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 ⇒ Object
5
6
7
|
# File 'lib/artifact/files.rb', line 5
def self.files
@files ||= Tree.new(config.root)
end
|
.full_path(path) ⇒ Object
27
28
29
|
# File 'lib/artifact.rb', line 27
def self.full_path(path)
File.join(root, path)
end
|
.load_file(path, fallback) ⇒ Object
43
44
45
46
47
48
49
|
# 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 ⇒ Object
35
36
37
|
# File 'lib/artifact/middleman.rb', line 35
def self.middleman
@app
end
|
.middleman=(app) ⇒ Object
31
32
33
|
# File 'lib/artifact/middleman.rb', line 31
def self.middleman=(app)
@app = app
end
|
.new_file(path) ⇒ Object
39
40
41
|
# File 'lib/artifact.rb', line 39
def self.new_file(path)
load_file(path, WritableFile)
end
|
.open_file(path) ⇒ Object
35
36
37
|
# File 'lib/artifact.rb', line 35
def self.open_file(path)
load_file(path, ReadableFile)
end
|
.posts ⇒ Object
43
44
45
|
# 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) ⇒ Object
31
32
33
|
# File 'lib/artifact.rb', line 31
def self.relative_path(path)
path.sub(root + '/', '')
end
|
.repo ⇒ Object
51
52
53
|
# File 'lib/artifact.rb', line 51
def self.repo
@repo ||= Repo.new(File.expand_path(config.root))
end
|
.root ⇒ Object
23
24
25
|
# File 'lib/artifact.rb', line 23
def self.root
config.root
end
|
.run_hook(name, *args) ⇒ Object
60
61
62
63
64
65
|
# 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 ⇒ Object
39
40
41
|
# File 'lib/artifact/middleman.rb', line 39
def self.source_root
File.join(config.root, config.source_root)
end
|
.uploads ⇒ Object
52
53
54
|
# File 'lib/artifact/middleman.rb', line 52
def self.uploads
@uploads ||= Tree.new(File.join(source_root, Artifact.config.uploads_path))
end
|