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,81 @@
|
|
1
|
+
require 'rake-pipeline'
|
2
|
+
|
3
|
+
module Rake
|
4
|
+
class Pipeline
|
5
|
+
class FileWrapper
|
6
|
+
include Benoit::FileWrapperExtensions
|
7
|
+
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module Benoit
|
13
|
+
class PipelineProject
|
14
|
+
attr_reader :assetfile_path, :output_dir, :tmp_cache_dir, :project
|
15
|
+
|
16
|
+
def initialize(assetfile_path, output_dir=nil, tmp_cache_dir=nil)
|
17
|
+
@assetfile_path = assetfile_path
|
18
|
+
@output_dir = output_dir || default_output_dir
|
19
|
+
@tmp_cache_dir = tmp_cache_dir || default_cache_dir
|
20
|
+
@project = build_project!
|
21
|
+
end
|
22
|
+
|
23
|
+
def invoke
|
24
|
+
if Benoit.config.clean_before_build?
|
25
|
+
Benoit::Cleaner.run
|
26
|
+
end
|
27
|
+
project.pipelines.each do |pipeline|
|
28
|
+
pipeline.register_invocation_hook :after_task, BuildNotifiers::FileBuiltNotifier
|
29
|
+
pipeline.register_invocation_hook :before_filter, BuildNotifiers::ProgressNotifier
|
30
|
+
pipeline.register_invocation_hook :filters_ready, ->(pipeline){
|
31
|
+
require 'ostruct'
|
32
|
+
paths_map = {}
|
33
|
+
pipeline.output_files.each do |output|
|
34
|
+
input = output.original_inputs.first
|
35
|
+
|
36
|
+
wrapper = OpenStruct.new(path: output.path, read: input.read, fullpath: input.fullpath)
|
37
|
+
|
38
|
+
paths_map[input.path] = output.path
|
39
|
+
|
40
|
+
PageMetadata::Store.current[wrapper]
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
current_site = CurrentSite.load
|
45
|
+
|
46
|
+
current_site.paths_map = paths_map
|
47
|
+
|
48
|
+
# Load ALL filters (including filters within filters)
|
49
|
+
filters = recursively_load_filters_from_pipeline(pipeline)
|
50
|
+
filters.each do |filter|
|
51
|
+
if filter.respond_to? :current_site=
|
52
|
+
filter.current_site = current_site
|
53
|
+
end
|
54
|
+
end
|
55
|
+
}
|
56
|
+
end
|
57
|
+
project.invoke
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def recursively_load_filters_from_pipeline(pipeline)
|
63
|
+
pipeline.filters.map do |filter|
|
64
|
+
if filter.respond_to? :filters
|
65
|
+
recursively_load_filters_from_pipeline(filter)
|
66
|
+
else
|
67
|
+
filter
|
68
|
+
end
|
69
|
+
end.flatten
|
70
|
+
end
|
71
|
+
|
72
|
+
def build_project!
|
73
|
+
output, tmp = [output_dir, tmp_cache_dir]
|
74
|
+
Rake::Pipeline::Project.new(@assetfile_path) do
|
75
|
+
output output
|
76
|
+
tmpdir tmp if tmp
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
#
|
2
|
+
# LoadsSiteContent.rb
|
3
|
+
# Benoit
|
4
|
+
#
|
5
|
+
# Created by Joseph Fiorini on 10/22/12.
|
6
|
+
# Copyright 2012 densitypop. All rights reserved.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'json'
|
10
|
+
require 'inflecto'
|
11
|
+
require 'cadenza/context_object'
|
12
|
+
|
13
|
+
module Benoit
|
14
|
+
class SiteContext
|
15
|
+
|
16
|
+
class ContextObject < ::Cadenza::ContextObject
|
17
|
+
def initialize(site)
|
18
|
+
@site = site
|
19
|
+
@pages = site.pages
|
20
|
+
end
|
21
|
+
|
22
|
+
def lookup_resource_collection(name)
|
23
|
+
singular_name = Inflecto.singularize(name)
|
24
|
+
collection = @pages.select do |page|
|
25
|
+
page["_type"] == singular_name
|
26
|
+
end
|
27
|
+
|
28
|
+
collection.map!(&:to_hash)
|
29
|
+
end
|
30
|
+
|
31
|
+
def paginated_collection(name)
|
32
|
+
potential_collection = @site.paginated_collections[name].last
|
33
|
+
if potential_collection.respond_to? :at_end?
|
34
|
+
potential_collection.rewind_list! if potential_collection.at_end?
|
35
|
+
return potential_collection
|
36
|
+
end
|
37
|
+
|
38
|
+
per_page = @site.paginated_collections[name].first
|
39
|
+
collection = lookup_resource_collection(name)
|
40
|
+
|
41
|
+
collection.paginate(per_page).tap do |coll|
|
42
|
+
@site.paginated_collections[name] << coll
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def resource_collection(name)
|
47
|
+
lookup_resource_collection(name)
|
48
|
+
end
|
49
|
+
|
50
|
+
def method_missing(msg,*args)
|
51
|
+
name = msg.to_s
|
52
|
+
parsed_name = Inflecto.singularize(name).sub(/paginated_/, "")
|
53
|
+
|
54
|
+
valid_page = @pages.any? { |page| page.has_value?(parsed_name) }
|
55
|
+
|
56
|
+
if valid_page and name.start_with? "paginated_"
|
57
|
+
return paginated_collection(parsed_name)
|
58
|
+
elsif valid_page
|
59
|
+
return resource_collection(name)
|
60
|
+
else
|
61
|
+
super
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
alias_method :missing_context_method, :method_missing
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.from_hash(context_attrs)
|
70
|
+
page_contexts = context_attrs.values.map do |context|
|
71
|
+
Page.from_hash(context)
|
72
|
+
end
|
73
|
+
new(page_contexts)
|
74
|
+
end
|
75
|
+
|
76
|
+
attr_reader :pages
|
77
|
+
|
78
|
+
attr_accessor :paths_map
|
79
|
+
|
80
|
+
def initialize(pages)
|
81
|
+
@pages = pages
|
82
|
+
end
|
83
|
+
|
84
|
+
def [](key)
|
85
|
+
key = paths_map[key] if paths_map.key?(key)
|
86
|
+
page_with_path(key)
|
87
|
+
end
|
88
|
+
|
89
|
+
def page_with_path(path)
|
90
|
+
@pages.find do |page|
|
91
|
+
page.permalink == "/#{path}"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def to_context
|
96
|
+
@context ||= ContextObject.new(self)
|
97
|
+
end
|
98
|
+
|
99
|
+
def paginated_collections
|
100
|
+
self.class.paginated_collections
|
101
|
+
end
|
102
|
+
|
103
|
+
def paginated_collection?(key)
|
104
|
+
unless self.class.paginated_collections.nil?
|
105
|
+
self.class.paginated_collections.key?(key)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def self.paginate_collection(collection, per_page)
|
110
|
+
@paginated_collections ||= Hash.new([])
|
111
|
+
@paginated_collections[collection] << per_page
|
112
|
+
end
|
113
|
+
|
114
|
+
def self.paginated_collections
|
115
|
+
@paginated_collections
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.clear_paginated_collections!
|
119
|
+
@paginated_collections.clear if @paginated_collections
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#
|
2
|
+
# TemplateLayoutLookup.rb
|
3
|
+
# Benoit
|
4
|
+
#
|
5
|
+
# Created by Joseph Fiorini on 10/29/12.
|
6
|
+
# Copyright 2012 densitypop. All rights reserved.
|
7
|
+
#
|
8
|
+
|
9
|
+
def FindsLayoutsForTemplate(input, options={})
|
10
|
+
Benoit::Utils::FindsLayoutsForTemplate.new(input, options).lookup_layouts
|
11
|
+
end
|
12
|
+
|
13
|
+
module Benoit::Utils
|
14
|
+
|
15
|
+
|
16
|
+
class FindsLayoutsForTemplate
|
17
|
+
|
18
|
+
|
19
|
+
FrontMatterLookupStrategy = ->(input) {
|
20
|
+
input =
|
21
|
+
if input.respond_to? :final_output and input.final_output
|
22
|
+
input.final_output
|
23
|
+
else
|
24
|
+
input
|
25
|
+
end
|
26
|
+
metadata = Benoit::PageMetadata::Store.current[input]
|
27
|
+
return unless metadata
|
28
|
+
metadata["layout"] || metadata["template"]
|
29
|
+
}
|
30
|
+
|
31
|
+
CadenzaInheritanceLookupStrategy = ->(input) {
|
32
|
+
extends_pattern = /\{% extends "([\.\w_-]+)" %\}/
|
33
|
+
return unless File.exist?(input.path)
|
34
|
+
match_data = File.read(input.path).match(extends_pattern)
|
35
|
+
return unless match_data
|
36
|
+
match_data.captures[0]
|
37
|
+
}
|
38
|
+
|
39
|
+
attr_reader :root, :template_path, :load_paths, :input
|
40
|
+
|
41
|
+
def initialize(input, options)
|
42
|
+
@load_paths = options.delete(:load_paths) || [""]
|
43
|
+
@root = options.delete(:root)
|
44
|
+
@template_path = input
|
45
|
+
@input = input
|
46
|
+
end
|
47
|
+
|
48
|
+
def lookup_layouts
|
49
|
+
recursively_lookup_layouts_for_file(input)
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def recursively_lookup_layouts_for_file(input, template_list=[])
|
55
|
+
|
56
|
+
parent_template = call_strategy_for_file input, root
|
57
|
+
|
58
|
+
if parent_template
|
59
|
+
normalized_path = NormalizesPathToTemplate(parent_template, load_paths)
|
60
|
+
template_list << normalized_path
|
61
|
+
input = Rake::Pipeline::FileWrapper.new(Dir.pwd, normalized_path)
|
62
|
+
# TODO: Not a fan of Dir.pwd here, but it will always work. Is there a better way to get the correct input root?
|
63
|
+
recursively_lookup_layouts_for_file(input, template_list)
|
64
|
+
end
|
65
|
+
|
66
|
+
template_list
|
67
|
+
end
|
68
|
+
|
69
|
+
def call_strategy_for_file(input, root)
|
70
|
+
strategies = [FrontMatterLookupStrategy]
|
71
|
+
strategies.inject(nil) do |parent_template,strategy|
|
72
|
+
strategy.call(input) || parent_template
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#
|
2
|
+
# NormalizesPathToTemplate.rb
|
3
|
+
# Benoit
|
4
|
+
#
|
5
|
+
# Created by Joseph Fiorini on 10/29/12.
|
6
|
+
# Copyright 2012 densitypop. All rights reserved.
|
7
|
+
#
|
8
|
+
|
9
|
+
def NormalizesPathToTemplate(template, load_paths)
|
10
|
+
Benoit::Utils::NormalizesPathToTemplate.new(template, load_paths).
|
11
|
+
normalize_path
|
12
|
+
end
|
13
|
+
|
14
|
+
module Benoit
|
15
|
+
module Utils
|
16
|
+
class NormalizesPathToTemplate
|
17
|
+
attr_accessor :template_path, :load_paths
|
18
|
+
|
19
|
+
def initialize(template_path, load_paths)
|
20
|
+
@template_path = template_path
|
21
|
+
@load_paths = load_paths
|
22
|
+
end
|
23
|
+
|
24
|
+
def normalize_path
|
25
|
+
return template_path if File.exist?(template_path) # Already normalized, just return it
|
26
|
+
load_paths.inject(template_path) do |actual_path,load_path|
|
27
|
+
path_to_try = actual_path
|
28
|
+
if not File.basename(path_to_try).start_with? "_"
|
29
|
+
path_to_try = File.join(File.dirname(path_to_try), "_#{File.basename(path_to_try)}")
|
30
|
+
end
|
31
|
+
path_to_try += ".html" unless File.extname(path_to_try) == ".html"
|
32
|
+
return path_to_try if File.exist?(path_to_try)
|
33
|
+
path_to_try = File.join(load_path, path_to_try)
|
34
|
+
if File.exist?(path_to_try)
|
35
|
+
path_to_try
|
36
|
+
else
|
37
|
+
actual_path
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module Enumerable
|
2
|
+
def paginate(per_page)
|
3
|
+
Benoit::Utils::PaginatedList.new(self, per_page)
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
module Benoit
|
8
|
+
module Utils
|
9
|
+
class PaginatedList
|
10
|
+
include Enumerable
|
11
|
+
|
12
|
+
attr_reader :per_page, :ops, :source, :enum
|
13
|
+
|
14
|
+
def initialize(list, per_page=nil, &block)
|
15
|
+
@ops = []
|
16
|
+
@list = list
|
17
|
+
@per_page = per_page
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def each(&block)
|
22
|
+
run_queued_operations!
|
23
|
+
return paginate! && @enum unless block_given?
|
24
|
+
paginated.each do |page|
|
25
|
+
block.call(page)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def each_with_index(&block)
|
30
|
+
run_queued_operations!
|
31
|
+
paginated.each_with_index do |p,i|
|
32
|
+
block.call(p, i)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def paginate!
|
37
|
+
@enum ||= @list.each_slice(@per_page)
|
38
|
+
end
|
39
|
+
|
40
|
+
def paginated
|
41
|
+
paginate!
|
42
|
+
@enum.next
|
43
|
+
end
|
44
|
+
|
45
|
+
def sort_by(&block)
|
46
|
+
@ops << ->(list){
|
47
|
+
list.sort_by(&block)
|
48
|
+
}
|
49
|
+
self
|
50
|
+
end
|
51
|
+
|
52
|
+
def map(&block)
|
53
|
+
@ops << ->(list){
|
54
|
+
list.map(&block)
|
55
|
+
}
|
56
|
+
self
|
57
|
+
end
|
58
|
+
|
59
|
+
def take(n)
|
60
|
+
return self if @enum
|
61
|
+
@ops << ->(list){
|
62
|
+
list.take(n)
|
63
|
+
}
|
64
|
+
self
|
65
|
+
end
|
66
|
+
|
67
|
+
def reverse
|
68
|
+
return self if @enum
|
69
|
+
@ops << ->(list){
|
70
|
+
list.reverse
|
71
|
+
}
|
72
|
+
self
|
73
|
+
end
|
74
|
+
|
75
|
+
def peek
|
76
|
+
@enum.peek if @enum
|
77
|
+
end
|
78
|
+
|
79
|
+
def at_end?
|
80
|
+
return false if @enum.nil?
|
81
|
+
@enum.peek
|
82
|
+
false
|
83
|
+
rescue StopIteration
|
84
|
+
true
|
85
|
+
end
|
86
|
+
|
87
|
+
def rewind_list!
|
88
|
+
@enum.rewind
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
def run_queued_operations!
|
94
|
+
@list =
|
95
|
+
@ops.inject(@list) do |l,op|
|
96
|
+
op.call l
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module BuildNotifiers
|
2
|
+
module FileBuiltNotifier
|
3
|
+
|
4
|
+
def self.call(pipeline,task)
|
5
|
+
if ProgressNotifier.finalizing?
|
6
|
+
path = task.name.sub(pipeline.output_root + "/", "")
|
7
|
+
notify_built(path, "success")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.notify_built(path, status="built")
|
12
|
+
if Benoit.config.output_mode == :app
|
13
|
+
puts({ type: status, path: path }.to_json)
|
14
|
+
else
|
15
|
+
puts "Built: #{path}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|