pith 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.markdown +1 -1
- data/cucumber.yml +1 -1
- data/features/layouts.feature +7 -7
- data/features/relative_linking.feature +2 -2
- data/features/step_definitions/build_steps.rb +1 -1
- data/features/textile.feature +11 -5
- data/lib/pith/input.rb +1 -0
- data/lib/pith/plugins/compass.rb +1 -1
- data/lib/pith/render_context.rb +0 -3
- data/lib/pith/version.rb +1 -1
- data/spec/pith/config_spec.rb +9 -9
- data/spec/pith/input_spec.rb +17 -9
- data/spec/pith/pathname_ext_spec.rb +5 -5
- data/spec/pith/plugins/publication_spec.rb +7 -7
- data/spec/pith/project_spec.rb +13 -13
- data/spec/pith/server_spec.rb +8 -9
- data/spec/spec_helper.rb +2 -0
- metadata +74 -140
- data/features/content_for.feature~ +0 -29
- data/features/haml.feature~ +0 -24
- data/features/helpers.feature~ +0 -23
- data/features/ignorance.feature~ +0 -37
- data/features/include.feature~ +0 -84
- data/features/incremental_rebuild.feature~ +0 -24
- data/features/layouts.feature~ +0 -63
- data/features/linking.feature~ +0 -79
- data/features/metadata.feature~ +0 -20
- data/features/relative_linking.feature~ +0 -109
- data/features/step_definitions/build_steps.rb~ +0 -66
- data/features/support/env.rb~ +0 -86
- data/features/support/rspec_matchers.rb~ +0 -5
- data/features/textile.feature~ +0 -29
- data/features/verbatim.feature~ +0 -32
- data/lib/pith.rb~ +0 -1
- data/lib/pith/console_logger.rb~ +0 -16
- data/lib/pith/input.rb~ +0 -20
- data/lib/pith/metadata.rb~ +0 -26
- data/lib/pith/pathname_ext.rb~ +0 -16
- data/lib/pith/plugins/publication.rb~ +0 -2
- data/lib/pith/plugins/publication/input.rb~ +0 -50
- data/lib/pith/plugins/publication/project.rb~ +0 -14
- data/lib/pith/project.rb~ +0 -143
- data/lib/pith/reference_error.rb~ +0 -5
- data/lib/pith/render_context.rb~ +0 -117
- data/lib/pith/server.rb~ +0 -46
- data/lib/pith/version.rb~ +0 -3
- data/lib/pith/watcher.rb~ +0 -32
- data/sample/_out/index.html +0 -14
- data/sample/_out/stylesheets/app.css +0 -38
@@ -1,66 +0,0 @@
|
|
1
|
-
Given /^input file "([^\"]*)" contains "([^\"]*)"$/ do |path, content|
|
2
|
-
@inputs.write(path, content, :mtime => (Time.now - 5))
|
3
|
-
end
|
4
|
-
|
5
|
-
Given /^input file "([^\"]*)" contains$/ do |path, content|
|
6
|
-
@inputs.write(path, content, :mtime => (Time.now - 5))
|
7
|
-
end
|
8
|
-
|
9
|
-
Given /^input file "([^\"]*)" exists$/ do |path|
|
10
|
-
Given %{input file "#{path}" contains "something"}
|
11
|
-
end
|
12
|
-
|
13
|
-
Given "the site is up-to-date" do
|
14
|
-
When "I build the site"
|
15
|
-
end
|
16
|
-
|
17
|
-
Given /^the "([^\"]*)" flag is enabled$/ do |flag|
|
18
|
-
@project.send("#{flag}=", true)
|
19
|
-
end
|
20
|
-
|
21
|
-
Given /^the "([^\"]*)" flag is disabled$/ do |flag|
|
22
|
-
@project.send("#{flag}=", false)
|
23
|
-
end
|
24
|
-
|
25
|
-
When /^I change input file "([^\"]*)" to contain "([^\"]*)"$/ do |path, content|
|
26
|
-
@inputs[path] = content
|
27
|
-
end
|
28
|
-
|
29
|
-
When /^I change input file "([^\"]*)" to contain$/ do |path, content|
|
30
|
-
@inputs[path] = content
|
31
|
-
end
|
32
|
-
|
33
|
-
When /^I remove input file "([^\"]*)"$/ do |path|
|
34
|
-
@inputs[path] = nil
|
35
|
-
end
|
36
|
-
|
37
|
-
When /^I (?:re)?build the site$/ do
|
38
|
-
@project.logger.clear
|
39
|
-
@project.build
|
40
|
-
end
|
41
|
-
|
42
|
-
class String
|
43
|
-
def clean
|
44
|
-
strip.gsub(/\s+/, ' ')
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
Then /^output file "([^\"]*)" should contain "([^\"]*)"$/ do |path, content|
|
49
|
-
@outputs[path].clean.should == content.clean
|
50
|
-
end
|
51
|
-
|
52
|
-
Then /^output file "([^\"]*)" should contain$/ do |path, content|
|
53
|
-
@outputs[path].clean.should == content.clean
|
54
|
-
end
|
55
|
-
|
56
|
-
Then /^output file "([^\"]*)" should not exist$/ do |path|
|
57
|
-
@outputs[path].should == nil
|
58
|
-
end
|
59
|
-
|
60
|
-
Then /^output file "([^"]*)" should be re\-generated$/ do |path|
|
61
|
-
@project.logger.messages.should contain(/--> +#{path}/)
|
62
|
-
end
|
63
|
-
|
64
|
-
Then /^output file "([^"]*)" should not be re\-generated$/ do |path|
|
65
|
-
@project.logger.messages.should_not contain(/--> +#{path}/)
|
66
|
-
end
|
data/features/support/env.rb~
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
require "pathname"
|
2
|
-
|
3
|
-
class DirHash
|
4
|
-
|
5
|
-
def initialize(dir)
|
6
|
-
@dir = Pathname(dir)
|
7
|
-
end
|
8
|
-
|
9
|
-
def [](file)
|
10
|
-
file_path = @dir + file
|
11
|
-
file_path.read if file_path.exist?
|
12
|
-
end
|
13
|
-
|
14
|
-
def []=(file, content)
|
15
|
-
if content.nil?
|
16
|
-
remove(file)
|
17
|
-
else
|
18
|
-
write(file, content)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def remove(file)
|
23
|
-
(@dir + file).unlink
|
24
|
-
end
|
25
|
-
|
26
|
-
def write(file, content, options = {})
|
27
|
-
file_path = @dir + file
|
28
|
-
file_path.parent.mkpath
|
29
|
-
file_path.open("w") do |io|
|
30
|
-
io << content
|
31
|
-
end
|
32
|
-
if options[:mtime]
|
33
|
-
timestamp = options[:mtime]
|
34
|
-
file_path.utime(timestamp, timestamp)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
class InternalLogger
|
41
|
-
|
42
|
-
def initialize
|
43
|
-
@messages = []
|
44
|
-
end
|
45
|
-
|
46
|
-
attr_reader :messages
|
47
|
-
|
48
|
-
def clear
|
49
|
-
@messages.clear
|
50
|
-
end
|
51
|
-
|
52
|
-
def info(message, &block)
|
53
|
-
message ||= block.call
|
54
|
-
write(message)
|
55
|
-
end
|
56
|
-
|
57
|
-
alias :warn :info
|
58
|
-
alias :debug :info
|
59
|
-
|
60
|
-
def write(message)
|
61
|
-
@messages << message
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
$project_dir = Pathname(__FILE__).expand_path.parent.parent.parent
|
67
|
-
$tmp_dir = $project_dir + "tmp"
|
68
|
-
|
69
|
-
$input_dir = $tmp_dir + "input"
|
70
|
-
|
71
|
-
$output_dir = $tmp_dir + "output"
|
72
|
-
$output_dir.mkpath
|
73
|
-
|
74
|
-
$: << ($project_dir + "lib").to_s
|
75
|
-
require "pith"
|
76
|
-
|
77
|
-
Before do
|
78
|
-
[$input_dir, $output_dir].each do |dir|
|
79
|
-
dir.rmtree if dir.exist?
|
80
|
-
dir.mkpath
|
81
|
-
end
|
82
|
-
@project = Pith::Project.new(:input_dir => $input_dir, :output_dir => $output_dir)
|
83
|
-
@project.logger = InternalLogger.new
|
84
|
-
@inputs = DirHash.new($input_dir)
|
85
|
-
@outputs = DirHash.new($output_dir)
|
86
|
-
end
|
data/features/textile.feature~
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
Feature: support for Textile markup
|
2
|
-
|
3
|
-
I want to use Textile fragments in pages
|
4
|
-
So that I can express content succintly
|
5
|
-
|
6
|
-
Scenario: Haml page with embedded Textile
|
7
|
-
|
8
|
-
Given input file "page.html.haml" contains
|
9
|
-
"""
|
10
|
-
:textile
|
11
|
-
|
12
|
-
A paragraph.
|
13
|
-
|
14
|
-
* one
|
15
|
-
* two
|
16
|
-
* three
|
17
|
-
"""
|
18
|
-
|
19
|
-
When I build the site
|
20
|
-
|
21
|
-
Then output file "page.html" should contain
|
22
|
-
"""
|
23
|
-
<p>A paragraph.</p>
|
24
|
-
<ul>
|
25
|
-
<li>one</li>
|
26
|
-
<li>two</li>
|
27
|
-
<li>three</li>
|
28
|
-
</ul>
|
29
|
-
"""
|
data/features/verbatim.feature~
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
Feature: unrecognised input files are copied into output intact
|
2
|
-
|
3
|
-
I want any unrecognised file to be copied into the site verbatim
|
4
|
-
So that I can mix dynamic and static content
|
5
|
-
|
6
|
-
Scenario: text file
|
7
|
-
|
8
|
-
Given input file "verbatim.txt" contains
|
9
|
-
"""
|
10
|
-
Blah de blah
|
11
|
-
"""
|
12
|
-
|
13
|
-
When I build the site
|
14
|
-
|
15
|
-
Then output file "verbatim.txt" should contain
|
16
|
-
"""
|
17
|
-
Blah de blah
|
18
|
-
"""
|
19
|
-
|
20
|
-
Scenario: file in subdirectory
|
21
|
-
|
22
|
-
Given input file "blah/verbatim.txt" contains
|
23
|
-
"""
|
24
|
-
Blah de blah
|
25
|
-
"""
|
26
|
-
|
27
|
-
When I build the site
|
28
|
-
|
29
|
-
Then output file "blah/verbatim.txt" should contain
|
30
|
-
"""
|
31
|
-
Blah de blah
|
32
|
-
"""
|
data/lib/pith.rb~
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'pith/project'
|
data/lib/pith/console_logger.rb~
DELETED
data/lib/pith/input.rb~
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require "pith/input/template"
|
2
|
-
require "pith/input/resource"
|
3
|
-
|
4
|
-
module Pith
|
5
|
-
module Input
|
6
|
-
|
7
|
-
class << self
|
8
|
-
|
9
|
-
def new(project, path)
|
10
|
-
if Template.can_handle?(path)
|
11
|
-
Template.new(project, path)
|
12
|
-
else
|
13
|
-
Resource.new(project, path)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
data/lib/pith/metadata.rb~
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require "yaml"
|
2
|
-
|
3
|
-
module Pith
|
4
|
-
|
5
|
-
module Metadata
|
6
|
-
|
7
|
-
extend self
|
8
|
-
|
9
|
-
def extract_from(io)
|
10
|
-
line = io.gets
|
11
|
-
if line =~ /---$/
|
12
|
-
metadata_prefix = $`
|
13
|
-
yaml = ""
|
14
|
-
while line && line.start_with?(metadata_prefix)
|
15
|
-
yaml << line[metadata_prefix.size .. -1]
|
16
|
-
line = io.gets
|
17
|
-
end
|
18
|
-
YAML.load(yaml)
|
19
|
-
else
|
20
|
-
Hash.new
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
data/lib/pith/pathname_ext.rb~
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require "pathname"
|
2
|
-
|
3
|
-
class Pathname
|
4
|
-
|
5
|
-
def touch(mtime = nil)
|
6
|
-
FileUtils.touch(self.to_s)
|
7
|
-
utime(mtime, mtime) if mtime
|
8
|
-
end
|
9
|
-
|
10
|
-
def all_files(pattern = "**/*")
|
11
|
-
Pathname.glob(self + pattern, File::FNM_DOTMATCH).select do |path|
|
12
|
-
path.file?
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require "pith/input"
|
2
|
-
require "time"
|
3
|
-
|
4
|
-
module Pith
|
5
|
-
module Plugins
|
6
|
-
module Publication
|
7
|
-
|
8
|
-
module TemplateMethods
|
9
|
-
|
10
|
-
def published?
|
11
|
-
!published_at.nil?
|
12
|
-
end
|
13
|
-
|
14
|
-
def published_at
|
15
|
-
parse_date(meta["published"])
|
16
|
-
end
|
17
|
-
|
18
|
-
def updated_at
|
19
|
-
parse_date(meta["updated"]) || published_at
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def parse_date(date_string)
|
25
|
-
Time.parse(date_string) if date_string
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
module Pith
|
35
|
-
module Input
|
36
|
-
|
37
|
-
class Abstract
|
38
|
-
|
39
|
-
def published?
|
40
|
-
false
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
class Template
|
46
|
-
include Pith::Plugins::Publication::TemplateMethods
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
end
|
data/lib/pith/project.rb~
DELETED
@@ -1,143 +0,0 @@
|
|
1
|
-
require "logger"
|
2
|
-
require "pith/input"
|
3
|
-
require "pith/pathname_ext"
|
4
|
-
require "pith/reference_error"
|
5
|
-
require "tilt"
|
6
|
-
|
7
|
-
module Pith
|
8
|
-
|
9
|
-
class Project
|
10
|
-
|
11
|
-
def initialize(attributes = {})
|
12
|
-
attributes.each do |k,v|
|
13
|
-
send("#{k}=", v)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
attr_reader :input_dir
|
18
|
-
|
19
|
-
def input_dir=(dir)
|
20
|
-
@input_dir = Pathname(dir)
|
21
|
-
end
|
22
|
-
|
23
|
-
attr_reader :output_dir
|
24
|
-
|
25
|
-
def output_dir=(dir)
|
26
|
-
@output_dir = Pathname(dir)
|
27
|
-
end
|
28
|
-
|
29
|
-
attr_accessor :assume_content_negotiation
|
30
|
-
attr_accessor :assume_directory_index
|
31
|
-
|
32
|
-
# Public: get inputs
|
33
|
-
#
|
34
|
-
# Returns Pith::Input objects representing the files in the input_dir.
|
35
|
-
#
|
36
|
-
# The list of inputs is cached after first load;
|
37
|
-
# call #refresh to discard the cached data.
|
38
|
-
#
|
39
|
-
def inputs
|
40
|
-
@inputs ||= input_dir.all_files.map do |input_file|
|
41
|
-
path = input_file.relative_path_from(input_dir)
|
42
|
-
find_or_create_input(path)
|
43
|
-
end.compact
|
44
|
-
end
|
45
|
-
|
46
|
-
# Public: find an input.
|
47
|
-
#
|
48
|
-
# path - an path relative to either input_dir or output_dir
|
49
|
-
#
|
50
|
-
# Returns the first input whose input_path or output_path matches.
|
51
|
-
# Returns nil if no match is found.
|
52
|
-
#
|
53
|
-
def input(path)
|
54
|
-
path = Pathname(path)
|
55
|
-
inputs.each do |input|
|
56
|
-
return input if input.path == path || input.output_path == path
|
57
|
-
end
|
58
|
-
nil
|
59
|
-
end
|
60
|
-
|
61
|
-
# Public: build the project, generating output files.
|
62
|
-
#
|
63
|
-
def build
|
64
|
-
refresh
|
65
|
-
load_config
|
66
|
-
remove_old_outputs
|
67
|
-
generate_outputs
|
68
|
-
output_dir.touch
|
69
|
-
end
|
70
|
-
|
71
|
-
# Public: discard cached data that is out-of-sync with the file-system.
|
72
|
-
#
|
73
|
-
def refresh
|
74
|
-
@inputs = nil
|
75
|
-
@config_files = nil
|
76
|
-
end
|
77
|
-
|
78
|
-
def last_built_at
|
79
|
-
output_dir.mtime
|
80
|
-
end
|
81
|
-
|
82
|
-
def logger
|
83
|
-
@logger ||= Logger.new(nil)
|
84
|
-
end
|
85
|
-
|
86
|
-
attr_writer :logger
|
87
|
-
|
88
|
-
def helpers(&block)
|
89
|
-
helper_module.module_eval(&block)
|
90
|
-
end
|
91
|
-
|
92
|
-
def helper_module
|
93
|
-
@helper_module ||= Module.new
|
94
|
-
end
|
95
|
-
|
96
|
-
def config_files
|
97
|
-
@config_files ||= begin
|
98
|
-
input_dir.all_files("_pith/**")
|
99
|
-
end.to_set
|
100
|
-
end
|
101
|
-
|
102
|
-
private
|
103
|
-
|
104
|
-
def load_config
|
105
|
-
config_file = input_dir + "_pith/config.rb"
|
106
|
-
project = self
|
107
|
-
if config_file.exist?
|
108
|
-
eval(config_file.read, binding, config_file)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
def remove_old_outputs
|
113
|
-
valid_output_paths = inputs.map { |i| i.output_path }
|
114
|
-
output_dir.all_files.each do |output_file|
|
115
|
-
output_path = output_file.relative_path_from(output_dir)
|
116
|
-
unless valid_output_paths.member?(output_path)
|
117
|
-
logger.info("removing #{output_path}")
|
118
|
-
FileUtils.rm(output_file)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
def generate_outputs
|
124
|
-
inputs.each do |input|
|
125
|
-
input.build
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def input_cache
|
130
|
-
@input_cache ||= Hash.new do |h, cache_key|
|
131
|
-
h[cache_key] = Input.new(self, cache_key.first)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def find_or_create_input(path)
|
136
|
-
file = input_dir + path
|
137
|
-
cache_key = [path, file.mtime]
|
138
|
-
input_cache[cache_key]
|
139
|
-
end
|
140
|
-
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|