munge 0.18.0 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/munge.rb +32 -31
- data/lib/munge/application.rb +7 -7
- data/lib/munge/bootloader.rb +0 -11
- data/lib/munge/cli.rb +3 -3
- data/lib/munge/cli/commands/build.rb +17 -21
- data/lib/munge/cli/commands/clean.rb +28 -33
- data/lib/munge/cli/commands/init.rb +1 -1
- data/lib/munge/cli/commands/server.rb +3 -3
- data/lib/munge/cli/dispatch.rb +56 -13
- data/lib/munge/config.rb +2 -2
- data/lib/munge/{system.rb → conglomerate.rb} +21 -14
- data/lib/munge/{system → conglomerate}/collection.rb +5 -26
- data/lib/munge/{system → conglomerate}/item_factory.rb +1 -1
- data/lib/munge/{system → conglomerate}/item_factory/content_parser.rb +1 -1
- data/lib/munge/{system → conglomerate}/item_factory/item_identifier.rb +1 -1
- data/lib/munge/conglomerate/processor.rb +138 -0
- data/lib/munge/conglomerate/reader.rb +33 -0
- data/lib/munge/{system → conglomerate}/router.rb +3 -3
- data/lib/munge/{system → conglomerate}/router/itemish.rb +1 -1
- data/lib/munge/{errors.rb → error.rb} +1 -25
- data/lib/munge/{extras → extra}/livereload.rb +5 -5
- data/lib/munge/{extras → extra}/livereload/messaging.rb +1 -1
- data/lib/munge/{extras → extra}/livereload/server.rb +1 -1
- data/lib/munge/{extras → extra}/livereload/update_client.rb +1 -1
- data/lib/munge/{extras → extra}/livereload/update_server.rb +1 -1
- data/lib/munge/{extras → extra}/livereload/vendor/livereload.js +0 -0
- data/lib/munge/{formatters → formatter}/default.rb +1 -1
- data/lib/munge/{formatters → formatter}/dots.rb +1 -1
- data/lib/munge/{formatters → formatter}/silent.rb +1 -1
- data/lib/munge/function/clean.rb +18 -0
- data/lib/munge/function/write.rb +68 -0
- data/lib/munge/go/sass.rb +5 -5
- data/lib/munge/go/sass/asset_urls.rb +2 -2
- data/lib/munge/{helpers → helper}/asset_paths.rb +1 -1
- data/lib/munge/{helpers → helper}/asset_tags.rb +1 -1
- data/lib/munge/{helpers → helper}/capture.rb +1 -1
- data/lib/munge/helper/data.rb +21 -0
- data/lib/munge/helper/define_module.rb +13 -0
- data/lib/munge/{helpers → helper}/find.rb +3 -3
- data/lib/munge/{helpers → helper}/link.rb +3 -3
- data/lib/munge/{helpers → helper}/livereload.rb +1 -1
- data/lib/munge/helper/rendering.rb +51 -0
- data/lib/munge/{helpers → helper}/tag.rb +4 -8
- data/lib/munge/item.rb +4 -5
- data/lib/munge/load.rb +60 -0
- data/lib/munge/pre_init.rb +10 -7
- data/lib/munge/{routers → router}/add_directory_index.rb +1 -1
- data/lib/munge/{routers → router}/auto_add_extension.rb +1 -1
- data/lib/munge/{routers → router}/fingerprint.rb +1 -1
- data/lib/munge/{routers → router}/remove_index_basename.rb +1 -1
- data/lib/munge/version.rb +1 -1
- data/lib/munge/vfs/dry_run.rb +28 -0
- data/lib/munge/vfs/filesystem.rb +44 -0
- data/lib/munge/vfs/memory.rb +33 -0
- data/lib/munge/write_manager/all.rb +11 -11
- data/lib/munge/write_manager/only_needed.rb +9 -9
- data/munge.gemspec +25 -17
- data/seeds/boot.rb +21 -0
- data/seeds/boot.yml +10 -0
- data/seeds/config.rb +7 -0
- data/seeds/layouts/blog_archives.html.erb +1 -1
- data/seeds/layouts/blog_index.html.erb +1 -1
- data/seeds/layouts/default.html.erb +1 -1
- data/seeds/lib/routing.rb +8 -8
- data/seeds/lib/sass.rb +1 -1
- data/seeds/lib/view_helpers.rb +3 -11
- data/seeds/rules.rb +1 -1
- data/seeds/src/home/index.html.erb +1 -1
- metadata +64 -46
- data/lib/munge/cleaner.rb +0 -31
- data/lib/munge/helpers/rendering.rb +0 -100
- data/lib/munge/init.rb +0 -45
- data/lib/munge/io/dry_run.rb +0 -31
- data/lib/munge/io/filesystem.rb +0 -38
- data/lib/munge/io/noop.rb +0 -27
- data/lib/munge/runner.rb +0 -68
- data/lib/munge/system/processor.rb +0 -52
- data/lib/munge/system/readers/filesystem.rb +0 -52
- data/lib/munge/transformers/tilt_transformer.rb +0 -40
- data/lib/munge/util/import.rb +0 -15
- data/seeds/setup.rb +0 -3
File without changes
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Munge
|
2
|
+
module Function
|
3
|
+
class Clean
|
4
|
+
def initialize(memory:, destination:)
|
5
|
+
@memory = memory
|
6
|
+
@destination = destination
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
orphans = @destination.tree - @memory.tree
|
11
|
+
|
12
|
+
orphans.each do |orphan|
|
13
|
+
@destination.rm(orphan)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Munge
|
2
|
+
module Function
|
3
|
+
class Write
|
4
|
+
def initialize(conglomerate:, reporter:, manager:, destination:)
|
5
|
+
@items = conglomerate.items
|
6
|
+
@router = conglomerate.router
|
7
|
+
@processor = conglomerate.processor
|
8
|
+
@reporter = reporter
|
9
|
+
@manager = manager
|
10
|
+
@vfs = destination
|
11
|
+
@written_paths = []
|
12
|
+
end
|
13
|
+
|
14
|
+
def call
|
15
|
+
@reporter.start
|
16
|
+
|
17
|
+
@items
|
18
|
+
.reject { |item| item.route.nil? }
|
19
|
+
.each { |item| render_and_write(item) }
|
20
|
+
|
21
|
+
@reporter.done
|
22
|
+
|
23
|
+
@manager.written_routes
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def render_and_write(item)
|
29
|
+
relpath = @router.filepath(item)
|
30
|
+
route = @router.route(item)
|
31
|
+
content = @processor.transform(item)
|
32
|
+
|
33
|
+
write_status = status(relpath, content)
|
34
|
+
|
35
|
+
case write_status
|
36
|
+
when :new
|
37
|
+
@manager.on_new(route, relpath, content)
|
38
|
+
when :changed
|
39
|
+
@manager.on_changed(route, relpath, content)
|
40
|
+
when :identical
|
41
|
+
@manager.on_identical(route, relpath, content)
|
42
|
+
when :double_write_error
|
43
|
+
raise Error::DoubleWriteError, item.route
|
44
|
+
end
|
45
|
+
|
46
|
+
@reporter.call(item, relpath, write_status)
|
47
|
+
end
|
48
|
+
|
49
|
+
def status(path, content)
|
50
|
+
if @written_paths.include?(path)
|
51
|
+
return :double_write_error
|
52
|
+
end
|
53
|
+
|
54
|
+
@written_paths.push(path)
|
55
|
+
|
56
|
+
if !@vfs.exist?(path)
|
57
|
+
return :new
|
58
|
+
end
|
59
|
+
|
60
|
+
if @vfs.read(path) == content
|
61
|
+
return :identical
|
62
|
+
end
|
63
|
+
|
64
|
+
:changed
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/munge/go/sass.rb
CHANGED
@@ -14,13 +14,13 @@ module Munge
|
|
14
14
|
Sass.load_paths << File.join(*paths)
|
15
15
|
end
|
16
16
|
|
17
|
-
# Sets {Munge::
|
17
|
+
# Sets {Munge::Conglomerate} for use with plugins
|
18
18
|
#
|
19
|
-
# @param
|
19
|
+
# @param conglomerate [Munge::Conglomerate]
|
20
20
|
# @return [void]
|
21
|
-
def
|
22
|
-
Sass::Script::Functions.send(:define_method, :
|
23
|
-
|
21
|
+
def set_sass_conglomerate!(conglomerate)
|
22
|
+
Sass::Script::Functions.send(:define_method, :conglomerate) do
|
23
|
+
conglomerate
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -34,8 +34,8 @@ module Sass::Script::Functions
|
|
34
34
|
def asset_route_helper(root, basename)
|
35
35
|
basename_string = stringify_string(basename)
|
36
36
|
|
37
|
-
item =
|
38
|
-
r =
|
37
|
+
item = conglomerate.items["#{root}/#{basename_string}"]
|
38
|
+
r = conglomerate.router.route(item)
|
39
39
|
|
40
40
|
quoted_string(r)
|
41
41
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
module Munge
|
2
|
-
module
|
2
|
+
module Helper
|
3
3
|
module Link
|
4
4
|
def path_to(itemish)
|
5
5
|
item =
|
6
6
|
if itemish.is_a?(String)
|
7
|
-
|
7
|
+
conglomerate.items[itemish]
|
8
8
|
else
|
9
9
|
itemish
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
conglomerate.router.route(item)
|
13
13
|
end
|
14
14
|
|
15
15
|
def link_to(itemish, text = nil, opts = {})
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Munge
|
2
|
+
module Helper
|
3
|
+
module Rendering
|
4
|
+
def render(item, engines: :use_extensions, data: {})
|
5
|
+
merged_data = item.frontmatter.merge(data)
|
6
|
+
inner_view_scope = current_view_scope.clone
|
7
|
+
inner_view_scope.instance_variable_set(:@data_stack, data_stack.dup)
|
8
|
+
inner_view_scope.data_stack.push(merged_data)
|
9
|
+
|
10
|
+
conglomerate.processor.private_transform(
|
11
|
+
filename: item.relpath,
|
12
|
+
content: item.content,
|
13
|
+
view_scope: inner_view_scope,
|
14
|
+
engines: [engines].flatten.compact
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def layout(item_or_string, data: {}, &block)
|
19
|
+
layout_item =
|
20
|
+
if item_or_string.is_a?(String)
|
21
|
+
conglomerate.layouts[item_or_string]
|
22
|
+
else
|
23
|
+
item_or_string
|
24
|
+
end
|
25
|
+
|
26
|
+
inner_as_block =
|
27
|
+
if block_given?
|
28
|
+
inner = capture(&block)
|
29
|
+
-> { inner }
|
30
|
+
else
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
|
34
|
+
output =
|
35
|
+
conglomerate.processor.private_transform(
|
36
|
+
filename: "(layout) #{layout_item.relpath}",
|
37
|
+
content: layout_item.content,
|
38
|
+
view_scope: current_view_scope.clone,
|
39
|
+
engines: %i[use_extensions],
|
40
|
+
block: inner_as_block
|
41
|
+
)
|
42
|
+
|
43
|
+
if block_given?
|
44
|
+
append_to_erbout(block.binding, output)
|
45
|
+
end
|
46
|
+
|
47
|
+
output
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Munge
|
2
|
-
module
|
2
|
+
module Helper
|
3
3
|
module Tag
|
4
4
|
def empty_tag(name, options = {})
|
5
5
|
options_str = options.map { |k, v| %(#{k}="#{h(v)}") }.join(" ")
|
@@ -17,23 +17,19 @@ module Munge
|
|
17
17
|
content = nil
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
html_attributes =
|
21
21
|
if options.any?
|
22
22
|
" " + options.map { |k, v| %(#{k}="#{h(v)}") }.join(" ")
|
23
|
-
else
|
24
|
-
""
|
25
23
|
end
|
26
24
|
|
27
|
-
|
25
|
+
inner_html =
|
28
26
|
if content
|
29
27
|
content
|
30
28
|
elsif block_given?
|
31
29
|
capture(&block)
|
32
|
-
else
|
33
|
-
""
|
34
30
|
end
|
35
31
|
|
36
|
-
"<#{name}#{
|
32
|
+
"<#{name}#{html_attributes}>#{inner_html}</#{name}>"
|
37
33
|
end
|
38
34
|
|
39
35
|
def h(string)
|
data/lib/munge/item.rb
CHANGED
@@ -11,7 +11,7 @@ module Munge
|
|
11
11
|
@relpath = relpath
|
12
12
|
@id = id
|
13
13
|
@content = content
|
14
|
-
@frontmatter = frontmatter
|
14
|
+
@frontmatter = Munge::Util::SymbolHash.deep_convert(frontmatter)
|
15
15
|
@stat = stat
|
16
16
|
|
17
17
|
@route = nil
|
@@ -116,12 +116,11 @@ module Munge
|
|
116
116
|
@layout = remove_surrounding_slashes(new_layout)
|
117
117
|
end
|
118
118
|
|
119
|
-
# @param
|
119
|
+
# @param engine [Symbol] name of template engine to apply onto item when
|
120
120
|
# building
|
121
|
-
# @param *args
|
122
121
|
# @return [void]
|
123
|
-
def transform(
|
124
|
-
@transforms.push(
|
122
|
+
def transform(engine = :use_extensions)
|
123
|
+
@transforms.push(engine)
|
125
124
|
end
|
126
125
|
|
127
126
|
# Deep freeze. Freezes all instance variables as well as itself.
|
data/lib/munge/load.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
module Munge
|
2
|
+
class Load
|
3
|
+
def initialize(root_path)
|
4
|
+
boot_config_path = File.join(root_path, "boot.yml")
|
5
|
+
|
6
|
+
@root_path = Pathname.new(root_path)
|
7
|
+
@boot_config = YAML.load(File.read(boot_config_path))
|
8
|
+
@config = Munge::Config.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def app
|
12
|
+
Dir.chdir(@root_path) do
|
13
|
+
config_load
|
14
|
+
|
15
|
+
conglomerate = Munge::Conglomerate.new(@root_path.to_s, @config)
|
16
|
+
application = Munge::Application.new(conglomerate)
|
17
|
+
|
18
|
+
thread_variable_set_helper(@boot_config["conglomerate_key"], conglomerate) do
|
19
|
+
thread_variable_set_helper(@boot_config["application_key"], application) do
|
20
|
+
thread_variable_set_helper(@boot_config["config_key"], @config) do
|
21
|
+
thread_variable_set_helper(@boot_config["root_path_key"], @root_path) do
|
22
|
+
load_from_boot_config_key("boot_path")
|
23
|
+
load_from_boot_config_key("rules_path")
|
24
|
+
|
25
|
+
yield application, conglomerate
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def thread_variable_set_helper(key, value)
|
36
|
+
Thread.current.thread_variable_set(key, value)
|
37
|
+
|
38
|
+
result = yield
|
39
|
+
|
40
|
+
Thread.current.thread_variable_set(key, nil)
|
41
|
+
|
42
|
+
result
|
43
|
+
end
|
44
|
+
|
45
|
+
def load_from_boot_config_key(key)
|
46
|
+
abspath = @root_path.join(@boot_config[key])
|
47
|
+
|
48
|
+
load abspath
|
49
|
+
end
|
50
|
+
|
51
|
+
def config_load
|
52
|
+
return if @loaded_config
|
53
|
+
@loaded_config = true
|
54
|
+
|
55
|
+
thread_variable_set_helper(@boot_config["config_key"], @config) do
|
56
|
+
load_from_boot_config_key("config_path")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/munge/pre_init.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
module Munge
|
2
2
|
class PreInit
|
3
|
-
include Munge::Util::Import
|
4
|
-
|
5
3
|
def initialize(config_path)
|
6
4
|
if !File.exist?(config_path)
|
7
|
-
raise Munge::
|
5
|
+
raise Munge::Error::ConfigRbNotFound, config_path
|
8
6
|
end
|
9
7
|
|
10
8
|
@config_path = config_path
|
@@ -13,16 +11,21 @@ module Munge
|
|
13
11
|
def config
|
14
12
|
config = Munge::Config.new
|
15
13
|
|
16
|
-
|
14
|
+
thread_variable_set_helper("config", config) do
|
15
|
+
load @config_path
|
16
|
+
end
|
17
17
|
|
18
18
|
config
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
-
def
|
24
|
-
|
25
|
-
|
23
|
+
def thread_variable_set_helper(key, value)
|
24
|
+
Thread.current.thread_variable_set(key, value)
|
25
|
+
|
26
|
+
yield
|
27
|
+
|
28
|
+
Thread.current.thread_variable_set(key, nil)
|
26
29
|
end
|
27
30
|
end
|
28
31
|
end
|