benoit 0.1.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.
- data/.gitignore +4 -0
- data/.gitmodules +3 -0
- data/.rspec +1 -0
- data/.rspec-turnip +1 -0
- data/.ruby-version +1 -0
- data/Assetfile +44 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +110 -0
- data/Rakefile +9 -0
- data/benoit.gemspec +50 -0
- data/bin/benoit +121 -0
- data/bin/bundle-development +1 -0
- data/bin/bundle-sandbox +1 -0
- data/lib/benoit.rb +36 -0
- data/lib/benoit/cadenza.rb +11 -0
- data/lib/benoit/cadenza/output_filters.rb +21 -0
- data/lib/benoit/cleaner.rb +10 -0
- data/lib/benoit/compiler_error.rb +49 -0
- data/lib/benoit/configuration.rb +24 -0
- data/lib/benoit/current_site.rb +12 -0
- data/lib/benoit/file_wrapper_extensions.rb +13 -0
- data/lib/benoit/filters.rb +15 -0
- data/lib/benoit/filters/base_filter.rb +44 -0
- data/lib/benoit/filters/blacklist_filter.rb +18 -0
- data/lib/benoit/filters/cadenza_filter.rb +75 -0
- data/lib/benoit/filters/content_page_filter.rb +45 -0
- data/lib/benoit/filters/markdown_filter.rb +19 -0
- data/lib/benoit/filters/metadata_cleaner.rb +30 -0
- data/lib/benoit/filters/move_to_root_filter.rb +22 -0
- data/lib/benoit/filters/pagination_filter.rb +23 -0
- data/lib/benoit/filters/pass_thru_filter.rb +22 -0
- data/lib/benoit/filters/sass_filter.rb +74 -0
- data/lib/benoit/filters/set_metadata_filter.rb +15 -0
- data/lib/benoit/logger.rb +69 -0
- data/lib/benoit/page.rb +88 -0
- data/lib/benoit/page_metadata.rb +8 -0
- data/lib/benoit/page_metadata/container.rb +74 -0
- data/lib/benoit/page_metadata/json_converter.rb +28 -0
- data/lib/benoit/page_metadata/parser.rb +38 -0
- data/lib/benoit/page_metadata/store.rb +75 -0
- data/lib/benoit/pipeline.rb +1 -0
- data/lib/benoit/pipeline/dsl_extensions.rb +8 -0
- data/lib/benoit/pipeline/pagination_matcher.rb +53 -0
- data/lib/benoit/pipeline_project.rb +81 -0
- data/lib/benoit/site_context.rb +123 -0
- data/lib/benoit/utils/finds_layouts_for_template.rb +77 -0
- data/lib/benoit/utils/normalizes_path_to_template.rb +43 -0
- data/lib/benoit/utils/paginated_list.rb +102 -0
- data/lib/benoit/version.rb +3 -0
- data/lib/build_notifiers/file_built_notifier.rb +20 -0
- data/lib/build_notifiers/progress_notifier.rb +57 -0
- data/lib/cli.rb +39 -0
- data/spec/.rbenv-gemsets +1 -0
- data/spec/Gemfile +9 -0
- data/spec/Gemfile.lock +57 -0
- data/spec/bin/autospec +16 -0
- data/spec/bin/cucumber +16 -0
- data/spec/bin/htmldiff +16 -0
- data/spec/bin/ldiff +16 -0
- data/spec/bin/rspec +16 -0
- data/spec/features/build_command.feature +46 -0
- data/spec/features/frontmatter_metadata.feature +99 -0
- data/spec/features/javascript_files.feature +35 -0
- data/spec/features/output_filters.feature +20 -0
- data/spec/features/page_layouts.feature +72 -0
- data/spec/features/pagination.feature +58 -0
- data/spec/features/sass_files.feature +30 -0
- data/spec/features/version.feature +5 -0
- data/spec/lib/filters/base_filter_spec.rb +141 -0
- data/spec/lib/filters/markdown_filter_spec.rb +65 -0
- data/spec/lib/filters/sass_filter_spec.rb +73 -0
- data/spec/lib/metadata_json_converter_spec.rb +65 -0
- data/spec/lib/metadata_store_spec.rb +148 -0
- data/spec/lib/page_spec.rb +19 -0
- data/spec/lib/site_context_spec.rb +106 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/steps/output_file_steps.rb +45 -0
- data/spec/steps/run_steps.rb +71 -0
- data/spec/steps/staticly_steps.rb +194 -0
- data/spec/support/aruba/rspec.rb +66 -0
- data/spec/support/files/img.png +0 -0
- data/spec/support/files/input.css.scss +7 -0
- data/spec/support/files/input.scss +7 -0
- data/spec/support/spec_helpers/file_helpers.rb +8 -0
- data/spec/support/spec_helpers/memory_file_wrapper.rb +43 -0
- data/spec/support/spec_helpers/memory_manifest.rb +19 -0
- data/spec/turnip_helper.rb +19 -0
- data/vendor/frontmatter/frontmatter.gemspec +24 -0
- data/vendor/frontmatter/lib/frontmatter.rb +92 -0
- data/vendor/frontmatter/lib/frontmatter/version.rb +3 -0
- data/vendor/rake-pipeline/.gitignore +18 -0
- data/vendor/rake-pipeline/.rspec +1 -0
- data/vendor/rake-pipeline/.travis.yml +12 -0
- data/vendor/rake-pipeline/.yardopts +2 -0
- data/vendor/rake-pipeline/GETTING_STARTED.md +268 -0
- data/vendor/rake-pipeline/Gemfile +14 -0
- data/vendor/rake-pipeline/LICENSE +20 -0
- data/vendor/rake-pipeline/README.markdown +11 -0
- data/vendor/rake-pipeline/README.yard +178 -0
- data/vendor/rake-pipeline/Rakefile +21 -0
- data/vendor/rake-pipeline/bin/rakep +4 -0
- data/vendor/rake-pipeline/examples/copying_files.md +12 -0
- data/vendor/rake-pipeline/examples/minifying_files.md +37 -0
- data/vendor/rake-pipeline/examples/modifying_pipelines.md +67 -0
- data/vendor/rake-pipeline/examples/multiple_pipelines.md +77 -0
- data/vendor/rake-pipeline/lib/generators/rake/pipeline/install/install_generator.rb +70 -0
- data/vendor/rake-pipeline/lib/rake-pipeline.rb +509 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/cli.rb +57 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/dsl.rb +9 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/dsl/pipeline_dsl.rb +246 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/dsl/project_dsl.rb +108 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/dynamic_file_task.rb +194 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/error.rb +17 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/file_wrapper.rb +195 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/filter.rb +267 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/filters.rb +4 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/filters/concat_filter.rb +63 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/filters/gsub_filter.rb +56 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/filters/ordering_concat_filter.rb +38 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/filters/pipeline_finalizing_filter.rb +21 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/graph.rb +178 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/manifest.rb +82 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/manifest_entry.rb +34 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/matcher.rb +141 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/middleware.rb +73 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/precompile.rake +8 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/project.rb +338 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/rails_plugin.rb +10 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/railtie.rb +34 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/reject_matcher.rb +29 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/server.rb +15 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/sorted_pipeline.rb +19 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/version.rb +6 -0
- data/vendor/rake-pipeline/rails/init.rb +2 -0
- data/vendor/rake-pipeline/rake-pipeline.gemspec +24 -0
- data/vendor/rake-pipeline/spec/cli_spec.rb +73 -0
- data/vendor/rake-pipeline/spec/concat_filter_spec.rb +37 -0
- data/vendor/rake-pipeline/spec/dsl/pipeline_dsl_spec.rb +165 -0
- data/vendor/rake-pipeline/spec/dsl/project_dsl_spec.rb +41 -0
- data/vendor/rake-pipeline/spec/dynamic_file_task_spec.rb +119 -0
- data/vendor/rake-pipeline/spec/encoding_spec.rb +106 -0
- data/vendor/rake-pipeline/spec/file_wrapper_spec.rb +132 -0
- data/vendor/rake-pipeline/spec/filter_spec.rb +367 -0
- data/vendor/rake-pipeline/spec/graph_spec.rb +56 -0
- data/vendor/rake-pipeline/spec/gsub_filter_spec.rb +87 -0
- data/vendor/rake-pipeline/spec/manifest_entry_spec.rb +46 -0
- data/vendor/rake-pipeline/spec/manifest_spec.rb +67 -0
- data/vendor/rake-pipeline/spec/matcher_spec.rb +141 -0
- data/vendor/rake-pipeline/spec/middleware_spec.rb +199 -0
- data/vendor/rake-pipeline/spec/ordering_concat_filter_spec.rb +42 -0
- data/vendor/rake-pipeline/spec/pipeline_spec.rb +232 -0
- data/vendor/rake-pipeline/spec/project_spec.rb +295 -0
- data/vendor/rake-pipeline/spec/rake_acceptance_spec.rb +720 -0
- data/vendor/rake-pipeline/spec/rake_tasks_spec.rb +21 -0
- data/vendor/rake-pipeline/spec/reject_matcher_spec.rb +31 -0
- data/vendor/rake-pipeline/spec/sorted_pipeline_spec.rb +27 -0
- data/vendor/rake-pipeline/spec/spec_helper.rb +38 -0
- data/vendor/rake-pipeline/spec/support/spec_helpers/file_utils.rb +35 -0
- data/vendor/rake-pipeline/spec/support/spec_helpers/filters.rb +37 -0
- data/vendor/rake-pipeline/spec/support/spec_helpers/input_helpers.rb +23 -0
- data/vendor/rake-pipeline/spec/support/spec_helpers/memory_file_wrapper.rb +35 -0
- data/vendor/rake-pipeline/spec/support/spec_helpers/memory_manifest.rb +19 -0
- data/vendor/rake-pipeline/tools/perfs +101 -0
- metadata +497 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
Feature: Page Layouts
|
|
2
|
+
|
|
3
|
+
Background:
|
|
4
|
+
Given a site
|
|
5
|
+
|
|
6
|
+
Scenario: Finds layouts in _layouts
|
|
7
|
+
Given a site named "test"
|
|
8
|
+
And a file named "index.html" with content:
|
|
9
|
+
"""
|
|
10
|
+
{% extends "_layout.html" %}
|
|
11
|
+
|
|
12
|
+
{% block content %}boo{% endblock %}
|
|
13
|
+
"""
|
|
14
|
+
And a file named "_layouts/_layout.html" with content:
|
|
15
|
+
"""
|
|
16
|
+
<section id="main">
|
|
17
|
+
{% block content %}{% endblock %}
|
|
18
|
+
</section>
|
|
19
|
+
"""
|
|
20
|
+
When I run `benoit build`
|
|
21
|
+
Then the output file "index.html" should have content:
|
|
22
|
+
"""
|
|
23
|
+
<section id="main">
|
|
24
|
+
boo
|
|
25
|
+
</section>
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
Scenario: Reads layout from metadata in .html files
|
|
29
|
+
Given a file with an extension of ".html" containing metadata:
|
|
30
|
+
"""
|
|
31
|
+
layout: _layout
|
|
32
|
+
"""
|
|
33
|
+
And that file has content:
|
|
34
|
+
"""
|
|
35
|
+
{% block content %}CONTENT{% endblock %}
|
|
36
|
+
"""
|
|
37
|
+
And a layout named "_layout" with content:
|
|
38
|
+
"""
|
|
39
|
+
!!!
|
|
40
|
+
{% block content %}{% endblock %}
|
|
41
|
+
!!!
|
|
42
|
+
"""
|
|
43
|
+
When I build the site
|
|
44
|
+
Then the output file should have content:
|
|
45
|
+
"""
|
|
46
|
+
!!!
|
|
47
|
+
CONTENT
|
|
48
|
+
!!!
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
Scenario: Doesn't require layouts prefixed with underscore
|
|
52
|
+
Given a file with an extension of ".html" containing metadata:
|
|
53
|
+
"""
|
|
54
|
+
layout: layout
|
|
55
|
+
"""
|
|
56
|
+
And that file has content:
|
|
57
|
+
"""
|
|
58
|
+
{% block content %}CONTENT{% endblock %}
|
|
59
|
+
"""
|
|
60
|
+
And a layout named "_layout" with content:
|
|
61
|
+
"""
|
|
62
|
+
!!!
|
|
63
|
+
{% block content %}{% endblock %}
|
|
64
|
+
!!!
|
|
65
|
+
"""
|
|
66
|
+
When I build the site
|
|
67
|
+
Then the output file should have content:
|
|
68
|
+
"""
|
|
69
|
+
!!!
|
|
70
|
+
CONTENT
|
|
71
|
+
!!!
|
|
72
|
+
"""
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
Feature: Content Pagination
|
|
2
|
+
|
|
3
|
+
Background:
|
|
4
|
+
Given a site
|
|
5
|
+
And 20 files containing metadata:
|
|
6
|
+
"""
|
|
7
|
+
type: post
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
Scenario: Outputs one file per page
|
|
11
|
+
Given a file named "page.html" containing metadata:
|
|
12
|
+
"""
|
|
13
|
+
posts_per_page: 10
|
|
14
|
+
"""
|
|
15
|
+
When I build the site
|
|
16
|
+
Then the output file "page1.html" should exist
|
|
17
|
+
And the output file "page2.html" should exist
|
|
18
|
+
|
|
19
|
+
Scenario: Renders 10 posts per page
|
|
20
|
+
Given a file named "page.html" with content:
|
|
21
|
+
"""
|
|
22
|
+
---
|
|
23
|
+
posts_per_page: 10
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
{% for post in site.paginated_posts | sort: "page_num" %}{{post.content}}
|
|
27
|
+
{% endfor %}
|
|
28
|
+
"""
|
|
29
|
+
When I build the site
|
|
30
|
+
Then the output file "page1.html" should only contain the first 10 posts
|
|
31
|
+
And the output file "page2.html" should only contain the last 10 posts
|
|
32
|
+
|
|
33
|
+
Scenario: Renders 5 posts per page
|
|
34
|
+
Given a file named "page.html" with content:
|
|
35
|
+
"""
|
|
36
|
+
---
|
|
37
|
+
posts_per_page: 5
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
{% for post in site.paginated_posts | sort: "page_num" %}{{post.content}}
|
|
41
|
+
{% endfor %}
|
|
42
|
+
"""
|
|
43
|
+
When I build the site
|
|
44
|
+
Then the output file "page1.html" should only contain the first 5 posts
|
|
45
|
+
And the output file "page4.html" should only contain the last 5 posts
|
|
46
|
+
|
|
47
|
+
Scenario: Keeps path to paginated files
|
|
48
|
+
Given a file named "dir/page.html" with content:
|
|
49
|
+
"""
|
|
50
|
+
---
|
|
51
|
+
posts_per_page: 5
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
{% for post in site.paginated_posts | sort: "page_num" %}{{post.content}}
|
|
55
|
+
{% endfor %}
|
|
56
|
+
"""
|
|
57
|
+
When I build the site
|
|
58
|
+
Then the output file "dir/page1.html" should exist
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Feature: Compiling Sass Files
|
|
2
|
+
|
|
3
|
+
Background:
|
|
4
|
+
Given a site
|
|
5
|
+
|
|
6
|
+
Scenario: Converts SCSS files to CSS
|
|
7
|
+
Given a file named "styles.scss" with content:
|
|
8
|
+
"""
|
|
9
|
+
$variable: value;
|
|
10
|
+
|
|
11
|
+
.test {
|
|
12
|
+
.nested {
|
|
13
|
+
attribute: $variable;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
"""
|
|
17
|
+
When I build the site
|
|
18
|
+
Then the output file "styles.css" should have content:
|
|
19
|
+
"""
|
|
20
|
+
.test .nested {
|
|
21
|
+
attribute: value; }
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
Scenario: Makes Compass available
|
|
25
|
+
Given a file named "styles.scss" with content:
|
|
26
|
+
"""
|
|
27
|
+
@import "compass/css3";
|
|
28
|
+
"""
|
|
29
|
+
When I build the site
|
|
30
|
+
Then the output file "styles.css" should exist
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'rake-pipeline'
|
|
3
|
+
require 'benoit/filters/base_filter'
|
|
4
|
+
require 'benoit/page'
|
|
5
|
+
|
|
6
|
+
describe Benoit::Filters::BaseFilter do
|
|
7
|
+
MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
|
|
8
|
+
MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
|
|
9
|
+
|
|
10
|
+
let(:basic_filter) do
|
|
11
|
+
Class.new(described_class)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
let(:html_input) { "<html><head></head><body><h1>TESTING</h1></body></html>" }
|
|
15
|
+
|
|
16
|
+
def input_file(name, content)
|
|
17
|
+
MemoryFileWrapper.new("/path/to/input", name, "UTF-8", Set.new([]), content)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def output_file(name)
|
|
21
|
+
MemoryFileWrapper.new("/path/to/output", name, "UTF-8", Set.new([]))
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def setup_filter(filter, input_filename='index.html')
|
|
25
|
+
filter.file_wrapper_class = MemoryFileWrapper
|
|
26
|
+
filter.manifest = MemoryManifest.new
|
|
27
|
+
filter.last_manifest = MemoryManifest.new
|
|
28
|
+
filter.input_files = [input_file(input_filename, html_input)]
|
|
29
|
+
filter.output_root= "/path/to/output"
|
|
30
|
+
filter.rake_application = Rake::Application.new
|
|
31
|
+
filter.current_site = {}
|
|
32
|
+
filter
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def setup_final_outputs(filter)
|
|
36
|
+
filter.input_files.each_with_index do |input,i|
|
|
37
|
+
output = filter.output_files[i]
|
|
38
|
+
filter.current_site.merge!(input.path => { "content" => input.read })
|
|
39
|
+
filter.current_site.merge!(output.path => { "content" => input.read })
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "generates output directly from the input" do
|
|
44
|
+
filter = setup_filter basic_filter.new
|
|
45
|
+
|
|
46
|
+
expect(filter.output_files).to eq([output_file("index.html")])
|
|
47
|
+
|
|
48
|
+
setup_final_outputs(filter)
|
|
49
|
+
|
|
50
|
+
tasks = filter.generate_rake_tasks
|
|
51
|
+
tasks.each(&:invoke)
|
|
52
|
+
|
|
53
|
+
file = MemoryFileWrapper.files["/path/to/output/index.html"]
|
|
54
|
+
expect(file.body).to eq(html_input)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
describe "building output" do
|
|
58
|
+
|
|
59
|
+
let(:builder_filter) do
|
|
60
|
+
Class.new(described_class) do
|
|
61
|
+
build_output do
|
|
62
|
+
"blah"
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
let(:page_filter) do
|
|
68
|
+
Class.new(described_class) do
|
|
69
|
+
build_output do |page|
|
|
70
|
+
page["content"]
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
let(:path_writer) do
|
|
76
|
+
Class.new(described_class) do
|
|
77
|
+
build_output do |page,input|
|
|
78
|
+
input.path
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "gets output from calling builder" do
|
|
84
|
+
filter = setup_filter builder_filter.new
|
|
85
|
+
|
|
86
|
+
setup_final_outputs(filter)
|
|
87
|
+
|
|
88
|
+
tasks = filter.generate_rake_tasks
|
|
89
|
+
tasks.each(&:invoke)
|
|
90
|
+
|
|
91
|
+
file = MemoryFileWrapper.files["/path/to/output/index.html"]
|
|
92
|
+
expect(file.body).to eq("blah")
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "passes page object to builder" do
|
|
96
|
+
filter = setup_filter page_filter.new
|
|
97
|
+
|
|
98
|
+
setup_final_outputs(filter)
|
|
99
|
+
|
|
100
|
+
page = filter.current_site[filter.output_files.first.path]
|
|
101
|
+
|
|
102
|
+
tasks = filter.generate_rake_tasks
|
|
103
|
+
tasks.each(&:invoke)
|
|
104
|
+
|
|
105
|
+
file = MemoryFileWrapper.files["/path/to/output/index.html"]
|
|
106
|
+
expect(file.body).to eq(page["content"])
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it "passes input to builder when needed" do
|
|
110
|
+
filter = setup_filter path_writer.new
|
|
111
|
+
input = filter.input_files.first
|
|
112
|
+
|
|
113
|
+
setup_final_outputs(filter)
|
|
114
|
+
|
|
115
|
+
tasks = filter.generate_rake_tasks
|
|
116
|
+
tasks.each(&:invoke)
|
|
117
|
+
|
|
118
|
+
file = MemoryFileWrapper.files["/path/to/output/index.html"]
|
|
119
|
+
expect(file.body).to eq(input.path)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
describe "generating output filename" do
|
|
125
|
+
|
|
126
|
+
let(:output_name) do
|
|
127
|
+
Class.new(described_class) do
|
|
128
|
+
output_name do
|
|
129
|
+
"blah.diddy"
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it "gets output filename from calling generator" do
|
|
135
|
+
filter = setup_filter output_name.new
|
|
136
|
+
|
|
137
|
+
expect(filter.output_files).to eq([output_file("blah.diddy")])
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'rake-pipeline'
|
|
3
|
+
require 'benoit/filters'
|
|
4
|
+
require 'benoit/page'
|
|
5
|
+
|
|
6
|
+
describe Benoit::Filters::MarkdownFilter do
|
|
7
|
+
MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
|
|
8
|
+
MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
|
|
9
|
+
|
|
10
|
+
let(:markdown_input) {
|
|
11
|
+
<<-EOS.unindent
|
|
12
|
+
[some link](http://www.example.com)
|
|
13
|
+
|
|
14
|
+
**strong**
|
|
15
|
+
_em_
|
|
16
|
+
EOS
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let(:expected_output) {
|
|
20
|
+
<<-EOS.unindent
|
|
21
|
+
<p><a href="http://www.example.com">some link</a></p>
|
|
22
|
+
|
|
23
|
+
<p><strong>strong</strong>
|
|
24
|
+
<em>em</em></p>
|
|
25
|
+
EOS
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
def input_file(name, content)
|
|
29
|
+
MemoryFileWrapper.new("/path/to/input", name, "UTF-8", Set.new([]), content)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def output_file(name)
|
|
33
|
+
MemoryFileWrapper.new("/path/to/output", name, "UTF-8", Set.new([]))
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def setup_filter(filter, input_filename='page.markdown')
|
|
37
|
+
filter.file_wrapper_class = MemoryFileWrapper
|
|
38
|
+
filter.manifest = MemoryManifest.new
|
|
39
|
+
filter.last_manifest = MemoryManifest.new
|
|
40
|
+
filter.input_files = [input_file(input_filename, markdown_input)]
|
|
41
|
+
filter.output_root= "/path/to/output"
|
|
42
|
+
filter.rake_application = Rake::Application.new
|
|
43
|
+
filter
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "generates the correct output" do
|
|
47
|
+
filter = setup_filter described_class.new
|
|
48
|
+
|
|
49
|
+
input_file = filter.input_files.first
|
|
50
|
+
output_file = output_file("page.html")
|
|
51
|
+
|
|
52
|
+
page = { "content" => markdown_input }
|
|
53
|
+
filter.current_site = { input_file.path => page, output_file.path => page }
|
|
54
|
+
|
|
55
|
+
expect(filter.output_files).to eq([output_file])
|
|
56
|
+
|
|
57
|
+
tasks = filter.generate_rake_tasks
|
|
58
|
+
tasks.each(&:invoke)
|
|
59
|
+
|
|
60
|
+
file = MemoryFileWrapper.files["/path/to/output/page.html"]
|
|
61
|
+
expect(file.body).to eq(expected_output)
|
|
62
|
+
|
|
63
|
+
expect(page["content"]).to eq(expected_output)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'rake-pipeline'
|
|
3
|
+
require 'benoit/filters'
|
|
4
|
+
require 'benoit/page'
|
|
5
|
+
require 'benoit/compiler_error'
|
|
6
|
+
|
|
7
|
+
describe Benoit::Filters::SassFilter do
|
|
8
|
+
MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
|
|
9
|
+
MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
|
|
10
|
+
FileWrapper ||= Rake::Pipeline::FileWrapper
|
|
11
|
+
|
|
12
|
+
let(:scss_input_path) {
|
|
13
|
+
File.expand_path("spec/support/files/input.scss")
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let(:expected_output) {
|
|
17
|
+
str =
|
|
18
|
+
<<-EOS
|
|
19
|
+
.test .nested {
|
|
20
|
+
attribute: value; }
|
|
21
|
+
EOS
|
|
22
|
+
str.unindent
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
def input_file
|
|
26
|
+
path = scss_input_path
|
|
27
|
+
FileWrapper.new(File.dirname(path), File.basename(path), "UTF-8", Set.new([]))
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def output_file(name)
|
|
31
|
+
MemoryFileWrapper.new("/path/to/output", name, "UTF-8", Set.new([]))
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def setup_filter(filter)
|
|
35
|
+
filter.file_wrapper_class = MemoryFileWrapper
|
|
36
|
+
filter.manifest = MemoryManifest.new
|
|
37
|
+
filter.last_manifest = MemoryManifest.new
|
|
38
|
+
filter.input_files = [input_file]
|
|
39
|
+
filter.output_root= "/path/to/output"
|
|
40
|
+
filter.rake_application = Rake::Application.new
|
|
41
|
+
filter
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "generates the correct output" do
|
|
45
|
+
filter = setup_filter described_class.new
|
|
46
|
+
|
|
47
|
+
input_file = filter.input_files.first
|
|
48
|
+
output_file = output_file("input.css")
|
|
49
|
+
|
|
50
|
+
expect(filter.output_files).to eq([output_file])
|
|
51
|
+
|
|
52
|
+
tasks = filter.generate_rake_tasks
|
|
53
|
+
tasks.each(&:invoke)
|
|
54
|
+
|
|
55
|
+
file = MemoryFileWrapper.files["/path/to/output/input.css"]
|
|
56
|
+
expect(file.body).to eq(expected_output)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe "files ending in .css.scss" do
|
|
60
|
+
|
|
61
|
+
let(:scss_input_path) {
|
|
62
|
+
File.expand_path("spec/support/files/input.css.scss")
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
it "do not end in .css.css" do
|
|
66
|
+
filter = setup_filter described_class.new
|
|
67
|
+
|
|
68
|
+
output_file = output_file("input.css")
|
|
69
|
+
expect(filter.output_files).to eq([output_file])
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
end
|