munge 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/exe/munge +2 -2
  3. data/lib/munge.rb +21 -18
  4. data/lib/munge/bootstrap.rb +9 -2
  5. data/lib/munge/cli/commands/build.rb +11 -0
  6. data/lib/munge/{commands → cli/commands}/view.rb +15 -13
  7. data/lib/munge/cli/dispatch.rb +47 -0
  8. data/lib/munge/go/sass.rb +22 -0
  9. data/lib/munge/go/sass/asset_urls.rb +44 -0
  10. data/lib/munge/{helper/asset_urls.rb → helpers/asset_paths.rb} +6 -6
  11. data/lib/munge/{helper → helpers}/asset_tags.rb +1 -1
  12. data/lib/munge/{helper → helpers}/capture.rb +1 -1
  13. data/lib/munge/{helper → helpers}/find.rb +1 -1
  14. data/lib/munge/{helper → helpers}/link.rb +1 -1
  15. data/lib/munge/{helper → helpers}/rendering.rb +1 -1
  16. data/lib/munge/{helper → helpers}/tag.rb +1 -1
  17. data/lib/munge/routers/add_index_html.rb +1 -1
  18. data/lib/munge/routers/auto_add_extension.rb +1 -1
  19. data/lib/munge/routers/fingerprint.rb +1 -1
  20. data/lib/munge/routers/remove_index_basename.rb +1 -1
  21. data/lib/munge/system.rb +9 -9
  22. data/lib/munge/{core → system}/alterant.rb +2 -3
  23. data/lib/munge/{core → system}/collection.rb +1 -1
  24. data/lib/munge/{core → system}/item_factory.rb +2 -2
  25. data/lib/munge/{core → system}/item_factory/content_parser.rb +1 -1
  26. data/lib/munge/system/readers/filesystem.rb +48 -0
  27. data/lib/munge/{core → system}/router.rb +1 -1
  28. data/lib/munge/{core → system}/router/itemish.rb +1 -1
  29. data/lib/munge/{core → system}/write.rb +1 -1
  30. data/lib/munge/{transformer → transformers}/tilt.rb +1 -1
  31. data/lib/munge/version.rb +1 -1
  32. data/seeds/config/routing.rb +4 -4
  33. data/seeds/config/sass.rb +6 -2
  34. data/seeds/config/view_helpers.rb +8 -8
  35. data/seeds/setup.rb +1 -1
  36. metadata +24 -22
  37. data/lib/munge/cli.rb +0 -45
  38. data/lib/munge/readers/filesystem.rb +0 -46
  39. data/seeds/config/sass_helpers.rb +0 -54
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4cfe4d5e02bf3872299162b668845fbe856db41a
4
- data.tar.gz: c1acc5e8fc9dd7c6a1c3ca2f1d7d12e360e080d7
3
+ metadata.gz: cdbfe2a9223c246cb18bd9fcdaf389c52075eef5
4
+ data.tar.gz: 591d3ea317628eeed159e629e31bb476777be91d
5
5
  SHA512:
6
- metadata.gz: 62174c45cdfb612a0351bfb37083a92f1109e25f618ddad861e086fa8e9274128f13aec4787e230d1707ffb1c723c74ce9008854d3edc4c523a7d79cab16bb6e
7
- data.tar.gz: ec309d87bce9804227edbb8b0b86baeaadf4ac3e479edc451e795c78fb6dbc1f6fe686dc3f95818221be02b2b2fa54e52c584e9063053d94f7619c0e88156f1a
6
+ metadata.gz: 3360ab60a36319f56066a7a82967bde4c5d70f4bae08d6b0709eb8c8b1531f1caf1aefe0eb351aa3a9a27803898d61ed2446a98fe4daded6bbc164d2dd8ab9ef
7
+ data.tar.gz: bddb33da3a1739658e3f9bcc510e10244bf0a461a2963c83d3ba062808a4dc3907fea300d3e4ed26c9d8323ff576b111e59598d85bf8c6348520356c1b77ef0d
data/exe/munge CHANGED
@@ -6,6 +6,6 @@ if File.exist?(File.expand_path("../../.git", __FILE__))
6
6
  end
7
7
 
8
8
  require "munge"
9
- require "munge/cli"
9
+ require "munge/cli/dispatch"
10
10
 
11
- Munge::CLI.start(ARGV)
11
+ Munge::Cli::Dispatch.start(ARGV)
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/helper/asset_tags"
15
- require "munge/helper/asset_urls"
16
- require "munge/helper/capture"
17
- require "munge/helper/find"
18
- require "munge/helper/link"
19
- require "munge/helper/rendering"
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"
@@ -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
- binding.eval(setup_string, setup_path)
58
+ import(setup_path, setup_string)
58
59
 
