munge 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -1
- data/lib/munge.rb +5 -1
- data/lib/munge/bootloader.rb +27 -0
- data/lib/munge/cli/commands/build.rb +14 -10
- data/lib/munge/cli/commands/view.rb +3 -4
- data/lib/munge/cli/dispatch.rb +6 -10
- data/lib/munge/go/sass.rb +2 -0
- data/lib/munge/helpers/rendering.rb +5 -5
- data/lib/munge/init.rb +34 -0
- data/lib/munge/reporters/default.rb +1 -1
- data/lib/munge/runner.rb +5 -5
- data/lib/munge/system.rb +0 -1
- data/lib/munge/system/item_factory.rb +2 -5
- data/lib/munge/system/router.rb +0 -2
- data/lib/munge/version.rb +1 -1
- data/seeds/config/routing.rb +1 -1
- data/seeds/config/sass.rb +3 -3
- metadata +5 -4
- data/lib/munge/bootstrap.rb +0 -81
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fa33dfb3bfa3c6040f2b72dd3a5f382d52f1805
|
4
|
+
data.tar.gz: 7c053502ee9c5bf4f7571d80ae40ba5c87731c40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d3061ee4abaf367192b0afde561b912f0dee607b867bed033ce02baaaa58a69805f205a49aeb084d016581de59399f7a591fa26d48f8d74153d3dca11c98ad8
|
7
|
+
data.tar.gz: 5c2842c9a228b1a283fa587160eb5ad80e8ee97d716984675e9f7eacfd906f2e7022ebca728cedd7ff6a43271e03dfde447f5655fd250cffccec09d4e185775c
|
data/.rubocop.yml
CHANGED
@@ -4,13 +4,17 @@ AllCops:
|
|
4
4
|
- vendor/bundle/**/*
|
5
5
|
- Gemfile
|
6
6
|
- Rakefile
|
7
|
-
-
|
7
|
+
- munge.gemspec
|
8
8
|
|
9
9
|
Metrics/AbcSize:
|
10
10
|
Exclude:
|
11
11
|
- test/**/*
|
12
12
|
|
13
|
+
Metrics/LineLength:
|
14
|
+
Max: 120
|
15
|
+
|
13
16
|
Metrics/MethodLength:
|
17
|
+
Max: 15
|
14
18
|
Exclude:
|
15
19
|
- test/**/*
|
16
20
|
|
@@ -42,5 +46,9 @@ Style/MultilineOperationIndentation:
|
|
42
46
|
Style/StringLiterals:
|
43
47
|
EnforcedStyle: double_quotes
|
44
48
|
|
49
|
+
Style/SymbolProc:
|
50
|
+
Exclude:
|
51
|
+
- seeds/**/*
|
52
|
+
|
45
53
|
Style/UnneededInterpolation:
|
46
54
|
Enabled: false
|
data/lib/munge.rb
CHANGED
@@ -19,7 +19,10 @@ require "munge/util/path"
|
|
19
19
|
require "munge/util/symbol_hash"
|
20
20
|
require "munge/util/config"
|
21
21
|
require "munge/system/router"
|
22
|
+
require "munge/system/router/itemish"
|
22
23
|
require "munge/system/item_factory"
|
24
|
+
require "munge/system/item_factory/content_parser"
|
25
|
+
require "munge/system/item_factory/item_identifier"
|
23
26
|
require "munge/system/collection"
|
24
27
|
require "munge/system/readers/filesystem"
|
25
28
|
require "munge/system/alterant"
|
@@ -29,7 +32,8 @@ require "munge/writers/noop"
|
|
29
32
|
require "munge/write_manager"
|
30
33
|
require "munge/application"
|
31
34
|
require "munge/runner"
|
32
|
-
require "munge/
|
35
|
+
require "munge/init"
|
36
|
+
require "munge/bootloader"
|
33
37
|
|
34
38
|
# Extensions
|
35
39
|
require "munge/helpers/asset_tags"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Munge
|
2
|
+
class Bootloader
|
3
|
+
def initialize(root_path:)
|
4
|
+
@root_path = root_path
|
5
|
+
@config_path = File.join(root_path, "config.yml")
|
6
|
+
@setup_path = File.join(root_path, "setup.rb")
|
7
|
+
@rules_path = File.join(root_path, "rules.rb")
|
8
|
+
@config = Munge::Util::Config.read(@config_path)
|
9
|
+
end
|
10
|
+
|
11
|
+
def init
|
12
|
+
@init ||=
|
13
|
+
Init.new(
|
14
|
+
root_path: @root_path,
|
15
|
+
config: @config,
|
16
|
+
setup_path: @setup_path,
|
17
|
+
rules_path: @rules_path
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_reader :root_path
|
22
|
+
attr_reader :config_path
|
23
|
+
attr_reader :setup_path
|
24
|
+
attr_reader :rules_path
|
25
|
+
attr_reader :config
|
26
|
+
end
|
27
|
+
end
|
@@ -2,18 +2,18 @@ module Munge
|
|
2
2
|
module Cli
|
3
3
|
module Commands
|
4
4
|
class Build
|
5
|
-
def initialize(
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
def initialize(bootloader, dry_run:, reporter:)
|
6
|
+
destination_root = bootloader.root_path
|
7
|
+
config = bootloader.config
|
8
|
+
@app = application(bootloader)
|
9
9
|
|
10
10
|
runner =
|
11
11
|
Munge::Runner.new(
|
12
12
|
items: @app.vomit(:items),
|
13
13
|
router: @app.vomit(:router),
|
14
14
|
alterant: @app.vomit(:alterant),
|
15
|
-
writer: writer,
|
16
|
-
reporter:
|
15
|
+
writer: writer(dry_run),
|
16
|
+
reporter: reporter(reporter),
|
17
17
|
destination: File.expand_path(config[:output], destination_root)
|
18
18
|
)
|
19
19
|
|
@@ -22,19 +22,23 @@ module Munge
|
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
-
def application(
|
26
|
-
bootstrap =
|
25
|
+
def application(bootloader)
|
26
|
+
bootstrap = bootloader.init
|
27
27
|
|
28
28
|
bootstrap.app
|
29
29
|
end
|
30
30
|
|
31
|
-
def writer
|
32
|
-
if
|
31
|
+
def writer(dry_run)
|
32
|
+
if dry_run
|
33
33
|
Munge::Writers::Noop.new
|
34
34
|
else
|
35
35
|
Munge::Writers::Filesystem.new
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
def reporter(class_name)
|
40
|
+
Munge::Reporters.const_get(class_name).new
|
41
|
+
end
|
38
42
|
end
|
39
43
|
end
|
40
44
|
end
|
@@ -28,9 +28,8 @@ module Munge
|
|
28
28
|
module Cli
|
29
29
|
module Commands
|
30
30
|
class View
|
31
|
-
def initialize(
|
32
|
-
config
|
33
|
-
rack_opts = { Host: options[:host], Port: options[:port] }
|
31
|
+
def initialize(bootloader, host:, port:)
|
32
|
+
config = bootloader.config
|
34
33
|
|
35
34
|
app =
|
36
35
|
Rack::Builder.new do
|
@@ -40,7 +39,7 @@ module Munge
|
|
40
39
|
run Rack::File.new(config[:output])
|
41
40
|
end
|
42
41
|
|
43
|
-
Rack::Handler::WEBrick.run(app,
|
42
|
+
Rack::Handler::WEBrick.run(app, Host: host, Port: port)
|
44
43
|
end
|
45
44
|
end
|
46
45
|
end
|
data/lib/munge/cli/dispatch.rb
CHANGED
@@ -18,14 +18,14 @@ module Munge
|
|
18
18
|
method_option :reporter, desc: "Set reporter", default: "Default", type: :string
|
19
19
|
method_option :dry_run, desc: "Run without writing files", default: false, type: :boolean
|
20
20
|
def build
|
21
|
-
Commands::Build.new(
|
21
|
+
Commands::Build.new(bootloader, symbolized_options)
|
22
22
|
end
|
23
23
|
|
24
24
|
desc "view", "View built files"
|
25
25
|
method_option :port, aliases: "-p", desc: "Set port", default: 7000, type: :numeric
|
26
26
|
method_option :host, aliases: "-h", desc: "Set host", default: "0.0.0.0", type: :string
|
27
27
|
def view
|
28
|
-
Commands::View.new(
|
28
|
+
Commands::View.new(bootloader, symbolized_options)
|
29
29
|
end
|
30
30
|
|
31
31
|
desc "version", "Print version"
|
@@ -36,16 +36,12 @@ module Munge
|
|
36
36
|
|
37
37
|
private
|
38
38
|
|
39
|
-
def
|
40
|
-
Munge::
|
39
|
+
def bootloader
|
40
|
+
Munge::Bootloader.new(root_path: destination_root)
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
def rules_path
|
48
|
-
File.join(destination_root, "rules.rb")
|
43
|
+
def symbolized_options
|
44
|
+
Munge::Util::SymbolHash.deep_convert(options)
|
49
45
|
end
|
50
46
|
end
|
51
47
|
end
|
data/lib/munge/go/sass.rb
CHANGED
@@ -9,11 +9,13 @@ module Munge
|
|
9
9
|
Sass.load_paths << File.join(*paths)
|
10
10
|
end
|
11
11
|
|
12
|
+
# rubocop:disable Style/AccessorMethodName
|
12
13
|
def set_sass_system!(system)
|
13
14
|
Sass::Script::Functions.send(:define_method, :system) do
|
14
15
|
system
|
15
16
|
end
|
16
17
|
end
|
18
|
+
# rubocop:enable Style/AccessorMethodName
|
17
19
|
|
18
20
|
def add_sass_functions!(asset_roots)
|
19
21
|
Sass::Script::Functions.send(:include, asset_roots)
|
@@ -4,7 +4,7 @@ module Munge
|
|
4
4
|
def render(item, engines: nil, data: {}, content_override: nil)
|
5
5
|
content = content_override || item.content
|
6
6
|
renderers = tilt_renderer_list(item, engines)
|
7
|
-
mdata = merged_data(item.frontmatter, data,
|
7
|
+
mdata = merged_data(item.frontmatter, data, self_item: item)
|
8
8
|
|
9
9
|
render_string(content, data: mdata, engines: renderers)
|
10
10
|
end
|
@@ -12,7 +12,7 @@ module Munge
|
|
12
12
|
def layout(item_or_string, data: {}, &block)
|
13
13
|
layout_item = resolve_layout(item_or_string)
|
14
14
|
renderers = tilt_renderer_list(layout_item, nil)
|
15
|
-
mdata = merged_data(layout_item.frontmatter, data,
|
15
|
+
mdata = merged_data(layout_item.frontmatter, data, self_layout: layout_item)
|
16
16
|
|
17
17
|
render_string(layout_item.content, data: mdata, engines: renderers, &block)
|
18
18
|
end
|
@@ -25,8 +25,8 @@ module Munge
|
|
25
25
|
|
26
26
|
output =
|
27
27
|
engines
|
28
|
-
.inject(content) do |
|
29
|
-
template = engine.new {
|
28
|
+
.inject(content) do |memo, engine|
|
29
|
+
template = engine.new { memo }
|
30
30
|
|
31
31
|
if inner
|
32
32
|
template.render(self, data) { inner }
|
@@ -44,7 +44,7 @@ module Munge
|
|
44
44
|
|
45
45
|
def render_with_layout(item, content_engines: nil, data: {}, content_override: nil)
|
46
46
|
inner = render(item, engines: content_engines, data: data, content_override: content_override)
|
47
|
-
mdata = merged_data(item.frontmatter, data,
|
47
|
+
mdata = merged_data(item.frontmatter, data, self_item: item)
|
48
48
|
|
49
49
|
if item.layout
|
50
50
|
layout(item.layout, data: mdata) do
|
data/lib/munge/init.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Munge
|
2
|
+
class Init
|
3
|
+
def initialize(root_path:,
|
4
|
+
config:,
|
5
|
+
setup_path:,
|
6
|
+
rules_path:)
|
7
|
+
@root_path = root_path
|
8
|
+
@setup_path = setup_path
|
9
|
+
@rules_path = rules_path
|
10
|
+
@binding = binding
|
11
|
+
|
12
|
+
system = Munge::System.new(root_path, config)
|
13
|
+
|
14
|
+
import(setup_path)
|
15
|
+
|
16
|
+
@app = Munge::Application.new(system)
|
17
|
+
|
18
|
+
import(rules_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def config_path
|
22
|
+
File.join(root_path, "config")
|
23
|
+
end
|
24
|
+
|
25
|
+
def import(file_path)
|
26
|
+
absolute_file_path = File.expand_path(file_path, root_path)
|
27
|
+
contents = File.read(absolute_file_path)
|
28
|
+
@binding.eval(contents, absolute_file_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
attr_reader :app
|
32
|
+
attr_reader :root_path
|
33
|
+
end
|
34
|
+
end
|
data/lib/munge/runner.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module Munge
|
2
2
|
class Runner
|
3
3
|
def initialize(items:, router:, alterant:, writer:, reporter:, destination:)
|
4
|
-
@items
|
5
|
-
@router
|
6
|
-
@alterant
|
7
|
-
@writer
|
8
|
-
@reporter
|
4
|
+
@items = items
|
5
|
+
@router = router
|
6
|
+
@alterant = alterant
|
7
|
+
@writer = writer
|
8
|
+
@reporter = reporter
|
9
9
|
@write_manager = Munge::WriteManager.new(driver: File)
|
10
10
|
@destination = destination
|
11
11
|
end
|
data/lib/munge/system.rb
CHANGED
@@ -4,7 +4,6 @@ module Munge
|
|
4
4
|
def initialize(root_path, config)
|
5
5
|
source_path = File.expand_path(config[:source], root_path)
|
6
6
|
layouts_path = File.expand_path(config[:layouts], root_path)
|
7
|
-
output_path = File.expand_path(config[:output], root_path)
|
8
7
|
data_path = File.expand_path(config[:data], root_path)
|
9
8
|
|
10
9
|
@global_data = YAML.load_file(data_path) || {}
|
@@ -1,13 +1,10 @@
|
|
1
|
-
require_relative "item_factory/content_parser"
|
2
|
-
require_relative "item_factory/item_identifier"
|
3
|
-
|
4
1
|
module Munge
|
5
2
|
class System
|
6
3
|
class ItemFactory
|
7
4
|
def initialize(text_extensions:,
|
8
5
|
ignore_extensions:)
|
9
6
|
@text_extensions = Set.new(text_extensions)
|
10
|
-
@item_identifier =
|
7
|
+
@item_identifier = ItemIdentifier.new(remove_extensions: ignore_extensions)
|
11
8
|
end
|
12
9
|
|
13
10
|
def build(relpath:,
|
@@ -34,7 +31,7 @@ module Munge
|
|
34
31
|
type = compute_file_type(relpath)
|
35
32
|
|
36
33
|
if type == :text
|
37
|
-
parsed =
|
34
|
+
parsed = ContentParser.new(content)
|
38
35
|
|
39
36
|
build(
|
40
37
|
relpath: relpath,
|
data/lib/munge/system/router.rb
CHANGED
data/lib/munge/version.rb
CHANGED
data/seeds/config/routing.rb
CHANGED
data/seeds/config/sass.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "munge/go/sass"
|
2
2
|
|
3
|
-
Munge::Go
|
3
|
+
Munge::Go.add_sass_load_path!(root_path, config[:source], AssetRoots.stylesheets_root)
|
4
4
|
|
5
|
-
Munge::Go
|
5
|
+
Munge::Go.set_sass_system!(system)
|
6
6
|
|
7
|
-
Munge::Go
|
7
|
+
Munge::Go.add_sass_functions!(AssetRoots)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: munge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Ahn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -192,7 +192,7 @@ dependencies:
|
|
192
192
|
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '3.4'
|
195
|
-
description: Documentation for this release is located in https://github.com/zachahn/munge/blob/v0.7.
|
195
|
+
description: Documentation for this release is located in https://github.com/zachahn/munge/blob/v0.7.1/README.md
|
196
196
|
email:
|
197
197
|
- zach.ahn@gmail.com
|
198
198
|
executables:
|
@@ -212,7 +212,7 @@ files:
|
|
212
212
|
- exe/munge
|
213
213
|
- lib/munge.rb
|
214
214
|
- lib/munge/application.rb
|
215
|
-
- lib/munge/
|
215
|
+
- lib/munge/bootloader.rb
|
216
216
|
- lib/munge/cli.rb
|
217
217
|
- lib/munge/cli/commands/build.rb
|
218
218
|
- lib/munge/cli/commands/view.rb
|
@@ -226,6 +226,7 @@ files:
|
|
226
226
|
- lib/munge/helpers/link.rb
|
227
227
|
- lib/munge/helpers/rendering.rb
|
228
228
|
- lib/munge/helpers/tag.rb
|
229
|
+
- lib/munge/init.rb
|
229
230
|
- lib/munge/item.rb
|
230
231
|
- lib/munge/reporters/default.rb
|
231
232
|
- lib/munge/routers/add_index_html.rb
|
data/lib/munge/bootstrap.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
module Munge
|
2
|
-
class Bootstrap
|
3
|
-
class << self
|
4
|
-
def new_from_dir(root_path:)
|
5
|
-
new_from_fs(
|
6
|
-
root_path: root_path,
|
7
|
-
config_path: config_path(root_path),
|
8
|
-
setup_path: setup_path(root_path),
|
9
|
-
rules_path: rules_path(root_path)
|
10
|
-
)
|
11
|
-
end
|
12
|
-
|
13
|
-
def new_from_fs(root_path:,
|
14
|
-
config_path:,
|
15
|
-
setup_path:,
|
16
|
-
rules_path:)
|
17
|
-
new(
|
18
|
-
root_path: root_path,
|
19
|
-
config: read_config(config_path),
|
20
|
-
setup_string: File.read(setup_path),
|
21
|
-
setup_path: setup_path,
|
22
|
-
rules_string: File.read(rules_path),
|
23
|
-
rules_path: rules_path
|
24
|
-
)
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def read_config(config_path)
|
30
|
-
Munge::Util::Config.read(config_path)
|
31
|
-
end
|
32
|
-
|
33
|
-
def config_path(root_path)
|
34
|
-
File.join(root_path, "config.yml")
|
35
|
-
end
|
36
|
-
|
37
|
-
def setup_path(root_path)
|
38
|
-
File.join(root_path, "setup.rb")
|
39
|
-
end
|
40
|
-
|
41
|
-
def rules_path(root_path)
|
42
|
-
File.join(root_path, "rules.rb")
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def initialize(root_path:,
|
47
|
-
config:,
|
48
|
-
setup_string:,
|
49
|
-
rules_string:,
|
50
|
-
setup_path:,
|
51
|
-
rules_path:)
|
52
|
-
@setup_path = setup_path
|
53
|
-
@rules_path = rules_path
|
54
|
-
@binding = binding
|
55
|
-
|
56
|
-
system = Munge::System.new(root_path, config)
|
57
|
-
|
58
|
-
import(setup_path, setup_string)
|
59
|
-
|
60
|
-
@app = Munge::Application.new(system)
|
61
|
-
|
62
|
-
import(rules_path, rules_string)
|
63
|
-
end
|
64
|
-
|
65
|
-
def root_path
|
66
|
-
File.dirname(@setup_path)
|
67
|
-
end
|
68
|
-
|
69
|
-
def config_path
|
70
|
-
File.join(root_path, "config")
|
71
|
-
end
|
72
|
-
|
73
|
-
def import(file_path, file_contents = nil)
|
74
|
-
absolute_file_path = File.expand_path(file_path, root_path)
|
75
|
-
contents = file_contents || File.read(absolute_file_path)
|
76
|
-
@binding.eval(contents, absolute_file_path)
|
77
|
-
end
|
78
|
-
|
79
|
-
attr_reader :app
|
80
|
-
end
|
81
|
-
end
|