munge 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/munge +2 -2
- data/lib/munge.rb +21 -18
- data/lib/munge/bootstrap.rb +9 -2
- data/lib/munge/cli/commands/build.rb +11 -0
- data/lib/munge/{commands → cli/commands}/view.rb +15 -13
- data/lib/munge/cli/dispatch.rb +47 -0
- data/lib/munge/go/sass.rb +22 -0
- data/lib/munge/go/sass/asset_urls.rb +44 -0
- data/lib/munge/{helper/asset_urls.rb → helpers/asset_paths.rb} +6 -6
- data/lib/munge/{helper → helpers}/asset_tags.rb +1 -1
- data/lib/munge/{helper → helpers}/capture.rb +1 -1
- data/lib/munge/{helper → helpers}/find.rb +1 -1
- data/lib/munge/{helper → helpers}/link.rb +1 -1
- data/lib/munge/{helper → helpers}/rendering.rb +1 -1
- data/lib/munge/{helper → helpers}/tag.rb +1 -1
- data/lib/munge/routers/add_index_html.rb +1 -1
- data/lib/munge/routers/auto_add_extension.rb +1 -1
- data/lib/munge/routers/fingerprint.rb +1 -1
- data/lib/munge/routers/remove_index_basename.rb +1 -1
- data/lib/munge/system.rb +9 -9
- data/lib/munge/{core → system}/alterant.rb +2 -3
- data/lib/munge/{core → system}/collection.rb +1 -1
- data/lib/munge/{core → system}/item_factory.rb +2 -2
- data/lib/munge/{core → system}/item_factory/content_parser.rb +1 -1
- data/lib/munge/system/readers/filesystem.rb +48 -0
- data/lib/munge/{core → system}/router.rb +1 -1
- data/lib/munge/{core → system}/router/itemish.rb +1 -1
- data/lib/munge/{core → system}/write.rb +1 -1
- data/lib/munge/{transformer → transformers}/tilt.rb +1 -1
- data/lib/munge/version.rb +1 -1
- data/seeds/config/routing.rb +4 -4
- data/seeds/config/sass.rb +6 -2
- data/seeds/config/view_helpers.rb +8 -8
- data/seeds/setup.rb +1 -1
- metadata +24 -22
- data/lib/munge/cli.rb +0 -45
- data/lib/munge/readers/filesystem.rb +0 -46
- data/seeds/config/sass_helpers.rb +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdbfe2a9223c246cb18bd9fcdaf389c52075eef5
|
4
|
+
data.tar.gz: 591d3ea317628eeed159e629e31bb476777be91d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3360ab60a36319f56066a7a82967bde4c5d70f4bae08d6b0709eb8c8b1531f1caf1aefe0eb351aa3a9a27803898d61ed2446a98fe4daded6bbc164d2dd8ab9ef
|
7
|
+
data.tar.gz: bddb33da3a1739658e3f9bcc510e10244bf0a461a2963c83d3ba062808a4dc3907fea300d3e4ed26c9d8323ff576b111e59598d85bf8c6348520356c1b77ef0d
|
data/exe/munge
CHANGED
data/lib/munge.rb
CHANGED
@@ -6,30 +6,33 @@ require "yaml"
|
|
6
6
|
|
7
7
|
require "tilt"
|
8
8
|
|
9
|
+
# Core
|
9
10
|
require "munge/version"
|
10
11
|
require "munge/item"
|
11
12
|
require "munge/util/path"
|
12
13
|
require "munge/util/symbol_hash"
|
13
14
|
require "munge/util/config"
|
14
|
-
require "munge/
|
15
|
-
require "munge/
|
16
|
-
require "munge/
|
17
|
-
require "munge/
|
18
|
-
require "munge/
|
19
|
-
require "munge/
|
20
|
-
require "munge/helper/tag"
|
21
|
-
require "munge/transformer/tilt"
|
22
|
-
require "munge/readers/filesystem"
|
23
|
-
require "munge/routers/auto_add_extension"
|
24
|
-
require "munge/routers/fingerprint"
|
25
|
-
require "munge/routers/add_index_html"
|
26
|
-
require "munge/routers/remove_index_basename"
|
27
|
-
require "munge/core/router"
|
28
|
-
require "munge/core/item_factory"
|
29
|
-
require "munge/core/collection"
|
30
|
-
require "munge/core/write"
|
31
|
-
require "munge/core/alterant"
|
15
|
+
require "munge/system/router"
|
16
|
+
require "munge/system/item_factory"
|
17
|
+
require "munge/system/collection"
|
18
|
+
require "munge/system/readers/filesystem"
|
19
|
+
require "munge/system/write"
|
20
|
+
require "munge/system/alterant"
|
32
21
|
require "munge/system"
|
33
22
|
require "munge/application"
|
34
23
|
require "munge/runner"
|
35
24
|
require "munge/bootstrap"
|
25
|
+
|
26
|
+
# Extensions
|
27
|
+
require "munge/helpers/asset_tags"
|
28
|
+
require "munge/helpers/asset_paths"
|
29
|
+
require "munge/helpers/capture"
|
30
|
+
require "munge/helpers/find"
|
31
|
+
require "munge/helpers/link"
|
32
|
+
require "munge/helpers/rendering"
|
33
|
+
require "munge/helpers/tag"
|
34
|
+
require "munge/routers/auto_add_extension"
|
35
|
+
require "munge/routers/fingerprint"
|
36
|
+
require "munge/routers/add_index_html"
|
37
|
+
require "munge/routers/remove_index_basename"
|
38
|
+
require "munge/transformers/tilt"
|
data/lib/munge/bootstrap.rb
CHANGED
@@ -51,14 +51,15 @@ module Munge
|
|
51
51
|
rules_path:)
|
52
52
|
@setup_path = setup_path
|
53
53
|
@rules_path = rules_path
|
54
|
+
@binding = binding
|
54
55
|
|
55
56
|
system = Munge::System.new(root_path, config)
|
56
57
|
|
57
|
-
|
58
|
+
import(setup_path, setup_string)
|
58
59
|
|
59
60
|
@app = Munge::Application.new(system)
|
60
61
|
|
61
|
-
|
62
|
+
import(rules_path, rules_string)
|
62
63
|
end
|
63
64
|
|
64
65
|
def root_path
|
@@ -69,6 +70,12 @@ module Munge
|
|
69
70
|
File.join(root_path, "config")
|
70
71
|
end
|
71
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
|
+
|
72
79
|
attr_reader :app
|
73
80
|
end
|
74
81
|
end
|
@@ -25,21 +25,23 @@ require "adsf"
|
|
25
25
|
require "rack"
|
26
26
|
|
27
27
|
module Munge
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
module Cli
|
29
|
+
module Commands
|
30
|
+
class View
|
31
|
+
def initialize(options, config_path)
|
32
|
+
config = Munge::Util::Config.read(config_path)
|
33
|
+
rack_opts = { Host: options[:host], Port: options[:port] }
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
app =
|
36
|
+
Rack::Builder.new do
|
37
|
+
use Rack::ShowExceptions
|
38
|
+
use Rack::Head
|
39
|
+
use Adsf::Rack::IndexFileFinder, root: config[:output]
|
40
|
+
run Rack::File.new(config[:output])
|
41
|
+
end
|
41
42
|
|
42
|
-
|
43
|
+
Rack::Handler::WEBrick.run(app, rack_opts)
|
44
|
+
end
|
43
45
|
end
|
44
46
|
end
|
45
47
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module Munge
|
4
|
+
module Cli
|
5
|
+
class Dispatch < Thor
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
def self.source_root
|
9
|
+
File.expand_path("../../../seeds", __FILE__)
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "init PATH", "Create new site at PATH"
|
13
|
+
def init(path)
|
14
|
+
directory ".", path
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "build", "Build in current directory"
|
18
|
+
def build
|
19
|
+
require_relative "commands/build"
|
20
|
+
Commands::Build.new(destination_root)
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "view", "View built files"
|
24
|
+
method_option :port, aliases: "-p", desc: "Set port", default: 7000, type: :numeric
|
25
|
+
method_option :host, aliases: "-h", desc: "Set host", default: "0.0.0.0", type: :string
|
26
|
+
def view
|
27
|
+
require_relative "commands/view"
|
28
|
+
Commands::View.new(options, config_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "version", "Print version"
|
32
|
+
def version
|
33
|
+
puts "munge #{Munge::VERSION}"
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def config_path
|
39
|
+
File.join(destination_root, "config.yml")
|
40
|
+
end
|
41
|
+
|
42
|
+
def rules_path
|
43
|
+
File.join(destination_root, "rules.rb")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "sass"
|
2
|
+
require_relative "sass/asset_urls"
|
3
|
+
|
4
|
+
module Munge
|
5
|
+
module Go
|
6
|
+
module_function
|
7
|
+
|
8
|
+
def add_sass_load_path!(*paths)
|
9
|
+
Sass.load_paths << File.join(*paths)
|
10
|
+
end
|
11
|
+
|
12
|
+
def set_sass_system!(system)
|
13
|
+
Sass::Script::Functions.send(:define_method, :system) do
|
14
|
+
system
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_sass_functions!(asset_roots)
|
19
|
+
Sass::Script::Functions.send(:include, asset_roots)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Sass::Script::Functions
|
2
|
+
def stringify_string(stringish)
|
3
|
+
if stringish.instance_of?(::String)
|
4
|
+
stringish
|
5
|
+
else
|
6
|
+
stringish.value
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def asset_route_helper(root, basename)
|
11
|
+
basename_string = stringify_string(basename)
|
12
|
+
|
13
|
+
item = system.source["#{root}/#{basename_string}"]
|
14
|
+
r = system.router.route(item)
|
15
|
+
|
16
|
+
quoted_string(r)
|
17
|
+
end
|
18
|
+
|
19
|
+
def font_route(basename)
|
20
|
+
asset_route_helper(fonts_root, basename)
|
21
|
+
end
|
22
|
+
|
23
|
+
def font_url(basename)
|
24
|
+
basename_string = stringify_string(basename)
|
25
|
+
|
26
|
+
if basename_string.include?("?")
|
27
|
+
basename_parts = basename_string.split("?")
|
28
|
+
|
29
|
+
base = "#{basename_parts[0]}"
|
30
|
+
qs = "?#{basename_parts[1]}"
|
31
|
+
|
32
|
+
path_to_font = quoted_string(font_route(base).value + qs)
|
33
|
+
|
34
|
+
unquoted_string("url(#{path_to_font})")
|
35
|
+
else
|
36
|
+
unquoted_string("url(#{font_route(basename)})")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def image_url(basename)
|
41
|
+
img_route = asset_route_helper(images_root, basename)
|
42
|
+
unquoted_string("url(#{img_route})")
|
43
|
+
end
|
44
|
+
end
|
@@ -1,22 +1,22 @@
|
|
1
1
|
module Munge
|
2
|
-
module
|
3
|
-
module
|
4
|
-
def
|
2
|
+
module Helpers
|
3
|
+
module AssetPaths
|
4
|
+
def image_path(basename)
|
5
5
|
item = items["#{images_root}/#{basename}"]
|
6
6
|
url_for(item)
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
9
|
+
def font_path(basename)
|
10
10
|
item = items["#{fonts_root}/#{basename}"]
|
11
11
|
url_for(item)
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def stylesheet_path(basename)
|
15
15
|
item = items["#{stylesheets_root}/#{basename}"]
|
16
16
|
url_for(item)
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
19
|
+
def javascript_path(basename)
|
20
20
|
item = items["#{javascripts_root}/#{basename}"]
|
21
21
|
url_for(item)
|
22
22
|
end
|
data/lib/munge/system.rb
CHANGED
@@ -12,39 +12,39 @@ module Munge
|
|
12
12
|
@config = config
|
13
13
|
|
14
14
|
source_item_factory =
|
15
|
-
|
15
|
+
ItemFactory.new(
|
16
16
|
text_extensions: config[:text_extensions] + config[:bintext_extensions],
|
17
17
|
ignore_extensions: false
|
18
18
|
)
|
19
19
|
|
20
20
|
layouts_item_factory =
|
21
|
-
|
21
|
+
ItemFactory.new(
|
22
22
|
text_extensions: config[:text_extensions] + config[:bintext_extensions],
|
23
23
|
ignore_extensions: true
|
24
24
|
)
|
25
25
|
|
26
26
|
@source =
|
27
|
-
|
27
|
+
Collection.new(
|
28
28
|
item_factory: source_item_factory,
|
29
|
-
items:
|
29
|
+
items: Readers::Filesystem.new(source_path)
|
30
30
|
)
|
31
31
|
|
32
32
|
@layouts =
|
33
|
-
|
33
|
+
Collection.new(
|
34
34
|
item_factory: layouts_item_factory,
|
35
|
-
items:
|
35
|
+
items: Readers::Filesystem.new(layouts_path)
|
36
36
|
)
|
37
37
|
|
38
38
|
@alterant =
|
39
|
-
|
39
|
+
Alterant.new
|
40
40
|
|
41
41
|
@router =
|
42
|
-
|
42
|
+
Router.new(
|
43
43
|
alterant: @alterant
|
44
44
|
)
|
45
45
|
|
46
46
|
@writer =
|
47
|
-
|
47
|
+
Write.new(
|
48
48
|
output: output_path
|
49
49
|
)
|
50
50
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative "item_factory/content_parser"
|
2
2
|
|
3
3
|
module Munge
|
4
|
-
|
4
|
+
class System
|
5
5
|
class ItemFactory
|
6
6
|
def initialize(text_extensions:,
|
7
7
|
ignore_extensions:)
|
@@ -38,7 +38,7 @@ module Munge
|
|
38
38
|
type = compute_file_type(relpath)
|
39
39
|
|
40
40
|
if type == :text
|
41
|
-
parsed = Munge::
|
41
|
+
parsed = Munge::System::ItemFactory::ContentParser.new(content)
|
42
42
|
|
43
43
|
build(
|
44
44
|
relpath: relpath,
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Munge
|
2
|
+
class System
|
3
|
+
module Readers
|
4
|
+
class Filesystem
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
def initialize(source_path)
|
8
|
+
@source_path = source_path
|
9
|
+
end
|
10
|
+
|
11
|
+
def each
|
12
|
+
return enum_for(:each) unless block_given?
|
13
|
+
|
14
|
+
filepaths =
|
15
|
+
Dir.glob(File.join(@source_path, "**", "*"))
|
16
|
+
.select { |path| File.file?(path) }
|
17
|
+
|
18
|
+
filepaths.each do |abspath|
|
19
|
+
filehash = Hash[
|
20
|
+
relpath: compute_relpath(abspath),
|
21
|
+
content: compute_content(abspath),
|
22
|
+
stat: compute_stat(abspath)
|
23
|
+
]
|
24
|
+
|
25
|
+
yield filehash
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def compute_stat(abspath)
|
32
|
+
File.stat(abspath)
|
33
|
+
end
|
34
|
+
|
35
|
+
def compute_relpath(abspath)
|
36
|
+
folder = Pathname.new(@source_path)
|
37
|
+
file = Pathname.new(abspath)
|
38
|
+
|
39
|
+
file.relative_path_from(folder).to_s
|
40
|
+
end
|
41
|
+
|
42
|
+
def compute_content(abspath)
|
43
|
+
File.read(abspath)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/munge/version.rb
CHANGED
data/seeds/config/routing.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
system.router.register(
|
2
|
-
|
2
|
+
Routers::Fingerprint.new(
|
3
3
|
extensions: config[:bin_extensions] + config[:bintext_extensions],
|
4
4
|
separator: config[:fingeprint_separator]
|
5
5
|
))
|
6
6
|
system.router.register(
|
7
|
-
|
7
|
+
Routers::RemoveIndexBasename.new(
|
8
8
|
html_extensions: config[:text_extensions],
|
9
9
|
index: config[:index]
|
10
10
|
))
|
11
11
|
system.router.register(
|
12
|
-
|
12
|
+
Routers::AddIndexHtml.new(
|
13
13
|
html_extensions: config[:text_extensions],
|
14
14
|
index: config[:index]
|
15
15
|
))
|
16
16
|
system.router.register(
|
17
|
-
|
17
|
+
Routers::AutoAddExtension.new(
|
18
18
|
keep_extensions: config[:bin_extensions] + config[:bintext_extensions],
|
19
19
|
))
|
data/seeds/config/sass.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
-
require "sass"
|
1
|
+
require "munge/go/sass"
|
2
2
|
|
3
|
-
|
3
|
+
Munge::Go::add_sass_load_path!(root_path, config[:source], AssetRoots.stylesheets_root)
|
4
|
+
|
5
|
+
Munge::Go::set_sass_system!(system)
|
6
|
+
|
7
|
+
Munge::Go::add_sass_functions!(AssetRoots)
|
@@ -1,11 +1,11 @@
|
|
1
|
-
tilt_transformer =
|
2
|
-
tilt_transformer.register(Munge::
|
3
|
-
tilt_transformer.register(Munge::
|
4
|
-
tilt_transformer.register(Munge::
|
5
|
-
tilt_transformer.register(Munge::
|
6
|
-
tilt_transformer.register(Munge::
|
7
|
-
tilt_transformer.register(Munge::
|
8
|
-
tilt_transformer.register(Munge::
|
1
|
+
tilt_transformer = Transformers::Tilt.new(system)
|
2
|
+
tilt_transformer.register(Munge::Helpers::Capture)
|
3
|
+
tilt_transformer.register(Munge::Helpers::Find)
|
4
|
+
tilt_transformer.register(Munge::Helpers::Link)
|
5
|
+
tilt_transformer.register(Munge::Helpers::Rendering)
|
6
|
+
tilt_transformer.register(Munge::Helpers::Tag)
|
7
|
+
tilt_transformer.register(Munge::Helpers::AssetPaths)
|
8
|
+
tilt_transformer.register(Munge::Helpers::AssetTags)
|
9
9
|
tilt_transformer.register(AssetRoots)
|
10
10
|
|
11
11
|
system.alterant.register(tilt_transformer)
|
data/seeds/setup.rb
CHANGED
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.
|
4
|
+
version: 0.6.0
|
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-
|
11
|
+
date: 2016-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -178,7 +178,7 @@ dependencies:
|
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '3.4'
|
181
|
-
description: Documentation for this release is located in https://github.com/zachahn/munge/blob/v0.
|
181
|
+
description: Documentation for this release is located in https://github.com/zachahn/munge/blob/v0.6.0/README.md
|
182
182
|
email:
|
183
183
|
- zach.ahn@gmail.com
|
184
184
|
executables:
|
@@ -199,31 +199,34 @@ files:
|
|
199
199
|
- lib/munge.rb
|
200
200
|
- lib/munge/application.rb
|
201
201
|
- lib/munge/bootstrap.rb
|
202
|
-
- lib/munge/cli.rb
|
203
|
-
- lib/munge/commands/view.rb
|
204
|
-
- lib/munge/
|
205
|
-
- lib/munge/
|
206
|
-
- lib/munge/
|
207
|
-
- lib/munge/
|
208
|
-
- lib/munge/
|
209
|
-
- lib/munge/
|
210
|
-
- lib/munge/
|
211
|
-
- lib/munge/
|
212
|
-
- lib/munge/
|
213
|
-
- lib/munge/
|
214
|
-
- lib/munge/helper/find.rb
|
215
|
-
- lib/munge/helper/link.rb
|
216
|
-
- lib/munge/helper/rendering.rb
|
217
|
-
- lib/munge/helper/tag.rb
|
202
|
+
- lib/munge/cli/commands/build.rb
|
203
|
+
- lib/munge/cli/commands/view.rb
|
204
|
+
- lib/munge/cli/dispatch.rb
|
205
|
+
- lib/munge/go/sass.rb
|
206
|
+
- lib/munge/go/sass/asset_urls.rb
|
207
|
+
- lib/munge/helpers/asset_paths.rb
|
208
|
+
- lib/munge/helpers/asset_tags.rb
|
209
|
+
- lib/munge/helpers/capture.rb
|
210
|
+
- lib/munge/helpers/find.rb
|
211
|
+
- lib/munge/helpers/link.rb
|
212
|
+
- lib/munge/helpers/rendering.rb
|
213
|
+
- lib/munge/helpers/tag.rb
|
218
214
|
- lib/munge/item.rb
|
219
|
-
- lib/munge/readers/filesystem.rb
|
220
215
|
- lib/munge/routers/add_index_html.rb
|
221
216
|
- lib/munge/routers/auto_add_extension.rb
|
222
217
|
- lib/munge/routers/fingerprint.rb
|
223
218
|
- lib/munge/routers/remove_index_basename.rb
|
224
219
|
- lib/munge/runner.rb
|
225
220
|
- lib/munge/system.rb
|
226
|
-
- lib/munge/
|
221
|
+
- lib/munge/system/alterant.rb
|
222
|
+
- lib/munge/system/collection.rb
|
223
|
+
- lib/munge/system/item_factory.rb
|
224
|
+
- lib/munge/system/item_factory/content_parser.rb
|
225
|
+
- lib/munge/system/readers/filesystem.rb
|
226
|
+
- lib/munge/system/router.rb
|
227
|
+
- lib/munge/system/router/itemish.rb
|
228
|
+
- lib/munge/system/write.rb
|
229
|
+
- lib/munge/transformers/tilt.rb
|
227
230
|
- lib/munge/util/config.rb
|
228
231
|
- lib/munge/util/path.rb
|
229
232
|
- lib/munge/util/symbol_hash.rb
|
@@ -234,7 +237,6 @@ files:
|
|
234
237
|
- seeds/config/_asset_roots.rb
|
235
238
|
- seeds/config/routing.rb
|
236
239
|
- seeds/config/sass.rb
|
237
|
-
- seeds/config/sass_helpers.rb
|
238
240
|
- seeds/config/view_helpers.rb
|
239
241
|
- seeds/data.yml
|
240
242
|
- seeds/layouts/default.html.erb
|
data/lib/munge/cli.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require "thor"
|
2
|
-
|
3
|
-
require_relative "commands/view"
|
4
|
-
|
5
|
-
module Munge
|
6
|
-
class CLI < Thor
|
7
|
-
include Thor::Actions
|
8
|
-
|
9
|
-
def self.source_root
|
10
|
-
File.expand_path("../../../seeds", __FILE__)
|
11
|
-
end
|
12
|
-
|
13
|
-
desc "init PATH", "Create new site at PATH"
|
14
|
-
def init(path)
|
15
|
-
directory ".", path
|
16
|
-
end
|
17
|
-
|
18
|
-
desc "build", "Build in current directory"
|
19
|
-
def build
|
20
|
-
Munge::Runner.write(destination_root)
|
21
|
-
end
|
22
|
-
|
23
|
-
desc "view", "View built files"
|
24
|
-
method_option :port, aliases: "-p", desc: "Set port", default: 7000, type: :numeric
|
25
|
-
method_option :host, aliases: "-h", desc: "Set host", default: "0.0.0.0", type: :string
|
26
|
-
def view
|
27
|
-
Munge::Commands::View.new(options, config_path)
|
28
|
-
end
|
29
|
-
|
30
|
-
desc "version", "Print version"
|
31
|
-
def version
|
32
|
-
puts "munge #{Munge::VERSION}"
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def config_path
|
38
|
-
File.join(destination_root, "config.yml")
|
39
|
-
end
|
40
|
-
|
41
|
-
def rules_path
|
42
|
-
File.join(destination_root, "rules.rb")
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module Munge
|
2
|
-
module Reader
|
3
|
-
class Filesystem
|
4
|
-
include Enumerable
|
5
|
-
|
6
|
-
def initialize(source_path)
|
7
|
-
@source_path = source_path
|
8
|
-
end
|
9
|
-
|
10
|
-
def each
|
11
|
-
return enum_for(:each) unless block_given?
|
12
|
-
|
13
|
-
filepaths =
|
14
|
-
Dir.glob(File.join(@source_path, "**", "*"))
|
15
|
-
.select { |path| File.file?(path) }
|
16
|
-
|
17
|
-
filepaths.each do |abspath|
|
18
|
-
filehash = Hash[
|
19
|
-
relpath: compute_relpath(abspath),
|
20
|
-
content: compute_content(abspath),
|
21
|
-
stat: compute_stat(abspath)
|
22
|
-
]
|
23
|
-
|
24
|
-
yield filehash
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def compute_stat(abspath)
|
31
|
-
File.stat(abspath)
|
32
|
-
end
|
33
|
-
|
34
|
-
def compute_relpath(abspath)
|
35
|
-
folder = Pathname.new(@source_path)
|
36
|
-
file = Pathname.new(abspath)
|
37
|
-
|
38
|
-
file.relative_path_from(folder).to_s
|
39
|
-
end
|
40
|
-
|
41
|
-
def compute_content(abspath)
|
42
|
-
File.read(abspath)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
module Sass::Script::Functions
|
2
|
-
include AssetRoots
|
3
|
-
end
|
4
|
-
|
5
|
-
Sass::Script::Functions.send(:define_method, :stringify_string) do |stringish|
|
6
|
-
if stringish.instance_of?(::String)
|
7
|
-
stringish
|
8
|
-
else
|
9
|
-
stringish.value
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
Sass::Script::Functions.send(:define_method, :route) do |id_ruby_string|
|
14
|
-
item = system.source[id_ruby_string]
|
15
|
-
r = system.router.route(item)
|
16
|
-
|
17
|
-
quoted_string(r)
|
18
|
-
end
|
19
|
-
|
20
|
-
Sass::Script::Functions.send(:define_method, :asset_route_helper) do |root, basename|
|
21
|
-
basename_string = stringify_string(basename)
|
22
|
-
|
23
|
-
route("#{root}/#{basename_string}")
|
24
|
-
end
|
25
|
-
|
26
|
-
Sass::Script::Functions.send(:define_method, :font_route) do |basename|
|
27
|
-
asset_route_helper(fonts_root, basename)
|
28
|
-
end
|
29
|
-
|
30
|
-
Sass::Script::Functions.send(:define_method, :image_route) do |basename|
|
31
|
-
asset_route_helper(images_root, basename)
|
32
|
-
end
|
33
|
-
|
34
|
-
Sass::Script::Functions.send(:define_method, :font_url) do |basename|
|
35
|
-
basename_string = stringify_string(basename)
|
36
|
-
|
37
|
-
if basename_string.include?("?")
|
38
|
-
basename_parts = basename_string.split("?")
|
39
|
-
|
40
|
-
base = "#{basename_parts[0]}"
|
41
|
-
qs = "?#{basename_parts[1]}"
|
42
|
-
|
43
|
-
path_to_font = quoted_string(font_route(base).value + qs)
|
44
|
-
|
45
|
-
unquoted_string("url(#{path_to_font})")
|
46
|
-
else
|
47
|
-
unquoted_string("url(#{font_route(basename)})")
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
Sass::Script::Functions.send(:define_method, :image_url) do |basename|
|
52
|
-
img_route = image_route(basename)
|
53
|
-
unquoted_string("url(#{img_route})")
|
54
|
-
end
|