59
60
  @app = Munge::Application.new(system)
60
61
 
61
- binding.eval(rules_string, rules_path)
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
@@ -0,0 +1,11 @@
1
+ module Munge
2
+ module Cli
3
+ module Commands
4
+ class Build
5
+ def initialize(destination_root)
6
+ Munge::Runner.write(destination_root)
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -25,21 +25,23 @@ require "adsf"
25
25
  require "rack"
26
26
 
27
27
  module Munge
28
- class Commands
29
- class View
30
- def initialize(options, config_path)
31
- config = Munge::Util::Config.read(config_path)
32
- rack_opts = { Host: options[:host], Port: options[:port] }
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
- app =
35
- Rack::Builder.new do
36
- use Rack::ShowExceptions
37
- use Rack::Head
38
- use Adsf::Rack::IndexFileFinder, root: config[:output]
39
- run Rack::File.new(config[:output])
40
- end
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
- Rack::Handler::WEBrick.run(app, rack_opts)
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 Helper
3
- module AssetUrls
4
- def image_url(basename)
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 font_url(basename)
9
+ def font_path(basename)
10
10
  item = items["#{fonts_root}/#{basename}"]
11
11
  url_for(item)
12
12
  end
13
13
 
14
- def stylesheet_url(basename)
14
+ def stylesheet_path(basename)
15
15
  item = items["#{stylesheets_root}/#{basename}"]
16
16
  url_for(item)
17
17
  end
18
18
 
19
- def javascript_url(basename)
19
+ def javascript_path(basename)
20
20
  item = items["#{javascripts_root}/#{basename}"]
21
21
  url_for(item)
22
22
  end
@@ -1,5 +1,5 @@
1
1
  module Munge
2
- module Helper
2
+ module Helpers
3
3
  module AssetTags
4
4
  def stylesheet_tag(basename, options = {})
5
5
  options[:rel] = "stylesheet"
@@ -1,5 +1,5 @@
1
1
  module Munge
2
- module Helper
2
+ module Helpers
3
3
  module Capture
4
4
  def capture(&block)
5
5
  if block.binding.local_variable_defined?(:_erbout)
@@ -1,5 +1,5 @@
1
1
  module Munge
2
- module Helper
2
+ module Helpers
3
3
  module Find
4
4
  def items
5
5
  @source
@@ -1,5 +1,5 @@
1
1
  module Munge
2
- module Helper
2
+ module Helpers
3
3
  module Link
4
4
  def url_for(item)
5
5
  @router.route(item)
@@ -1,5 +1,5 @@
1
1
  module Munge
2
- module Helper
2
+ module Helpers
3
3
  module Rendering
4
4
  def render(item, engines: nil, data: {}, content_override: nil)
5
5
  content = content_override || item.content
@@ -1,5 +1,5 @@
1
1
  module Munge
2
- module Helper
2
+ module Helpers
3
3
  module Tag
4
4
  def empty_tag(name, options = {})
