benoit 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,10 @@
|
|
1
|
+
require 'rake-pipeline/middleware'
|
2
|
+
|
3
|
+
Rails.configuration.after_initialize do
|
4
|
+
if defined?(RAKEP_ENABLED) && RAKEP_ENABLED
|
5
|
+
assetfile = defined?(RAKEP_ASSETFILE) ? RAKEP_ASSETFILE : 'Assetfile'
|
6
|
+
project = Rake::Pipeline::Project.new assetfile
|
7
|
+
|
8
|
+
Rails.configuration.middleware.use Rake::Pipeline::Middleware, project
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "rake-pipeline/middleware"
|
2
|
+
|
3
|
+
module Rake
|
4
|
+
class Pipeline
|
5
|
+
# Use Rake::Pipeline inside of Rails 3.x. To use, simply add
|
6
|
+
# Rake::Pipeline to your +Gemfile+:
|
7
|
+
#
|
8
|
+
# !!!ruby
|
9
|
+
# gem 'rake-pipeline'
|
10
|
+
#
|
11
|
+
# Then, activate it in development mode. In config/development.rb:
|
12
|
+
#
|
13
|
+
# !!!ruby
|
14
|
+
# config.rake_pipeline_enabled = true
|
15
|
+
#
|
16
|
+
class Railtie < ::Rails::Railtie
|
17
|
+
config.rake_pipeline_enabled = false
|
18
|
+
config.rake_pipeline_assetfile = 'Assetfile'
|
19
|
+
|
20
|
+
rake_tasks do
|
21
|
+
load "rake-pipeline/precompile.rake"
|
22
|
+
end
|
23
|
+
|
24
|
+
initializer "rake-pipeline.assetfile" do |app|
|
25
|
+
if config.rake_pipeline_enabled
|
26
|
+
assetfile = File.join(Rails.root, config.rake_pipeline_assetfile)
|
27
|
+
project = Rake::Pipeline::Project.new assetfile
|
28
|
+
|
29
|
+
config.app_middleware.insert ActionDispatch::Static, Rake::Pipeline::Middleware, project
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Rake
|
2
|
+
class Pipeline
|
3
|
+
# A RejectMatcher is a pipeline that does no processing. It
|
4
|
+
# simply filters out some files. You can use this when
|
5
|
+
# you have more complex logic that doesn't fit nicely
|
6
|
+
# in a glob.
|
7
|
+
#
|
8
|
+
# You can pass a block or a glob (just like {DSL#match}).
|
9
|
+
# Files matching the glob will be rejected from the pipeline.
|
10
|
+
# Files are rejected when the block evaluates to true. Specify
|
11
|
+
# either a glob or a block.
|
12
|
+
#
|
13
|
+
# In general, you should not use RejectMatcher directly. Instead use
|
14
|
+
# {DSL#reject} in the block passed to {Pipeline.build}.
|
15
|
+
class RejectMatcher < Matcher
|
16
|
+
attr_accessor :block
|
17
|
+
|
18
|
+
def output_files
|
19
|
+
input_files.reject do |file|
|
20
|
+
if block
|
21
|
+
block.call file
|
22
|
+
else
|
23
|
+
file.path =~ @pattern
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "rake-pipeline/middleware"
|
2
|
+
require "rack/server"
|
3
|
+
|
4
|
+
module Rake
|
5
|
+
class Pipeline
|
6
|
+
class Server < Rack::Server
|
7
|
+
def app
|
8
|
+
not_found = proc { [404, { "Content-Type" => "text/plain" }, ["not found"]] }
|
9
|
+
project = Rake::Pipeline::Project.new "Assetfile"
|
10
|
+
|
11
|
+
Middleware.new(not_found, project)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Rake
|
2
|
+
class Pipeline
|
3
|
+
class SortedPipeline < Pipeline
|
4
|
+
attr_accessor :pipeline, :comparator
|
5
|
+
|
6
|
+
def output_files
|
7
|
+
input_files.sort(&comparator)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Override {Pipeline#finalize} to do nothing. We want to pass
|
11
|
+
# on our unmatched inputs to the next part of the pipeline.
|
12
|
+
#
|
13
|
+
# @return [void]
|
14
|
+
# @api private
|
15
|
+
def finalize
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/rake-pipeline/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Yehuda Katz", "Tom Dale"]
|
6
|
+
gem.email = ["wycats@gmail.com"]
|
7
|
+
gem.description = "Simple Asset Management"
|
8
|
+
gem.summary = "Simple Asset Management"
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "rake-pipeline"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Rake::Pipeline::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency "rake", "~> 0.9.0"
|
19
|
+
gem.add_dependency "thor"
|
20
|
+
gem.add_dependency "json"
|
21
|
+
|
22
|
+
gem.add_development_dependency "rspec"
|
23
|
+
gem.add_development_dependency "rack-test"
|
24
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require "rake-pipeline/cli"
|
2
|
+
|
3
|
+
describe "Rake::Pipeline::CLI" do
|
4
|
+
attr_reader :project, :pipeline
|
5
|
+
|
6
|
+
before do
|
7
|
+
@project = Rake::Pipeline::Project.new
|
8
|
+
@project.stub(:clean)
|
9
|
+
@project.stub(:invoke)
|
10
|
+
@project.stub(:output_files).and_return([])
|
11
|
+
Rake::Pipeline::Project.stub(:new).and_return(@project)
|
12
|
+
end
|
13
|
+
|
14
|
+
def rakep(*args)
|
15
|
+
Rake::Pipeline::CLI.start(args)
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "build" do
|
19
|
+
context "with no arguments" do
|
20
|
+
it "invokes a project" do
|
21
|
+
project.should_receive :invoke
|
22
|
+
rakep "build"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "cleans up the tmpdir" do
|
26
|
+
project.should_receive :cleanup_tmpdir
|
27
|
+
rakep "build"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "with a --pretend argument" do
|
32
|
+
it "doesn't invoke a project" do
|
33
|
+
project.should_not_receive :invoke
|
34
|
+
rakep "build", "--pretend"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "with a --clean argument" do
|
39
|
+
it "cleans a project" do
|
40
|
+
project.should_receive :clean
|
41
|
+
rakep "build", "--clean"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "invokes a project" do
|
45
|
+
project.should_receive :invoke
|
46
|
+
rakep "build", "--clean"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "clean" do
|
52
|
+
context "with no arguments" do
|
53
|
+
it "cleans a project" do
|
54
|
+
project.should_receive :clean
|
55
|
+
rakep "clean"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "server" do
|
61
|
+
let(:server) { double "server" }
|
62
|
+
|
63
|
+
before do
|
64
|
+
require 'rake-pipeline/server'
|
65
|
+
Rake::Pipeline::Server.stub(:new).and_return(server)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "starts a Rake::Pipeline::Server" do
|
69
|
+
server.should_receive :start
|
70
|
+
rakep "server"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
describe "ConcatFilter" do
|
2
|
+
MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
|
3
|
+
MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
|
4
|
+
|
5
|
+
let(:input_files) {
|
6
|
+
[
|
7
|
+
MemoryFileWrapper.new("/path/to/input", "javascripts/jquery.js", "UTF-8", [], "jQuery = {};"),
|
8
|
+
MemoryFileWrapper.new("/path/to/input", "javascripts/sproutcore.js", "UTF-8", [], "SC = {};")
|
9
|
+
]
|
10
|
+
}
|
11
|
+
|
12
|
+
it "generates output" do
|
13
|
+
filter = Rake::Pipeline::ConcatFilter.new { "application.js" }
|
14
|
+
filter.manifest = MemoryManifest.new
|
15
|
+
filter.last_manifest = MemoryManifest.new
|
16
|
+
filter.file_wrapper_class = MemoryFileWrapper
|
17
|
+
filter.output_root = "/path/to/output"
|
18
|
+
filter.input_files = input_files
|
19
|
+
|
20
|
+
filter.output_files.should == [MemoryFileWrapper.new("/path/to/output", "application.js", "BINARY", [])]
|
21
|
+
|
22
|
+
tasks = filter.generate_rake_tasks
|
23
|
+
tasks.each(&:invoke)
|
24
|
+
|
25
|
+
file = MemoryFileWrapper.files["/path/to/output/application.js"]
|
26
|
+
file.body.should == "jQuery = {};SC = {};"
|
27
|
+
file.encoding.should == "BINARY"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "accepts a string to use as the output file name" do
|
31
|
+
filter = Rake::Pipeline::ConcatFilter.new("app.js")
|
32
|
+
filter.file_wrapper_class = MemoryFileWrapper
|
33
|
+
filter.output_root = "/path/to/output"
|
34
|
+
filter.input_files = input_files
|
35
|
+
filter.output_files.should == [MemoryFileWrapper.new("/path/to/output", "app.js", "BINARY", [])]
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
describe "Rake::Pipeline::PipelineDSL" do
|
2
|
+
ConcatFilter = Rake::Pipeline::SpecHelpers::Filters::ConcatFilter
|
3
|
+
|
4
|
+
let(:pipeline) { Rake::Pipeline.new }
|
5
|
+
let(:dsl) { Rake::Pipeline::DSL::PipelineDSL.new(pipeline) }
|
6
|
+
|
7
|
+
def filter
|
8
|
+
pipeline.filters.last
|
9
|
+
end
|
10
|
+
|
11
|
+
it "accepts a pipeline in its constructor" do
|
12
|
+
dsl.pipeline.should == pipeline
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#input" do
|
16
|
+
it "adds an input to the pipeline" do
|
17
|
+
dsl.input "/app"
|
18
|
+
pipeline.inputs["/app"].should == '**/*'
|
19
|
+
end
|
20
|
+
|
21
|
+
it "configures the input's glob" do
|
22
|
+
dsl.input "/app", "*.js"
|
23
|
+
pipeline.inputs['/app'].should == "*.js"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "defaults input's glob to **/*" do
|
27
|
+
dsl.input "/app"
|
28
|
+
pipeline.inputs['/app'].should == "**/*"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#filter" do
|
33
|
+
|
34
|
+
it "adds a new instance of the filter class to the pipeline's filters" do
|
35
|
+
pipeline.filters.should be_empty
|
36
|
+
dsl.filter ConcatFilter
|
37
|
+
pipeline.filters.should_not be_empty
|
38
|
+
filter.should be_kind_of(ConcatFilter)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "takes a block to configure the filter's output file names" do
|
42
|
+
generator = proc { |input| "main.js" }
|
43
|
+
dsl.filter(ConcatFilter, &generator)
|
44
|
+
filter.output_name_generator.should == generator
|
45
|
+
end
|
46
|
+
|
47
|
+
it "passes any extra arguments to the filter's constructor" do
|
48
|
+
filter_class = Class.new(Rake::Pipeline::Filter) do
|
49
|
+
attr_reader :args
|
50
|
+
def initialize(*args)
|
51
|
+
@args = args
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
dsl.filter filter_class, "foo", "bar"
|
56
|
+
filter.args.should == %w(foo bar)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#match" do
|
61
|
+
it "creates a Matcher for the given glob" do
|
62
|
+
matcher = dsl.match("*.glob") {}
|
63
|
+
matcher.should be_kind_of(Rake::Pipeline::Matcher)
|
64
|
+
matcher.glob.should == "*.glob"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "adds the new matcher to the pipeline's filters" do
|
68
|
+
matcher = dsl.match("*.glob") {}
|
69
|
+
filter.should == matcher
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "#output" do
|
74
|
+
it "configures the pipeline's output_root" do
|
75
|
+
dsl.output "/path/to/output"
|
76
|
+
pipeline.output_root.should == "/path/to/output"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "#concat" do
|
81
|
+
it "creates a ConcatFilter" do
|
82
|
+
dsl.concat "octopus"
|
83
|
+
filter.should be_kind_of(Rake::Pipeline::ConcatFilter)
|
84
|
+
end
|
85
|
+
|
86
|
+
context "passed an Array first argument" do
|
87
|
+
it "creates an OrderingConcatFilter" do
|
88
|
+
dsl.concat ["octopus"]
|
89
|
+
filter.should be_kind_of(Rake::Pipeline::OrderingConcatFilter)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "#sort" do
|
95
|
+
it "adds a SortedPipeline for the given comparator" do
|
96
|
+
comparator = proc { }
|
97
|
+
matcher = dsl.sort(&comparator)
|
98
|
+
matcher.should be_kind_of(Rake::Pipeline::SortedPipeline)
|
99
|
+
matcher.comparator.should == comparator
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "#copy" do
|
104
|
+
it "creates a ConcatFilter" do
|
105
|
+
dsl.copy
|
106
|
+
filter.should be_kind_of(Rake::Pipeline::ConcatFilter)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "#reject" do
|
111
|
+
it "creates a new RejectMatcher for the given glob" do
|
112
|
+
matcher = dsl.reject("*.glob") {}
|
113
|
+
matcher.should be_kind_of(Rake::Pipeline::RejectMatcher)
|
114
|
+
matcher.glob.should == "*.glob"
|
115
|
+
end
|
116
|
+
|
117
|
+
it "creates a new RejectMatcher with the given block" do
|
118
|
+
block = proc { }
|
119
|
+
matcher = dsl.reject(&block)
|
120
|
+
matcher.should be_kind_of(Rake::Pipeline::RejectMatcher)
|
121
|
+
matcher.block.should == block
|
122
|
+
end
|
123
|
+
|
124
|
+
it "adds the new reject matcher to the pipeline's filters" do
|
125
|
+
matcher = dsl.reject("*.glob") {}
|
126
|
+
filter.should == matcher
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "#skip" do
|
131
|
+
it "adds a new RejectMatcher" do
|
132
|
+
dsl.skip "*.glob"
|
133
|
+
filter.should be_kind_of(Rake::Pipeline::RejectMatcher)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe "#exclude" do
|
138
|
+
it "adds a new RejectMatcher" do
|
139
|
+
dsl.exclude "*.glob"
|
140
|
+
filter.should be_kind_of(Rake::Pipeline::RejectMatcher)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe "#gsub" do
|
145
|
+
it "creates a GsubFilter" do
|
146
|
+
dsl.gsub
|
147
|
+
filter.should be_kind_of(Rake::Pipeline::GsubFilter)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe "#replace" do
|
152
|
+
it "creates a GsubFilter" do
|
153
|
+
dsl.replace
|
154
|
+
filter.should be_kind_of(Rake::Pipeline::GsubFilter)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe "#strip" do
|
159
|
+
it "creates a GsubFilter with no replacement" do
|
160
|
+
regex = /mock/
|
161
|
+
dsl.should_receive(:filter).with(Rake::Pipeline::GsubFilter, regex, '')
|
162
|
+
dsl.strip /mock/
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
describe "Rake::Pipeline::ProjectDSL" do
|
2
|
+
ConcatFilter ||= Rake::Pipeline::SpecHelpers::Filters::ConcatFilter
|
3
|
+
|
4
|
+
let(:project) { Rake::Pipeline::Project.new }
|
5
|
+
let(:dsl) { Rake::Pipeline::DSL::ProjectDSL.new(project) }
|
6
|
+
|
7
|
+
it "accepts a project in its constructor" do
|
8
|
+
dsl.project.should == project
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#output" do
|
12
|
+
it "configures the project's default_output_root" do
|
13
|
+
dsl.output "/path/to/output"
|
14
|
+
project.default_output_root.should == "/path/to/output"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#tmpdir" do
|
19
|
+
it "sets the project's tmpdir" do
|
20
|
+
dsl.tmpdir "/path/to/tmpdir"
|
21
|
+
project.tmpdir.should == "/path/to/tmpdir"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#input" do
|
26
|
+
it "uses Project#build_pipeline to add a new pipeline to the project" do
|
27
|
+
project.should_receive(:build_pipeline)
|
28
|
+
dsl.input("app") {}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#map" do
|
33
|
+
it "saves the block in a hash on the project" do
|
34
|
+
project.maps.keys.size.should == 0
|
35
|
+
run_me = lambda { }
|
36
|
+
dsl.map("foo", &run_me)
|
37
|
+
dsl.project.maps["foo"].should == run_me
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|