5
5
  options_str = options.map { |k, v| %(#{k}="#{v}") }.join(" ")
@@ -1,5 +1,5 @@
1
1
  module Munge
2
- module Router
2
+ module Routers
3
3
  class AddIndexHtml
4
4
  def initialize(html_extensions:, index:)
5
5
  @html_extensions = html_extensions
@@ -1,5 +1,5 @@
1
1
  module Munge
2
- module Router
2
+ module Routers
3
3
  class AutoAddExtension
4
4
  def initialize(keep_extensions:)
5
5
  @keep_extensions = keep_extensions
@@ -1,5 +1,5 @@
1
1
  module Munge
2
- module Router
2
+ module Routers
3
3
  class Fingerprint
4
4
  def initialize(extensions:,
5
5
  separator:)
@@ -1,5 +1,5 @@
1
1
  module Munge
2
- module Router
2
+ module Routers
3
3
  class RemoveIndexBasename
4
4
  def initialize(html_extensions:, index:)
5
5
  @html_extensions = html_extensions
data/lib/munge/system.rb CHANGED
@@ -12,39 +12,39 @@ module Munge
12
12
  @config = config
13
13
 
14
14
  source_item_factory =
15
- Core::ItemFactory.new(
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
- Core::ItemFactory.new(
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
- Core::Collection.new(
27
+ Collection.new(
28
28
  item_factory: source_item_factory,
29
- items: Reader::Filesystem.new(source_path)
29
+ items: Readers::Filesystem.new(source_path)
30
30
  )
31
31
 
32
32
  @layouts =
33
- Core::Collection.new(
33
+ Collection.new(
34
34
  item_factory: layouts_item_factory,
35
- items: Reader::Filesystem.new(layouts_path)
35
+ items: Readers::Filesystem.new(layouts_path)
36
36
  )
37
37
 
38
38
  @alterant =
39
- Core::Alterant.new(scope: self)
39
+ Alterant.new
40
40
 
41
41
  @router =
42
- Core::Router.new(
42
+ Router.new(
43
43
  alterant: @alterant
44
44
  )
45
45
 
46
46
  @writer =
47
- Core::Write.new(
47
+ Write.new(
48
48
  output: output_path
49
49
  )
50
50
  end
@@ -1,8 +1,7 @@
1
1
  module Munge
2
- module Core
2
+ class System
3
3
  class Alterant
4
- def initialize(scope:)
5
- @scope = scope
4
+ def initialize
6
5
  @registry = {}
7
6
  end
8
7
 
@@ -1,5 +1,5 @@
1
1
  module Munge
2
- module Core
2
+ class System
3
3
  class Collection
4
4
  include Enumerable
5
5
 
@@ -1,7 +1,7 @@
1
1
  require_relative "item_factory/content_parser"
2
2
 
3
3
  module Munge
4
- module Core
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::Core::ItemFactory::ContentParser.new(content)
41
+ parsed = Munge::System::ItemFactory::ContentParser.new(content)
42
42
 
43
43
  build(
44
44
  relpath: relpath,
@@ -1,5 +1,5 @@
1
1
  module Munge
2
- module Core
2
+ class System
3
3
  class ItemFactory
4
4
  class ContentParser
5
5
  def self.match(string)
@@ -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
@@ -1,7 +1,7 @@
1
1
  require_relative "router/itemish"
2
2
 
3
3
  module Munge
4
- module Core
4
+ class System
5
5
  class Router
6
6
  def initialize(alterant:)
7
7
  @registries = { route: [], filepath: [] }
@@ -1,5 +1,5 @@
1
1
  module Munge
2
- module Core
2
+ class System
3
3
  class Router
4
4
  class Itemish
5
5
  extend Forwardable
@@ -1,5 +1,5 @@
1
1
  module Munge
2
- module Core
2
+ class System
3
3
  class Write
4
4
  def initialize(output:)
5
5
  @output = output
@@ -1,5 +1,5 @@
1
1
  module Munge
2
- module Transformer
2
+ module Transformers
3
3
  class Tilt
4
4
  def initialize(scope)
5
5
  @pristine_scope = scope
data/lib/munge/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Munge
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -1,19 +1,19 @@
1
1
  system.router.register(
2
- Router::Fingerprint.new(
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
- Router::RemoveIndexBasename.new(
7
+ Routers::RemoveIndexBasename.new(
8
8
  html_extensions: config[:text_extensions],
9
9
  index: config[:index]
10
10
  ))
11
11
  system.router.register(
12
- Router::AddIndexHtml.new(
12
+ Routers::AddIndexHtml.new(
13
13
  html_extensions: config[:text_extensions],
14
14
  index: config[:index]
15
15
  ))
16
16
  system.router.register(
17
- Router::AutoAddExtension.new(
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
- Sass.load_paths << File.join(root_path, config[:source], "assets/stylesheets")
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 = Transformer::Tilt.new(system)
2
- tilt_transformer.register(Munge::Helper::Capture)
3
- tilt_transformer.register(Munge::Helper::Find)
4
- tilt_transformer.register(Munge::Helper::Link)
5
- tilt_transformer.register(Munge::Helper::Rendering)
6
- tilt_transformer.register(Munge::Helper::Tag)
7
- tilt_transformer.register(Munge::Helper::AssetUrls)
8
- tilt_transformer.register(Munge::Helper::AssetTags)
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
@@ -1,3 +1,3 @@
1
1
  Dir.glob(File.join(config_path, "*.rb")).sort.each do |file_path|
2
- binding.eval(File.read(file_path), file_path)
2
+ import(file_path)
3
3
  end
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.5.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-01-16 00:00:00.000000000 Z
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.5.0/README.md
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/core/alterant.rb
205
- - lib/munge/core/collection.rb
206
- - lib/munge/core/item_factory.rb
207
- - lib/munge/core/item_factory/content_parser.rb
208
- - lib/munge/core/router.rb
209
- - lib/munge/core/router/itemish.rb
210
- - lib/munge/core/write.rb
211
- - lib/munge/helper/asset_tags.rb
212
- - lib/munge/helper/asset_urls.rb
213
- - lib/munge/helper/capture.rb
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/transformer/tilt.rb
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